def get_neutron_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL'): """Create neutron client object. :param region: The region of the service :param service_name: The name of the neutron service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The endpoint_type of the service :return: a Neutron Client object. :raises Exception: if the client cannot be created """ if not cls.neutron_client: kwargs = {'region_name': region, 'session': keystone.get_session(), 'endpoint_type': endpoint_type} if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint_override'] = endpoint try: cls.neutron_client = neutron_client.Client( NEUTRON_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Neutron client.")) return cls.neutron_client
def get_neutron_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL'): """Create neutron client object. :param region: The region of the service :param service_name: The name of the neutron service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The endpoint_type of the service :return: a Neutron Client object. :raises Exception: if the client cannot be created """ if not cls.neutron_client: kwargs = { 'region_name': region, 'session': keystone.get_session(), 'endpoint_type': endpoint_type } if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint_override'] = endpoint try: cls.neutron_client = neutron_client.Client( NEUTRON_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Neutron client.")) return cls.neutron_client
def get_glance_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL'): """Create glance client object. :param region: The region of the service :param service_name: The name of the glance service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The endpoint_type of the service :return: a Glance Client object. :raises Exception: if the client cannot be created """ if not cls.glance_client: kwargs = {'region_name': region, 'session': keystone.get_session(), 'interface': endpoint_type} if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint'] = endpoint try: cls.glance_client = glance_client.Client( GLANCE_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Glance client.")) return cls.glance_client
def get_nova_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL', insecure=False, cacert=None): """Create nova client object. :param region: The region of the service :param service_name: The name of the nova service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The type of the endpoint :param insecure: Turn off certificate validation :param cacert: CA Cert file path :return: a Nova Client object. :raises Exception: if the client cannot be created """ if not cls.nova_client: kwargs = {'region_name': region, 'session': keystone.get_session(), 'endpoint_type': endpoint_type, 'insecure': insecure} if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint_override'] = endpoint if cacert: kwargs['cacert'] = cacert try: cls.nova_client = nova_client.Client( NOVA_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Nova client.")) return cls.nova_client
def get_glance_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL', insecure=False, cacert=None): """Create glance client object. :param region: The region of the service :param service_name: The name of the glance service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The endpoint_type of the service :param insecure: Turn off certificate validation :param cacert: CA Cert file path :return: a Glance Client object. :raises Exception: if the client cannot be created """ if not cls.glance_client: kwargs = {'region_name': region, 'session': keystone.get_session(), 'interface': endpoint_type} if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint'] = endpoint if endpoint.startswith("https"): kwargs['insecure'] = insecure kwargs['cacert'] = cacert try: cls.glance_client = glance_client.Client( GLANCE_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Glance client.")) return cls.glance_client
def get_barbican_client(cls, project_id=None): if not cls._barbican_client: try: cls._barbican_client = barbican_client.Client( session=keystone.get_session() ) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Barbican client")) return cls._barbican_client
def get_barbican_client(cls, project_id=None): if not cls._barbican_client: try: cls._barbican_client = barbican_client.Client( session=keystone.get_session(), region_name=CONF.certificates.region_name, interface=CONF.certificates.endpoint_type ) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Barbican client")) return cls._barbican_client
def get_barbican_client(cls): """Creates a Barbican client object. :return: a Barbican Client object :raises Exception: if the client cannot be created """ if not cls._barbican_client: try: cls._barbican_client = barbican_client.Client(session=keystone.get_session()) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Barbican client")) return cls._barbican_client
def setUp(self, mock_session): super(TestSshDriver, self).setUp() mock.MagicMock(keystone.get_session()) self.driver = ssh_driver.HaproxyManager() self.listener = sample_configs.sample_listener_tuple() self.vip = sample_configs.sample_vip_tuple() self.amphora = models.Amphora() self.amphora.id = self.FAKE_UUID_1 self.driver.cert_manager = mock.Mock(spec=cert_mgr.CertManager) self.driver.client = mock.Mock(spec=paramiko.SSHClient) self.driver.client.exec_command.return_value = (mock.Mock(), mock.Mock(), mock.Mock()) self.driver.amp_config = mock.MagicMock() self.port = network_models.Port(mac_address="123")
def get_barbican_client(cls): """Creates a Barbican client object. :return: a Barbican Client object :raises Exception: if the client cannot be created """ if not cls._barbican_client: try: cls._barbican_client = barbican_client.Client( session=keystone.get_session()) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Barbican client")) return cls._barbican_client
def setUp(self, mock_session): super(TestSshDriver, self).setUp() mock.MagicMock(keystone.get_session()) self.driver = ssh_driver.HaproxyManager() self.listener = sample_configs.sample_listener_tuple() self.vip = sample_configs.sample_vip_tuple() self.amphora = models.Amphora() self.amphora.id = self.FAKE_UUID_1 self.driver.cert_manager = mock.Mock( spec=cert_mgr.CertManager) self.driver.client = mock.Mock(spec=paramiko.SSHClient) self.driver.client.exec_command.return_value = ( mock.Mock(), mock.Mock(), mock.Mock()) self.driver.amp_config = mock.MagicMock() self.port = network_models.Port(mac_address='123')
def get_neutron_client(cls, region): """Create neutron client object. :param region: The region of the service :return: a Neutron Client object. :raises Exception: if the client cannot be created """ if not cls.neutron_client: try: cls.neutron_client = neutron_client.Client( NEUTRON_VERSION, session=keystone.get_session(), region_name=region) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Neutron client.")) return cls.neutron_client
def get_neutron_client(cls, region): """Create neutron client object. :param region: The region of the service :return: a Neutron Client object. :raises Exception: if the client cannot be created """ if not cls.neutron_client: try: cls.neutron_client = neutron_client.Client( NEUTRON_VERSION, session=keystone.get_session(), region_name=region ) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Neutron client.")) return cls.neutron_client
def get_glance_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL', insecure=False, cacert=None): """Create glance client object. :param region: The region of the service :param service_name: The name of the glance service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The endpoint_type of the service :param insecure: Turn off certificate validation :param cacert: CA Cert file path :return: a Glance Client object. :raises Exception: if the client cannot be created """ if not cls.glance_client: kwargs = { 'region_name': region, 'session': keystone.get_session(), 'interface': endpoint_type } if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint'] = endpoint if endpoint.startswith("https"): kwargs['insecure'] = insecure kwargs['cacert'] = cacert try: cls.glance_client = glance_client.Client( GLANCE_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Glance client.")) return cls.glance_client
def get_nova_client(cls, region, service_name=None, endpoint=None, endpoint_type='publicURL', insecure=False, cacert=None): """Create nova client object. :param region: The region of the service :param service_name: The name of the nova service in the catalog :param endpoint: The endpoint of the service :param endpoint_type: The type of the endpoint :param insecure: Turn off certificate validation :param cacert: CA Cert file path :return: a Nova Client object. :raises Exception: if the client cannot be created """ if not cls.nova_client: kwargs = { 'region_name': region, 'session': keystone.get_session(), 'endpoint_type': endpoint_type, 'insecure': insecure } if service_name: kwargs['service_name'] = service_name if endpoint: kwargs['endpoint_override'] = endpoint if cacert: kwargs['cacert'] = cacert try: cls.nova_client = nova_client.Client(NOVA_VERSION, **kwargs) except Exception: with excutils.save_and_reraise_exception(): LOG.exception(_LE("Error creating Nova client.")) return cls.nova_client