def initialize_vnc_api(auth_token, api_server_host, vnc_api_init_params): if auth_token is not None: vnc_api = VncApi(auth_token=auth_token) elif vnc_api_init_params is not None: vnc_api = VncApi( vnc_api_init_params.get("admin_user"), vnc_api_init_params.get("admin_password"), vnc_api_init_params.get("admin_tenant_name"), api_server_host, vnc_api_init_params.get("api_server_port"), api_server_use_ssl=vnc_api_init_params.get("api_server_use_ssl")) else: vnc_api = VncApi() return vnc_api
def vnc_api(self): e = SystemError('Cant connect to API server') api_servers = [srv.split(':')[0] for srv in self._args.api_server_list] api_server_port = self._args.api_server_list[0].split(':')[1] \ if self._args.api_server_list else None try: vnc = VncApi(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, api_servers, api_server_port, api_server_use_ssl=self._args.api_server_use_ssl, auth_host=self._args.auth_host, auth_port=self._args.auth_port, auth_protocol=self._args.auth_protocol) except Exception as e: ConnectionState.update(conn_type=ConnectionType.APISERVER, name='Config', status=ConnectionStatus.DOWN, message=str(e), server_addrs=api_servers) return None else: ConnectionState.update(conn_type=ConnectionType.APISERVER, name='Config', status=ConnectionStatus.UP, server_addrs=api_servers) return vnc
def remove_stale_pr_objects(cls, job_ctx): """ Clean up stale temporary PR objects when ZTP workflow fails. """ filters = {} try: vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) except Exception as ex: logging.error("Error connecting to API server: {}".format(ex)) return True # A case was noticed where the object deletion is attempted # before it is even created. To avoid this, wait for a # couple of seconds before trying to delete the PR time.sleep(2) filters['physical_router_managed_state'] = "dhcp" pr_list = vnc_api.physical_routers_list( filters=filters).get('physical-routers') for pr in pr_list: vnc_api.physical_router_delete(id=pr['uuid']) logging.info("Router {} in dhcp state deleted".format( pr['fq_name'][-1])) return True
def get_vnc(usr, passwd, tenant, api_servers, use_ssl=False, auth_host=None, auth_port=None, auth_protocol=None, notifycb=None): e = IOError('Api servers (%s) not reachable' % ','.join(api_servers)) api_server_list = [srv.split(':')[0] for srv in api_servers] api_server_port = api_servers[0].split(':')[1] if api_servers else None try: vnc = VncApi(usr, passwd, tenant, api_server_list, api_server_port, api_server_use_ssl=use_ssl, auth_host=auth_host, auth_port=auth_port, auth_protocol=auth_protocol) except Exception as e: if callable(notifycb): notifycb('api', str(e), servers=api_servers, up=False) else: if callable(notifycb): notifycb('api', 'Connected', servers=api_servers) return vnc return None
def read_dhcp_leases(cls, ipam_subnets, file_name, fabric_name, job_ctx, payload_key, payload_value, action='create'): vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token'), timeout=600) headers = { 'fabric_name': fabric_name, 'file_name': file_name, 'action': action } payload = {'ipam_subnets': ipam_subnets} payload[payload_key] = payload_value return vnc_api.amqp_request(exchange=cls.ZTP_EXCHANGE, exchange_type=cls.ZTP_EXCHANGE_TYPE, routing_key=cls.ZTP_REQUEST_ROUTING_KEY, response_key=cls.ZTP_RESPONSE_ROUTING_KEY + fabric_name, headers=headers, payload=payload)
def _connect_to_api_server(self): self._active_api_server = None self._api_client = None while not self._active_api_server: for api_server in self._api_servers: try: self._api_client = VncApi( self._keystone_info['admin_user'], self._keystone_info['admin_password'], self._keystone_info['admin_tenant_name'], api_server[0], api_server[1], auth_host=self._keystone_info['auth_host'], auth_protocol=self._keystone_info['auth_protocol'], auth_port=self._keystone_info['auth_port']) except Exception as e: self._logger( 'Failed to connect to contrail-api ' 'server: %s' % (str(e)), SandeshLevel.SYS_ERR) self._update_apiserver_connection_status( '%s:%s' % (api_server[0], api_server[1]), ConnectionStatus.DOWN, str(e)) else: self._active_api_server = api_server self._update_apiserver_connection_status( '%s:%s' % (api_server[0], api_server[1]), ConnectionStatus.UP) # TODO: Handle error from sync_config self._sync_config() break if not self._active_api_server: gevent.sleep(2) self._api_client_connection_task = None
def api(self): if hasattr(self, '_api'): return self._api # Retry till a api-server is up connected = False while not connected: try: self._api = VncApi(self.admin_user, self.admin_password, self.admin_tenant_name, self.api_srvr_ip, self.api_srvr_port, self.api_server_url, auth_host=self.auth_host, auth_port=self.auth_port, auth_protocol=self.auth_protocol, auth_url=self.auth_url, auth_type=self.auth_type, wait_for_connect=True, api_server_use_ssl=self.api_srvr_use_ssl, auth_token_url=self.auth_token_url) connected = True except requests.exceptions.RequestException: time.sleep(3) return self._api
def _initialize_vnc(): controller_nodes = os.environ.get('CONTROLLER_NODES', None).split(',') # keystone global env data user = os.environ.get('KEYSTONE_AUTH_ADMIN_USER', None) passwd = os.environ.get('KEYSTONE_AUTH_ADMIN_PASSWORD', None) tenant = os.environ.get('KEYSTONE_AUTH_ADMIN_TENANT', None) if user and passwd and tenant: vnc_api = VncApi(username=user, password=passwd, tenant_name=tenant, api_server_host=controller_nodes) else: vnc_api = VncApi() return vnc_api
def vnc_api(self, notifycb=None): e = SystemError('Cant connect to API server') for rt in (5, 2, 7, 9, 16, 25): for api_server in self.api_svrs(): srv = api_server.split(':') if len(srv) == 2: ip, port = srv[0], int(srv[1]) else: ip, port = '127.0.0.1', int(srv[0]) try: vnc = VncApi(self._args.admin_user, self._args.admin_password, self._args.admin_tenant_name, auth_host=self._args.auth_host, auth_port=self._args.auth_port, auth_protocol=self._args.auth_protocol) if callable(notifycb): notifycb('api', 'Connected', servers=api_server) return vnc except Exception as e: traceback.print_exc() if callable(notifycb): notifycb('api', 'Not connected', servers=api_server, up=False) time.sleep(rt) raise e
def get_vnc(usr, passwd, tenant, api_servers, auth_host=None, auth_port=None, auth_protocol=None, notifycb=None): e = IOError('Api servers (%s) not reachable' % ','.join(api_servers)) while True: for api_server in api_servers: srv = api_server.split(':') try: vnc = VncApi(usr, passwd, tenant, srv[0], srv[1], auth_host=auth_host, auth_port=auth_port, auth_protocol=auth_protocol) if callable(notifycb): notifycb('api', 'Connected', servers=api_server) return vnc except Exception as e: traceback.print_exc() if callable(notifycb): notifycb('api', 'Not connected', servers=api_server, up=False) time.sleep(3)
def _get_vnc_api(api_config): return VncApi(api_server_host=api_config.get('api_server_host'), api_server_port=api_config.get('api_server_port'), username=api_config.get('username'), password=api_config.get('password'), tenant_name=api_config.get('tenant_name'), api_server_use_ssl=api_config.get('api_server_use_ssl'))
def _get_vnc_api(ips, port, username, password, tenant, use_ssl): return VncApi(api_server_host=random.choice(ips), api_server_port=port, username=username, password=password, tenant_name=tenant, api_server_use_ssl=use_ssl)
def __init__(self): admin_user = cfg.CONF.keystone_authtoken.admin_user admin_password = cfg.CONF.keystone_authtoken.admin_password admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name api_srvr_ip = cfg.CONF.APISERVER.api_server_ip api_srvr_port = cfg.CONF.APISERVER.api_server_port api_srvr_use_ssl= cfg.CONF.APISERVER.use_ssl try: auth_host = cfg.CONF.keystone_authtoken.auth_host except cfg.NoSuchOptError: auth_host = "127.0.0.1" try: auth_protocol = cfg.CONF.keystone_authtoken.auth_protocol except cfg.NoSuchOptError: auth_protocol = "http" try: auth_port = cfg.CONF.keystone_authtoken.auth_port except cfg.NoSuchOptError: auth_port = "35357" try: auth_url = cfg.CONF.keystone_authtoken.auth_url except cfg.NoSuchOptError: auth_url = "/v2.0/tokens" try: auth_type = cfg.CONF.keystone_authtoken.auth_type except cfg.NoSuchOptError: auth_type = "keystone" try: api_server_url = cfg.CONF.APISERVER.api_server_url except cfg.NoSuchOptError: api_server_url = "/" # Retry till a api-server is up connected = False while not connected: try: self._api = VncApi(admin_user, admin_password, admin_tenant_name, api_srvr_ip, api_srvr_port, api_server_url, auth_host=auth_host, auth_port=auth_port, auth_protocol=auth_protocol, auth_url=auth_url, auth_type=auth_type, wait_for_connect=True, api_server_use_ssl=api_srvr_use_ssl) connected = True except requests.exceptions.RequestException: time.sleep(3) self._pool_manager = \ loadbalancer_pool.LoadbalancerPoolManager(self._api) self._vip_manager = virtual_ip.VirtualIpManager(self._api) self._member_manager = \ loadbalancer_member.LoadbalancerMemberManager(self._api) self._monitor_manager = \ loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager( self._api)
def get_handle(self): api_handle = VncApi(username=self.args.admin_user, password=self.args.admin_password, tenant_name=self.tenant_name, api_server_host='127.0.0.1', api_server_port=utils.get_api_listen_port()) return api_handle
def get_vnc(usr, passwd, tenant, ip, port): for rt in (5, 2, 7, 9, 16, 25): try: return VncApi(usr, passwd, tenant, ip, port) except Exception as e: traceback.print_exc() time.sleep(rt) raise e
def get_ztp_dhcp_config(cls, job_ctx, fabric_uuid): dhcp_config = {} try: vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) fabric = vncapi.fabric_read(id=fabric_uuid) fabric_dict = vncapi.obj_to_dict(fabric) # From here we get the 'management' type virtual network vn_uuid = None virtual_network_refs = fabric_dict.get( 'virtual_network_refs') or [] for virtual_net_ref in virtual_network_refs: if 'management' in virtual_net_ref['attr']['network_type']: vn_uuid = virtual_net_ref['uuid'] break if vn_uuid is None: raise NoIdError("Cannot find mgmt virtual network on fabric") virtual_net = vncapi.virtual_network_read(id=vn_uuid) virtual_net_dict = vncapi.obj_to_dict(virtual_net) # Get the IPAM attached to the virtual network ipam_refs = virtual_net_dict.get('network_ipam_refs') if ipam_refs: ipam_ref = ipam_refs[0] ipam = vncapi.network_ipam_read(id=ipam_ref['uuid']) ipam_dict = vncapi.obj_to_dict(ipam) ipam_subnets = ipam_dict.get('ipam_subnets') if ipam_subnets: dhcp_config['ipam_subnets'] = ipam_subnets.get('subnets') # To support multiple subnet and interface for DHCP, each dhcp # option is tagged with interface name. eg. # dhcp-option=set:eth0, <ip-range start> <ip-range end>. for subnet in dhcp_config['ipam_subnets']: intf_ip, intf_name = cls.get_host_ip_and_name(subnet) if intf_ip and intf_name: subnet.update({'intf_ip':intf_ip}) subnet.update({'intf_name':intf_name}) # Get static ip configuration for physical routers pr_refs = fabric.get_physical_router_back_refs() pr_uuids = [ref['uuid'] for ref in pr_refs] static_ips = {} for pr_uuid in pr_uuids: pr = vncapi.physical_router_read(id=pr_uuid) pr_dict = vncapi.obj_to_dict(pr) mac = pr_dict.get('physical_router_management_mac') ip = pr_dict.get('physical_router_management_ip') if mac and ip: static_ips[ip] = mac if static_ips: dhcp_config['static_ips'] = static_ips except Exception as ex: logging.error( "Error getting ZTP DHCP configuration: {}".format(ex)) return dhcp_config
def run_schema_transformer(st_logger, args): global _vnc_lib st_logger.notice("Elected master Schema Transformer node. Initializing...") st_logger.introspect_init() def connection_state_update(status, message=None): ConnectionState.update(conn_type=ConnType.APISERVER, name='ApiServer', status=status, message=message or 'ApiServer', server_addrs=[ '%s:%s' % (args.api_server_ip, args.api_server_port) ]) # end connection_state_update # Retry till API server is up connected = False connection_state_update(ConnectionStatus.INIT) api_server_list = args.api_server_ip.split(',') while not connected: try: _vnc_lib = VncApi(args.admin_user, args.admin_password, args.admin_tenant_name, api_server_list, args.api_server_port, api_server_use_ssl=args.api_server_use_ssl) connected = True connection_state_update(ConnectionStatus.UP) except requests.exceptions.ConnectionError as e: # Update connection info connection_state_update(ConnectionStatus.DOWN, str(e)) time.sleep(3) except (RuntimeError, ResourceExhaustionError): # auth failure or haproxy throws 503 time.sleep(3) global transformer transformer = SchemaTransformer(st_logger, args) transformer._conf_file = args.conf_file transformer._chksum = "" # checksum of collector list if args.collectors: transformer._chksum = hashlib.md5("".join(args.collectors)).hexdigest() """ @sighup SIGHUP handler to indicate configuration changes """ gevent.signal(signal.SIGHUP, transformer.sighup_handler) try: gevent.joinall(transformer._vnc_amqp._vnc_kombu.greenlets()) except KeyboardInterrupt: SchemaTransformer.destroy_instance() raise
def vnc_init(job_ctx): host = random.choice(job_ctx.get('api_server_host')) if job_ctx.get('auth_token') is not None: vnc_api = VncApi(api_server_host=host, auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) elif job_ctx.get('vnc_api_init_params') is not None: params = job_ctx.get('vnc_api_init_params') vnc_api = VncApi( params.get('admin_user'), params.get('admin_password'), params.get('admin_tenant_name'), host, params.get('api_server_port'), api_server_use_ssl=params.get('api_server_use_ssl')) else: vnc_api = VncApi() return vnc_api
def vnc_init(job_ctx): # randomize list for load balancing, pass list for HA api_server_ip_list = random.shuffle(job_ctx.get('api_server_host')) if job_ctx.get('auth_token') is not None: vnc_api = VncApi(api_server_host=api_server_ip_list, auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) elif job_ctx.get('vnc_api_init_params') is not None: params = job_ctx.get('vnc_api_init_params') vnc_api = VncApi( params.get('admin_user'), params.get('admin_password'), params.get('admin_tenant_name'), api_server_ip_list, params.get('api_server_port'), api_server_use_ssl=params.get('api_server_use_ssl')) else: vnc_api = VncApi() return vnc_api
def __init__(self, user, passwd, project_name, inputs, domain='default-domain'): self.inputs = inputs self.user = user self.passwd = passwd self.domain = domain self.project_name = project_name self.vnc = VncApi(username=user, password=passwd, tenant_name=project_name, api_server_host=self.inputs.cfgm_ip, api_server_port=self.inputs.api_server_port)
def __init__(self): # TODO: parse configuration for api-server:port and auth self._api = VncApi() self._pool_manager = \ loadbalancer_pool.LoadbalancerPoolManager(self._api) self._vip_manager = virtual_ip.VirtualIpManager(self._api) self._member_manager = \ loadbalancer_member.LoadbalancerMemberManager(self._api) self._monitor_manager = \ loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager( self._api)
def get_pr_subnet(cls, job_ctx, fabric_uuid, device_fq_name): api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) fabric = api.fabric_read(id=fabric_uuid) fabric_dict = api.obj_to_dict(fabric) vn_uuid = None virtual_network_refs = fabric_dict.get('virtual_network_refs') or [] for virtual_net_ref in virtual_network_refs: if 'management' in virtual_net_ref['attr']['network_type']: vn_uuid = virtual_net_ref['uuid'] break if vn_uuid is None: raise NoIdError("Cannot find mgmt virtual network on fabric") virtual_net = api.virtual_network_read(id=vn_uuid) virtual_net_dict = api.obj_to_dict(virtual_net) subnets = None ipam_refs = virtual_net_dict.get('network_ipam_refs') if ipam_refs: ipam_ref = ipam_refs[0] ipam = api.network_ipam_read(id=ipam_ref['uuid']) ipam_dict = api.obj_to_dict(ipam) ipam_subnets = ipam_dict.get('ipam_subnets') if ipam_subnets: subnets = ipam_subnets.get('subnets') gateway = None cidr = None if subnets: pr = api.physical_router_read(fq_name=device_fq_name) pr_dict = api.obj_to_dict(pr) ip = pr_dict.get('physical_router_management_ip') ip_addr = IPAddress(ip) for subnet in subnets: inner_subnet = subnet.get('subnet') cidr = inner_subnet.get('ip_prefix') + '/' + str( inner_subnet.get('ip_prefix_len')) if ip_addr in IPNetwork(cidr) and subnet.get( 'default_gateway'): gateway = subnet.get('default_gateway') subnet = cls._get_subnet_from_host_ip(cidr) break if cidr and gateway and subnet: return { 'cidr': cidr, 'gateway': gateway, 'intf_subnet': str(subnet) } raise NoIdError("Cannot find cidr and gateway for device: %s" % str(device_fq_name))
def restart_dhcp_server(cls, file_name, fabric_name, job_ctx): vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) headers = { 'fabric_name': fabric_name, 'file_name': file_name, 'action': 'delete' } vnc_api.amqp_publish(exchange=cls.ZTP_EXCHANGE, exchange_type=cls.ZTP_EXCHANGE_TYPE, routing_key=cls.ZTP_REQUEST_ROUTING_KEY, headers=headers, payload={}) return { 'status': 'success' }
def read_dhcp_leases(cls, ipam_subnets, file_name, fabric_name, job_ctx, payload_key, payload_value, action='create'): vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) timeout = job_ctx.get('job_input', {}).get('ztp_timeout', 0) # get the ztp_timeout from config properties if not defined in ztp.yml if timeout == 0: config_props = vnc_api.config_properties_read( fq_name=['default-global-system-config', 'config_property']) props_list = config_props.properties.key_value_pair for props in props_list or []: if props.key == 'ztp_timeout': timeout = int(props.value) vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token'), timeout=timeout + cls.VNC_API_REQUEST_BUFFER_TIME) headers = { 'fabric_name': fabric_name, 'file_name': file_name, 'action': action } payload = {'ipam_subnets': ipam_subnets, 'ztp_timeout': timeout} payload[payload_key] = payload_value amqp_timeout = timeout + cls.AMQP_BUFFER_TIME return vnc_api.amqp_request(exchange=cls.ZTP_EXCHANGE, exchange_type=cls.ZTP_EXCHANGE_TYPE, routing_key=cls.ZTP_REQUEST_ROUTING_KEY, response_key=cls.ZTP_RESPONSE_ROUTING_KEY + fabric_name, headers=headers, payload=payload, amqp_timeout=amqp_timeout)
def _publish_file(cls, name, contents, action, routing_key, fabric_name, job_ctx): vnc_api = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) headers = { 'fabric_name': fabric_name, 'file_name': name, 'action': action } vnc_api.amqp_publish(exchange=cls.ZTP_EXCHANGE, exchange_type=cls.ZTP_EXCHANGE_TYPE, routing_key=routing_key, headers=headers, payload=contents) return {'status': 'success'}
def get_ztp_dhcp_config(cls, job_ctx, fabric_uuid): dhcp_config = {} try: vncapi = VncApi(auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=job_ctx.get('auth_token')) fabric = vncapi.fabric_read(id=fabric_uuid) fabric_dict = vncapi.obj_to_dict(fabric) # From here we get the 'management' type virtual network vn_uuid = None virtual_network_refs = fabric_dict.get( 'virtual_network_refs') or [] for virtual_net_ref in virtual_network_refs: if 'management' in virtual_net_ref['attr']['network_type']: vn_uuid = virtual_net_ref['uuid'] break if vn_uuid is None: raise NoIdError("Cannot find mgmt virtual network on fabric") virtual_net = vncapi.virtual_network_read(id=vn_uuid) virtual_net_dict = vncapi.obj_to_dict(virtual_net) # Get the IPAM attached to the virtual network ipam_refs = virtual_net_dict.get('network_ipam_refs') if ipam_refs: ipam_ref = ipam_refs[0] ipam = vncapi.network_ipam_read(id=ipam_ref['uuid']) ipam_dict = vncapi.obj_to_dict(ipam) ipam_subnets = ipam_dict.get('ipam_subnets') if ipam_subnets: dhcp_config['ipam_subnets'] = ipam_subnets.get('subnets') # Get static ip configuration for physical routers pr_refs = fabric.get_physical_router_back_refs() pr_uuids = [ref['uuid'] for ref in pr_refs] static_ips = {} for pr_uuid in pr_uuids: pr = vncapi.physical_router_read(id=pr_uuid) pr_dict = vncapi.obj_to_dict(pr) mac = pr_dict.get('physical_router_management_mac') ip = pr_dict.get('physical_router_management_ip') if mac and ip: static_ips[ip] = mac if static_ips: dhcp_config['static_ips'] = static_ips except Exception as ex: logging.error( "Error getting ZTP DHCP configuration: {}".format(ex)) return dhcp_config
def __init__(self, username, password, tenant_name, api_server_host, api_server_port, auth_host, auth_port, auth_protocol, auth_url, auth_type, **kwargs): self.vnc_lib = VncApi(username=username, password=password, tenant_name=tenant_name, api_server_host=api_server_host, api_server_port=api_server_port, auth_host=auth_host, auth_port=auth_port, auth_protocol=auth_protocol, auth_url=auth_url, auth_type=auth_type, **kwargs)
def __init__(self): admin_user = cfg.CONF.keystone_authtoken.admin_user admin_password = cfg.CONF.keystone_authtoken.admin_password admin_tenant_name = cfg.CONF.keystone_authtoken.admin_tenant_name api_srvr_ip = cfg.CONF.APISERVER.api_server_ip api_srvr_port = cfg.CONF.APISERVER.api_server_port self._api = VncApi(admin_user, admin_password, admin_tenant_name, api_srvr_ip, api_srvr_port) self._pool_manager = \ loadbalancer_pool.LoadbalancerPoolManager(self._api) self._vip_manager = virtual_ip.VirtualIpManager(self._api) self._member_manager = \ loadbalancer_member.LoadbalancerMemberManager(self._api) self._monitor_manager = \ loadbalancer_healthmonitor.LoadbalancerHealthmonitorManager( self._api)
def __init__(self, cfg, name): if cfg is None: raise KeyError("Missing required args: cfg") if name is None: raise KeyError("Missing required args: name") self._name = name self._timeout = cfg['wait_for_job']['timeout'] self._max_retries = cfg['wait_for_job']['max_retries'] self._logger = SanityBase._init_logging(cfg['log'], name) self._api_server = cfg['api_server'] self._analytics = cfg['analytics'] self._api = VncApi(api_server_host=self._api_server['host'], api_server_port=self._api_server['port'], username=self._api_server['username'], password=self._api_server['password'], tenant_name=self._api_server['tenant'])
def _init_vnc_lib(self): # Instantiate the VNC library # Retry for sometime, till API server is up errmsg = None for i in range(0, 10): try: self.vnc_lib = VncApi( auth_type=VncApi._KEYSTONE_AUTHN_STRATEGY, auth_token=self.job_ctx.get('auth_token')) break except Exception as ex: time.sleep(10) errmsg = "Failed to connect to API server due to error: %s"\ % str(ex) if self.vnc_lib is None: raise RuntimeError(errmsg)