def do_user_get(kclient, args): """Display user details.""" if args.by_name: user = kclient.users.get_by_name(args.id) else: user = kclient.users.get(args.id) utils.print_dict(user._info)
def do_quota_create(kc, args): """Create quota.""" quota = kc.quotas.create(user_id=args.user_id, project_id=args.tenant_id, resource_id=args.resource_id, limit=args.limit) utils.print_dict(quota._info)
def do_tenant_create(kc, args): """Create new tenant.""" tenant = kc.tenants.create(args.name, description=args.description, parent_project_id=args.parent_project_id, enabled=strutils.bool_from_string(args.enabled)) utils.print_dict(tenant._info)
def do_tenant_create(kc, args): """Create new tenant""" tenant = kc.tenants.create(args.name, description=args.description, enabled=utils.string_to_bool(args.enabled), props=args.props) utils.print_dict(tenant._info)
def do_quota_create(kc, args): """Create quota.""" quota = kc.quotas.create(user_id=args.user_id, project_id=args.tenant_id, resource_id=args.resource_id, limit=args.limit) utils.print_dict(quota._info)
def do_user_create(kc, args): user = kc.users.create(args.username, args.password, args.email, tenant_id=args.default_tenant, enabled=args.enabled) utils.print_dict(user._info)
def do_tenant_get(kclient, args): """Display tenant details""" if args.by_name: tenant = kclient.tenants.get_by_name(args.id) else: tenant = kclient.tenants.get(args.id) utils.print_dict(tenant._info)
def do_tenant_create(kc, args): """Create new tenant.""" tenant = kc.tenants.create(args.name, description=args.description, parent_project_id=args.parent_project_id, enabled=strutils.bool_from_string(args.enabled)) utils.print_dict(tenant._info)
def do_user_create(kc, args): """Create new user""" user = kc.users.create(args.name, args.passwd, args.email, tenant_id=args.tenant_id, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(user._info)
def do_catalog(kc, args): """List service catalog, possibly filtered by service.""" endpoints = kc.service_catalog.get_endpoints(service_type=args.service) for (service, service_endpoints) in six.iteritems(endpoints): if len(service_endpoints) > 0: print("Service: %s" % service) for ep in service_endpoints: utils.print_dict(ep)
def do_catalog(kc, args): """List service catalog, possibly filtered by service.""" endpoints = kc.service_catalog.get_endpoints(service_type=args.service) for (service, service_endpoints) in six.iteritems(endpoints): if len(service_endpoints) > 0: print(_("Service: %s") % service) for ep in service_endpoints: utils.print_dict(ep)
def do_ec2_credentials_get(kc, args): """Display EC2-compatible credentials.""" if not args.user_id: # use the authenticated user id as a default args.user_id = kc.auth_user_id cred = kc.ec2.get(args.user_id, args.access) if cred: utils.print_dict(cred._info)
def do_endpoint_create(kc, args): """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)
def do_endpoint_create(kc, args): """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)
def do_ec2_credentials_get(kc, args): """Display EC2-compatible credentials.""" if not args.user_id: # use the authenticated user id as a default args.user_id = kc.auth_user_id cred = kc.ec2.get(args.user_id, args.access) if cred: utils.print_dict(cred._info)
def do_endpoint_create(kc, args): """Create a new endpoint associated with a service.""" service_id = utils.find_resource(kc.services, args.service).id endpoint = kc.endpoints.create(args.region, service_id, args.publicurl, args.adminurl, args.internalurl) utils.print_dict(endpoint._info)
def do_endpoint_create(kc, args): """Create a new endpoint associated with a service.""" service_id = utils.find_resource(kc.services, args.service).id endpoint = kc.endpoints.create(args.region, service_id, args.publicurl, args.adminurl, args.internalurl) utils.print_dict(endpoint._info)
def test_print_dict_unicode(self): name = u'\u540d\u5b57' utils.print_dict({'name': name}) output = self.stdout.getvalue() # In Python 2, output will be bytes, while in Python 3, it will not. # Let's decode the value if needed. if isinstance(output, six.binary_type): output = output.decode('utf-8') self.assertIn(name, output)
def do_ec2_credentials_create(kc, args): """Create EC2-compatible credentials for user per tenant.""" if not args.tenant_id: # use the authenticated tenant id as a default args.tenant_id = kc.auth_tenant_id if not args.user_id: # use the authenticated user id as a default args.user_id = kc.auth_user_id credentials = kc.ec2.create(args.user_id, args.tenant_id) utils.print_dict(credentials._info)
def do_ec2_credentials_create(kc, args): """Create EC2-compatible credentials for user per tenant.""" if not args.tenant_id: # use the authenticated tenant id as a default args.tenant_id = kc.auth_tenant_id if not args.user_id: # use the authenticated user id as a default args.user_id = kc.auth_user_id credentials = kc.ec2.create(args.user_id, args.tenant_id) utils.print_dict(credentials._info)
def do_policy_create(kc, args): """Create new user""" import json try: with open(args.policy,"r") as f: blob = json.load(f,object_hook=utils.convert) except IOError as e: print "I/O error({0}): {1}".format(e.errno, e.strerror) policy = kc.policies.create(json.dumps(blob), args.service_id,args.type) utils.print_dict(policy._info,100)
def do_tenant_create(kc, args): """Create new tenant""" domain_id = args.domain_id if not domain_id: domain = utils.find_resource(kc.domains, kc.project_domain_name) domain_id = domain.id tenant = kc.projects.create(args.name, domain_id, description=args.description, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(tenant._info)
def do_user_create(kc, args): """Create new user""" domain_id = args.domain_id if not domain_id: domain = utils.find_resource(kc.domains, kc.project_domain_name) domain_id = domain.id user = kc.users.create(name=args.name, password=args.passwd, email=args.email, project=args.tenant_id, domain=domain_id, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(user._info)
def do_tenant_create(kc, args): """Create new tenant""" domain_id = args.domain_id if not domain_id: domain = utils.find_resource(kc.domains, kc.project_domain_name) domain_id = domain.id tenant = kc.projects.create(args.name, domain_id, description=args.description, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(tenant._info)
def do_user_create(kc, args): """Create new user""" if args.tenant: tenant_id = utils.find_resource(kc.tenants, args.tenant).id elif args.tenant_id: tenant_id = args.tenant_id else: tenant_id = None user = kc.users.create(args.name, args.passwd, args.email, tenant_id=tenant_id, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(user._info)
def do_user_create(kc, args): """Create new user""" if args.tenant: tenant_id = utils.find_resource(kc.tenants, args.tenant).id elif args.tenant_id: tenant_id = args.tenant_id else: tenant_id = None user = kc.users.create(args.name, args.passwd, args.email, tenant_id=tenant_id, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(user._info)
def do_endpoint_get(kc, args): """Find endpoint filtered by a specific attribute or service type.""" kwargs = {"service_type": args.service, "endpoint_type": args.endpoint_type} if args.attr and args.value: kwargs.update({"attr": args.attr, "filter_value": args.value}) elif args.attr or args.value: print("Both --attr and --value required.") return url = kc.service_catalog.url_for(**kwargs) utils.print_dict({"%s.%s" % (args.service, args.endpoint_type): url})
def do_user_create(kc, args): """Create new user""" domain_id = args.domain_id if not domain_id: domain = utils.find_resource(kc.domains, kc.project_domain_name) domain_id = domain.id user = kc.users.create(name=args.name, password=args.passwd, email=args.email, project=args.tenant_id, domain=domain_id, enabled=utils.string_to_bool(args.enabled)) utils.print_dict(user._info)
def do_domain_update(kc, args): """Update a domain name, description or/and enabled status.""" kwargs = {} if args.name: kwargs['name'] = args.name if args.description: kwargs['description'] = args.description if args.enabled: kwargs['enabled'] = utils.string_to_bool(args.enabled) if not len(kwargs): print "Domain not updated, no arguments present." return domain = utils.find_resource(kc.domains, args.domain) updt_domain = kc.domains.update(domain=domain, **kwargs) utils.print_dict(updt_domain._info)
def do_domain_update(kc, args): """Update a domain name, description or/and enabled status.""" kwargs = {} if args.name: kwargs['name'] = args.name if args.description: kwargs['description'] = args.description if args.enabled: kwargs['enabled'] = utils.string_to_bool(args.enabled) if not len(kwargs): print "Domain not updated, no arguments present." return domain = utils.find_resource(kc.domains, args.domain) updt_domain = kc.domains.update(domain=domain, **kwargs) utils.print_dict(updt_domain._info)
def do_endpoint_get(kc, args): """Find endpoint filtered by a specific attribute or service type.""" kwargs = { 'service_type': args.service, 'endpoint_type': args.endpoint_type, } if args.attr and args.value: kwargs.update({'attr': args.attr, 'filter_value': args.value}) elif args.attr or args.value: print(_('Both --attr and --value required.')) return url = kc.service_catalog.url_for(**kwargs) utils.print_dict({'%s.%s' % (args.service, args.endpoint_type): url})
def do_endpoint_get(kc, args): """Find endpoint filtered by a specific attribute or service type.""" kwargs = { 'service_type': args.service, 'endpoint_type': args.endpoint_type, } if args.attr and args.value: kwargs.update({'attr': args.attr, 'filter_value': args.value}) elif args.attr or args.value: print('Both --attr and --value required.') return url = kc.service_catalog.url_for(**kwargs) utils.print_dict({'%s.%s' % (args.service, args.endpoint_type): url})
def do_user_create(kc, args): """Create new user.""" if args.tenant: tenant_id = utils.find_resource(kc.tenants, args.tenant).id elif args.tenant_id: tenant_id = args.tenant_id else: tenant_id = None new_passwd = args.passwd if args.passwd is ASK_FOR_PASSWORD: new_passwd = utils.prompt_for_password() user = kc.users.create(args.name, new_passwd, args.email, tenant_id=tenant_id, enabled=strutils.bool_from_string(args.enabled)) utils.print_dict(user._info)
def do_user_create(kc, args): """Create new user""" if args.tenant: tenant_id = utils.find_resource(kc.tenants, args.tenant).id elif args.tenant_id: tenant_id = args.tenant_id else: tenant_id = None new_passwd = args.passwd if args.passwd is ASK_FOR_PASSWORD: new_passwd = utils.prompt_for_password() user = kc.users.create(args.name, new_passwd, args.email, tenant_id=tenant_id, enabled=strutils.bool_from_string(args.enabled)) utils.print_dict(user._info)
def do_service_get(kc, args): """Display service from Service Catalog""" service = kc.services.get(args.id) utils.print_dict(service._info)
def do_token_get(kc, args): """Display the current user token.""" utils.print_dict(kc.service_catalog.get_token(), wrap=int(args.wrap))
def do_user_create(kc, args): """Create new user""" user = kc.users.create(args.name, args.passwd, args.email, tenant_id=args.tenant_id, enabled=args.enabled) utils.print_dict(user._info)
def do_role_get(kc, args): """Display role details""" role = kc.roles.get(args.id) utils.print_dict(role._info)
def do_role_create(kc, args): """Create new role.""" role = kc.roles.create(args.name) utils.print_dict(role._info)
def do_tenant_get(kc, args): """Display tenant details""" tenant = kc.tenants.get(args.id) utils.print_dict(tenant._info)
def do_service_get(kc, args): """Display service from Service Catalog.""" service = utils.find_resource(kc.services, args.service) utils.print_dict(service._info)
def do_service_get(kc, args): service = kc.services.get(args.id) utils.print_dict(service._info)
def do_tenant_get(kc, args): """Display tenant details.""" tenant = utils.find_resource(kc.tenants, args.tenant) utils.print_dict(tenant._info)
def do_service_create(kc, args): """Add service to Service Catalog.""" service = kc.services.create(args.name, args.type, args.description) utils.print_dict(service._info)
def do_tenant_create(kc, args): tenant = kc.tenants.create(args.tenant_name, description=args.description, enabled=args.enabled) utils.print_dict(tenant._info)
def do_user_get(kc, args): """Display user details.""" user = utils.find_resource(kc.users, args.user) utils.print_dict(user._info)
def do_token_get(kc, args): """Display the current user token.""" utils.print_dict(kc.service_catalog.get_token(), wrap=int(args.wrap))
def do_user_get(kc, args): """Display user details.""" user = utils.find_resource(kc.users, args.user) utils.print_dict(user._info)
def do_role_get(kc, args): """Display role details.""" role = utils.find_resource(kc.roles, args.role) utils.print_dict(role._info)
def do_role_create(kc, args): """Create new role.""" role = kc.roles.create(args.name) utils.print_dict(role._info)
def do_role_create(kc, args): role = kc.roles.create(args.role_name) utils.print_dict(role._info)
def do_service_create(kc, args): service = kc.services.create(args.service_name, args.service_type, args.description) utils.print_dict(service._info)
def do_tenant_get(kc, args): """Display tenant details.""" tenant = utils.find_resource(kc.tenants, args.tenant) utils.print_dict(tenant._info)
def do_role_get(kc, args): role = kc.roles.get(args.id) utils.print_dict(role._info)
def do_service_create(kc, args): """Add service to Service Catalog.""" service = kc.services.create(args.name, args.type, args.description) utils.print_dict(service._info)
def do_ec2_create_credentials(kc, args): credentials = kc.ec2.create(args.user_id, args.tenant_id) utils.print_dict(credentials._info)
def do_service_get(kc, args): """Display service from Service Catalog.""" service = utils.find_resource(kc.services, args.service) utils.print_dict(service._info)
def do_user_update_email(kc, args): user = kc.users.update_email(args.id, args.email) utils.print_dict(user._info)
def do_role_get(kc, args): """Display role details.""" role = utils.find_resource(kc.roles, args.role) utils.print_dict(role._info)