Add os_ prefix to project_domain_name/id

Running glance without defining --os-tenant-id and
--os-tenant-name leads to AttributeError. Add os_ prefix
to project_domain_name and project_domain_id because args
object doesn't have them

Closes-Bug: #1384759

Change-Id: Id85569aad538efcf327312d9936bb6463279ce34
This commit is contained in:
Oleksii Chuprykov 2014-10-23 18:12:23 +03:00
parent 521cc25a0a
commit bd73a5482c
2 changed files with 19 additions and 3 deletions
glanceclient
tests

@ -475,12 +475,12 @@ class OpenStackImagesShell(object):
project_info = (args.os_tenant_name or
args.os_tenant_id or
(args.os_project_name and
(args.project_domain_name or
args.project_domain_id)) or
(args.os_project_domain_name or
args.os_project_domain_id)) or
args.os_project_id)
if (not project_info):
# tenent is deprecated in Keystone v3. Use the latest
# tenant is deprecated in Keystone v3. Use the latest
# terminology instead.
raise exc.CommandError(
_("You must provide a project_id or project_name ("

@ -273,6 +273,22 @@ class ShellTest(utils.TestCase):
# Make sure we are actually prompted.
mock_getpass.assert_called_with('OS Password: ')
@mock.patch(
'glanceclient.shell.OpenStackImagesShell._get_keystone_session')
@mock.patch.object(openstack_shell.OpenStackImagesShell, '_cache_schemas')
def test_no_auth_with_proj_name(self, cache_schemas, session):
with mock.patch('glanceclient.v2.client.Client'):
args = ('--os-project-name myname '
'--os-project-domain-name mydomain '
'--os-project-domain-id myid '
'--os-image-api-version 2 image-list')
glance_shell = openstack_shell.OpenStackImagesShell()
glance_shell.main(args.split())
((args), kwargs) = session.call_args
self.assertEqual('myname', kwargs['project_name'])
self.assertEqual('mydomain', kwargs['project_domain_name'])
self.assertEqual('myid', kwargs['project_domain_id'])
class ShellTestWithKeystoneV3Auth(ShellTest):
# auth environment to use