fix confused domain argument for network create v2

we have used domain scope arguments --project-domain, --user-domain
and --group-domain in identity commands, for example, role add v3,
to prevent resources conflict from same resource name existence.
To keep with the style of identity commands, it's better to rename
--domain to --project-domain.

Closes-Bug: #1468988
Change-Id: Ic6ccb895cf9be4a3d5f0001525e3b80cd340da8b
This commit is contained in:
Guojian Shao 2015-06-26 12:07:58 +08:00
parent ec31a2a12e
commit 8899bc4162
3 changed files with 16 additions and 24 deletions

View File

@ -13,20 +13,20 @@ Create new network
.. code:: bash .. code:: bash
os network create os network create
[--domain <domain>] [--project <project> [--project-domain <project-domain>]]
[--enable | --disable] [--enable | --disable]
[--project <project>]
[--share | --no-share] [--share | --no-share]
<name> <name>
.. option:: --domain <domain>
Owner's domain (name or ID)
.. option:: --project <project> .. option:: --project <project>
Owner's project (name or ID) Owner's project (name or ID)
.. option:: --project-domain <project-domain>
Domain the project belongs to (name or ID).
This can be used in case collisions between project names exist.
.. option:: --enable .. option:: --enable
Enable network (default) Enable network (default)

View File

@ -87,10 +87,7 @@ class CreateNetwork(show.ShowOne):
'--project', '--project',
metavar='<project>', metavar='<project>',
help="Owner's project (name or ID)") help="Owner's project (name or ID)")
parser.add_argument( identity_common.add_project_domain_option_to_parser(parser)
'--domain',
metavar='<domain>',
help="Owner's domain (name or ID)")
return parser return parser
def take_action(self, parsed_args): def take_action(self, parsed_args):
@ -112,15 +109,11 @@ class CreateNetwork(show.ShowOne):
body['shared'] = parsed_args.shared body['shared'] = parsed_args.shared
if parsed_args.project is not None: if parsed_args.project is not None:
identity_client = self.app.client_manager.identity identity_client = self.app.client_manager.identity
if parsed_args.domain is not None: project_id = identity_common.find_project(
domain = identity_common.find_domain(identity_client, identity_client,
parsed_args.domain) parsed_args.project,
project_id = utils.find_resource(identity_client.projects, parsed_args.project_domain,
parsed_args.project, ).id
domain_id=domain.id).id
else:
project_id = utils.find_resource(identity_client.projects,
parsed_args.project).id
body['tenant_id'] = project_id body['tenant_id'] = project_id
return {'network': body} return {'network': body}

View File

@ -90,14 +90,14 @@ class TestCreateNetwork(common.TestNetworkBase):
"--disable", "--disable",
"--share", "--share",
"--project", identity_fakes_v3.project_name, "--project", identity_fakes_v3.project_name,
"--domain", identity_fakes_v3.domain_name, "--project-domain", identity_fakes_v3.domain_name,
FAKE_NAME, FAKE_NAME,
] + self.given_show_options ] + self.given_show_options
verifylist = [ verifylist = [
('admin_state', False), ('admin_state', False),
('shared', True), ('shared', True),
('project', identity_fakes_v3.project_name), ('project', identity_fakes_v3.project_name),
('domain', identity_fakes_v3.domain_name), ('project_domain', identity_fakes_v3.domain_name),
('name', FAKE_NAME), ('name', FAKE_NAME),
] + self.then_show_options ] + self.then_show_options
mocker = mock.Mock(return_value=copy.deepcopy(RESPONSE)) mocker = mock.Mock(return_value=copy.deepcopy(RESPONSE))
@ -165,7 +165,6 @@ class TestCreateNetwork(common.TestNetworkBase):
arglist = [ arglist = [
"--project", identity_fakes_v2.project_name, "--project", identity_fakes_v2.project_name,
FAKE_NAME, FAKE_NAME,
] ]
verifylist = [ verifylist = [
('admin_state', True), ('admin_state', True),
@ -203,14 +202,14 @@ class TestCreateNetwork(common.TestNetworkBase):
def test_create_with_domain_identityv2(self): def test_create_with_domain_identityv2(self):
arglist = [ arglist = [
"--project", identity_fakes_v3.project_name, "--project", identity_fakes_v3.project_name,
"--domain", identity_fakes_v3.domain_name, "--project-domain", identity_fakes_v3.domain_name,
FAKE_NAME, FAKE_NAME,
] ]
verifylist = [ verifylist = [
('admin_state', True), ('admin_state', True),
('shared', None), ('shared', None),
('project', identity_fakes_v3.project_name), ('project', identity_fakes_v3.project_name),
('domain', identity_fakes_v3.domain_name), ('project_domain', identity_fakes_v3.domain_name),
('name', FAKE_NAME), ('name', FAKE_NAME),
] ]
mocker = mock.Mock(return_value=copy.deepcopy(RESPONSE)) mocker = mock.Mock(return_value=copy.deepcopy(RESPONSE))