def get_dhcp_agent_host(config): try: neutronclient = openstack_driver.NeutronClient(config) keystoneclient = openstack_driver.KeystoneClient(config) token = keystoneclient.get_admin_token() filters = {'agent_type': 'DHCP agent', 'alive': True} agents = neutronclient.get_agents(token, filters) if agents: return agents[0].get('host', None) except Exception as exc: LOG.error(_LE("Failed to get dhcp agent host : %(exc)s"), {'exc': exc})
def __init__(self, config, supports_device_sharing=False, supports_hotplug=False, max_interfaces=8): self.service_vendor = 'general' self.supports_device_sharing = supports_device_sharing self.supports_hotplug = supports_hotplug self.maximum_interfaces = max_interfaces self.identity_handler = openstack_driver.KeystoneClient(config) self.compute_handler_nova = openstack_driver.NovaClient(config) self.network_handlers = { nfp_constants.GBP_MODE: nfp_gbp_network_driver.NFPGBPNetworkDriver(config), nfp_constants.NEUTRON_MODE: nfp_neutron_network_driver.NFPNeutronNetworkDriver(config) } self.config = config
def __init__(self, *args, **kwargs): super(TestKeystoneClient, self).__init__(*args, **kwargs) self.keystone_obj = openstack_driver.KeystoneClient(cfg.CONF)