From a5a9caea2b06a69953f692289866e59f52d78a4c Mon Sep 17 00:00:00 2001 From: Richard Theis Date: Mon, 4 Apr 2016 16:20:20 -0500 Subject: 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 --- openstackclient/network/v2/security_group_rule.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'openstackclient/network/v2') 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='', + 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) -- cgit v1.2.1