summaryrefslogtreecommitdiff
path: root/openstackclient/network
diff options
context:
space:
mode:
authorRichard Theis <rtheis@us.ibm.com>2016-03-11 08:11:12 -0600
committerRichard Theis <rtheis@us.ibm.com>2016-03-11 08:28:53 -0600
commita7c76878da02da406c9ccbcd62cc40def1108faa (patch)
treee694c790ba0671dba1b62a615f2f35671808fb58 /openstackclient/network
parent3737c5a842f727ad9d28fd10af67784efc6ab416 (diff)
downloadpython-openstackclient-a7c76878da02da406c9ccbcd62cc40def1108faa.tar.gz
Add project options to security group create
Add the --project and --project-domain options to the 'os security group create' command. These options are for Network v2 only. Change-Id: I9e1667080a1a49389d51ade2e76a08b08a09870b Closes-Bug: #1519511 Implements: blueprint neutron-client
Diffstat (limited to 'openstackclient/network')
-rw-r--r--openstackclient/network/v2/security_group.py21
1 files changed, 21 insertions, 0 deletions
diff --git a/openstackclient/network/v2/security_group.py b/openstackclient/network/v2/security_group.py
index f8162477..92498144 100644
--- a/openstackclient/network/v2/security_group.py
+++ b/openstackclient/network/v2/security_group.py
@@ -17,6 +17,7 @@ import argparse
import six
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
@@ -107,6 +108,15 @@ class CreateSecurityGroup(common.NetworkAndComputeShowOne):
)
return parser
+ def update_parser_network(self, parser):
+ 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 _get_description(self, parsed_args):
if parsed_args.description is not None:
return parsed_args.description
@@ -114,9 +124,20 @@ class CreateSecurityGroup(common.NetworkAndComputeShowOne):
return parsed_args.name
def take_action_network(self, client, parsed_args):
+ # Build the create attributes.
attrs = {}
attrs['name'] = parsed_args.name
attrs['description'] = self._get_description(parsed_args)
+ 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 the security group and display the results.
obj = client.create_security_group(**attrs)
display_columns, property_columns = _get_columns(obj)
data = utils.get_item_properties(