Add endpoint commands help text
Makes the new endpoint-* commands help text consistient with the other keystone commands. Also removes 'nargs' from options that require arguments. Change-Id: Idc638883b3675cf1d30163064e58ffe761c6f08b
This commit is contained in:
@@ -322,37 +322,33 @@ def do_endpoint_get(kc, args):
|
||||
|
||||
|
||||
def do_endpoint_list(kc, args):
|
||||
"""List configured service endpoints"""
|
||||
endpoints = kc.endpoints.list()
|
||||
utils.print_list(endpoints,
|
||||
['id', 'region', 'publicurl', 'internalurl', 'publicurl'])
|
||||
['id', 'region', 'publicurl', 'internalurl', 'adminurl'])
|
||||
|
||||
|
||||
@utils.arg('--region', metavar='<endpoint_region>',
|
||||
help='Endpoint region', nargs='?', default='regionOne')
|
||||
@utils.arg('--service_id', metavar='<service_id>',
|
||||
help='ID of service associated with Endpoint', nargs='?')
|
||||
@utils.arg('--publicurl', metavar='<publicurl>',
|
||||
help='Public URL endpoint', nargs='?')
|
||||
@utils.arg('--adminurl', metavar='<publicurl>',
|
||||
help='Admin URL endpoint', nargs='?')
|
||||
@utils.arg('--internalurl', metavar='<publicurl>',
|
||||
help='Internal URL endpoint', nargs='?')
|
||||
@utils.arg('--region', metavar='<endpoint-region>',
|
||||
help='Endpoint region', default='regionOne')
|
||||
@utils.arg('--service_id', metavar='<service-id>',
|
||||
help='ID of service associated with Endpoint')
|
||||
@utils.arg('--publicurl', metavar='<public-url>',
|
||||
help='Public URL endpoint')
|
||||
@utils.arg('--adminurl', metavar='<admin-url>',
|
||||
help='Admin URL endpoint')
|
||||
@utils.arg('--internalurl', metavar='<internal-url>',
|
||||
help='Internal URL endpoint')
|
||||
def do_endpoint_create(kc, args):
|
||||
kwargs = {
|
||||
'region': args.region,
|
||||
'service_id': args.service_id,
|
||||
'publicurl': args.publicurl,
|
||||
'adminurl': args.adminurl,
|
||||
'internalurl': args.internalurl,
|
||||
}
|
||||
"""Create a new endpoint associated with a service"""
|
||||
endpoint = kc.endpoints.create(
|
||||
args.region, args.service_id, args.publicurl,
|
||||
args.adminurl, args.internalurl)
|
||||
utils.print_dict(endpoint._info)
|
||||
|
||||
|
||||
@utils.arg('id', metavar='<endpoint_id>', help='ID of endpoint to delete')
|
||||
@utils.arg('id', metavar='<endpoint-id>', help='ID of endpoint to delete')
|
||||
def do_endpoint_delete(kc, args):
|
||||
"""Delete a service endpoint"""
|
||||
try:
|
||||
kc.endpoints.delete(args.id)
|
||||
print 'Endpoint has been deleted.'
|
||||
|
@@ -175,3 +175,25 @@ class ShellTest(utils.TestCase):
|
||||
do_shell_mock):
|
||||
shell('ec2-credentials-delete')
|
||||
assert do_shell_mock.called
|
||||
|
||||
def test_do_endpoints(self):
|
||||
do_shell_mock = mock.MagicMock()
|
||||
# grab the decorators for do_endpoint_create
|
||||
shell_func = getattr(shell_v2_0, 'do_endpoint_create')
|
||||
do_shell_mock.arguments = getattr(shell_func, 'arguments', [])
|
||||
with mock.patch('keystoneclient.v2_0.shell.do_endpoint_create',
|
||||
do_shell_mock):
|
||||
|
||||
# Test create args
|
||||
shell('endpoint-create '
|
||||
'--service_id=2 --publicurl=http://example.com:1234/go '
|
||||
'--adminurl=http://example.com:9876/adm')
|
||||
assert do_shell_mock.called
|
||||
((a, b), c) = do_shell_mock.call_args
|
||||
assert (b.auth_url, b.password, b.os_tenant_id,
|
||||
b.tenant_name, b.username, b.identity_api_version) == \
|
||||
(DEFAULT_AUTH_URL, DEFAULT_PASSWORD, DEFAULT_TENANT_ID,
|
||||
DEFAULT_TENANT_NAME, DEFAULT_USERNAME, '')
|
||||
assert (b.service_id, b.publicurl, b.adminurl) == ('2',
|
||||
'http://example.com:1234/go',
|
||||
'http://example.com:9876/adm')
|
||||
|
Reference in New Issue
Block a user