summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-04-14 21:45:03 +0000
committerGerrit Code Review <review@openstack.org>2016-04-14 21:45:03 +0000
commit52a12e743ea1047b6c34cd66dcb60cd61638ce1f (patch)
treeb325a98e44afd1b1954ac4bcffb7bdf3c9124eb9 /openstackclient/network
parentef68f23de3886cac3e92a45537d5eb2136ae150a (diff)
parenta5a9caea2b06a69953f692289866e59f52d78a4c (diff)
downloadpython-openstackclient-52a12e743ea1047b6c34cd66dcb60cd61638ce1f.tar.gz
Merge "Add project options to security group rule create"
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)