def run(self, parsed_args): self.client = Client(region_name=self.app.options.os_region_name, service_type=self.app.options.os_service_type, session=self.app.session, all_tenants=self.app.options.all_tenants, edit_managed=self.app.options.edit_managed) try: return super(Command, self).run(parsed_args) except exceptions.RemoteError as e: columns = ['Code', 'Type'] values = [e.code, e.type] if e.message: columns.append('Message') values.append(e.message) if e.errors: columns.append('Errors') values.append(e.errors) self.error_output(parsed_args, columns, values) except ks_exceptions.EndpointNotFound as e: self.app.log.error('No endpoint was found. You must provide a' 'username or user id via --os-username, ' '--os-user-id, env[OS_USERNAME] or ' 'env[OS_USER_ID]') return 1
def create_designate_client(): """Creates a Designate DNSaaS client.""" client = Client(auth_url=DNS_AUTH_URL, username=DNS_USERNAME, password=DNS_PASSKEY, tenant_id=DNS_TENANT_ID, endpoint=DNS_ENDPOINT_URL, service_type=DNS_SERVICE_TYPE, region_name=DNS_REGION) return client
def designateclient(request): designate_url = "" try: designate_url = url_for(request, 'dns') except exceptions.ServiceCatalogException: LOG.debug('no dns service configured.') return None insecure = getattr(settings, 'OPENSTACK_SSL_NO_VERIFY', False) cacert = getattr(settings, 'OPENSTACK_SSL_CACERT', None) return Client(endpoint=designate_url, token=request.user.token.id, username=request.user.username, tenant_id=request.user.project_id, insecure=insecure, cacert=cacert)
def run(self, parsed_args): warnings.simplefilter('once', category=DeprecationWarning) warnings.warn( 'The "designate" CLI is being deprecated in favour of the ' '"openstack" CLI plugin. All designate API v2 commands are ' 'implemented there. When the v1 API is removed this CLI will ' 'stop functioning', DeprecationWarning) warnings.resetwarnings() warnings.simplefilter('ignore', category=DeprecationWarning) self.client = Client(region_name=self.app.options.os_region_name, service_type=self.app.options.os_service_type, endpoint_type=self.app.options.os_endpoint_type, session=self.app.session, all_tenants=self.app.options.all_tenants, edit_managed=self.app.options.edit_managed, endpoint=self.app.options.os_endpoint) warnings.resetwarnings() try: return super(Command, self).run(parsed_args) except exceptions.RemoteError as e: columns = ['Code', 'Type'] values = [e.code, e.type] if e.message: columns.append('Message') values.append(e.message) if e.errors: columns.append('Errors') values.append(e.errors) self.error_output(parsed_args, columns, values) except ks_exceptions.EndpointNotFound as e: self.app.log.error('No endpoint was found. You must provide a ' 'username or user id via --os-username, ' '--os-user-id, env[OS_USERNAME] or ' 'env[OS_USER_ID]. You may also be using a ' 'cloud that does not have the V1 API enabled. ' 'If your cloud does not have the V1 DNS API ' 'use the openstack CLI to interact with the ' 'DNS Service.') return 1
def run(self, parsed_args): kwargs = { 'endpoint': self.app.options.os_endpoint, 'username': self.app.options.os_username, 'user_id': self.app.options.os_user_id, 'user_domain_id': self.app.options.os_user_domain_id, 'user_domain_name': self.app.options.os_user_domain_name, 'password': self.app.options.os_password, 'tenant_name': self.app.options.os_tenant_name, 'tenant_id': self.app.options.os_tenant_id, 'domain_name': self.app.options.os_domain_name, 'domain_id': self.app.options.os_domain_id, 'project_name': self.app.options.os_project_name, 'project_id': self.app.options.os_project_id, 'project_domain_name': self.app.options.os_project_domain_name, 'project_domain_id': self.app.options.os_project_domain_id, 'auth_url': self.app.options.os_auth_url, 'token': self.app.options.os_token, 'endpoint_type': self.app.options.os_endpoint_type, 'service_type': self.app.options.os_service_type, 'insecure': self.app.options.insecure, } self.client = Client(**kwargs) try: return super(Command, self).run(parsed_args) except exceptions.RemoteError as e: columns = ['Code', 'Type'] values = [e.code, e.type] if e.message: columns.append('Message') values.append(e.message) if e.errors: columns.append('Errors') values.append(e.errors) self.error_output(parsed_args, columns, values) return 1