summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorRichard Theis <rtheis@us.ibm.com>2016-04-04 16:20:20 -0500
committerRichard Theis <rtheis@us.ibm.com>2016-04-11 10:05:24 -0500
commita5a9caea2b06a69953f692289866e59f52d78a4c (patch)
tree9c82d9603791f1f9b955438de63fa45215c5ec82 /openstackclient/network
parent3a3f33b9265b63b681727f220d26286c763e67e3 (diff)
downloadpython-openstackclient-a5a9caea2b06a69953f692289866e59f52d78a4c.tar.gz
Add project options to security group rule create
Add the --project and --project-domain options to the 'os security group rule create' command. These options are for Network v2 only. Change-Id: Ie3e136be076f0f2c22fbe7048d1d6eaebf5aa655 Partial-Bug: #1519512 Implements: blueprint neutron-client
Diffstat (limited to 'openstackclient/network')
-rw-r--r--openstackclient/network/v2/security_group_rule.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/openstackclient/network/v2/security_group_rule.py b/openstackclient/network/v2/security_group_rule.py
index 83250914..509b1974 100644
--- a/openstackclient/network/v2/security_group_rule.py
+++ b/openstackclient/network/v2/security_group_rule.py
@@ -23,6 +23,7 @@ except ImportError:
from openstackclient.common import exceptions
from openstackclient.common import parseractions
from openstackclient.common import utils
+from openstackclient.identity import common as identity_common
from openstackclient.network import common
from openstackclient.network import utils as network_utils
@@ -120,6 +121,12 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
help='Ethertype of network traffic '
'(IPv4, IPv6; default: IPv4)',
)
+ parser.add_argument(
+ '--project',
+ metavar='<project>',
+ help="Owner's project (name or ID)"
+ )
+ identity_common.add_project_domain_option_to_parser(parser)
return parser
def take_action_network(self, client, parsed_args):
@@ -159,6 +166,14 @@ class CreateSecurityGroupRule(common.NetworkAndComputeShowOne):
elif attrs['ethertype'] == 'IPv4':
attrs['remote_ip_prefix'] = '0.0.0.0/0'
attrs['security_group_id'] = security_group_id
+ if parsed_args.project is not None:
+ identity_client = self.app.client_manager.identity
+ project_id = identity_common.find_project(
+ identity_client,
+ parsed_args.project,
+ parsed_args.project_domain,
+ ).id
+ attrs['tenant_id'] = project_id
# Create and show the security group rule.
obj = client.create_security_group_rule(**attrs)