Пример #1
0
    def _prepare_cache(self, endpoint, params, cache):

        if 'network.statistics.opencontrail' in cache:
            return cache['network.statistics.opencontrail']

        data = {
            'o_client': client.Client(self.conf, endpoint),
            'n_client': neutron_client.Client(self.conf)
        }

        cache['network.statistics.opencontrail'] = data

        return data
Пример #2
0
    def _prepare_cache(endpoint, params, cache):

        if 'network.statistics.contrail' in cache:
            return cache['network.statistics.contrail']

        data = {
            'o_client': client.Client(endpoint),
            'n_client': neutron_client.Client(),
            'ks_client': keystone_client.get_client()
        }

        cache['network.statistics.contrail'] = data

        return data
Пример #3
0
 def get_samples(self, manager, cache, resources):
     self.neutron = neutron_client.Client().client
     for endpoint in resources:
         for ip in self._iter_floating_ips(cache, endpoint):
             yield sample.Sample(
                 name='ip.floating',
                 type=sample.TYPE_GAUGE,
                 unit='ip',
                 volume=1,
                 user_id=None,  # endpoint.user_id,
                 project_id=ip['tenant_id'],
                 resource_id=ip['id'],
                 timestamp=timeutils.utcnow().isoformat(),
                 resource_metadata={'address': ip['floating_ip_address']})
Пример #4
0
    def _prepare_cache(endpoint, params, cache):

        if 'network.statistics.opencontrail' in cache:
            return cache['network.statistics.opencontrail']

        data = {
            'o_client':
            client.Client(endpoint, params['username'], params['password'],
                          params.get('domain'),
                          params.get('verify_ssl') == 'true'),
            'n_client':
            neutron_client.Client()
        }

        cache['network.statistics.opencontrail'] = data

        return data
Пример #5
0
class BaseServicesPollster(plugin.PollsterBase):

    FIELDS = []
    nc = neutron_client.Client()

    def _iter_cache(self, cache, meter_name, method):
        if meter_name not in cache:
            cache[meter_name] = list(method())
        return iter(cache[meter_name])

    def extract_metadata(self, metric):
        return dict((k, metric[k]) for k in self.FIELDS)

    @staticmethod
    def get_status_id(value):
        status = value.lower()
        return STATUS.get(status, -1)
Пример #6
0
    def get_samples(self, manager, cache, resources):
        self.neutron = neutron_client.Client().client
        for server in resources:
            search_opts = {'device_id': server.id}
            ports = self.port_list(**search_opts)

            networks = self.list_resources_with_long_filters(
                self.network_list, 'id', set([port['network_id'] for port in ports]))

            # Map instance to its ports
            instances_ports = collections.defaultdict(list)
            for port in ports:
                instances_ports[port['device_id']].append(port)

            # Map network id to its name
            network_names = dict(((network['id'], network['name']) for network in networks))

            try:
                addresses = self._server_get_addresses(server, instances_ports, {}, network_names)
            except Exception as e:
                LOG.info("[FitterFixedIPPollster] Error: %s" % e)
            else:
                server.addresses = addresses

            for network_name, nets in server.addresses.items():
                for net in nets:
                    yield sample.Sample(
                            name='ip.fixed',
                            unit='ip',
                            type=sample.TYPE_GAUGE,
                            volume=1,
                            user_id=server.user_id,
                            project_id=server.tenant_id,
                            resource_id=net['port_id'],
                            timestamp=timeutils.utcnow().isoformat(),
                            resource_metadata={
                                'address': net['addr'],
                            }
                    )
Пример #7
0
 def setUp(self):
     super(TestNeutronClient, self).setUp()
     self.nc = neutron_client.Client()
Пример #8
0
 def __init__(self, conf):
     super(_LBStatsPollster, self).__init__(conf)
     self.client = neutron_client.Client(self.conf)
     self.lb_version = self.conf.service_types.neutron_lbaas_version
Пример #9
0
 def setUp(self):
     super(TestNeutronClientLBaaSV2, self).setUp()
     conf = service.prepare_service([], [])
     self.nc = neutron_client.Client(conf)
Пример #10
0
 def setUp(self):
     super(TestNeutronClient, self).setUp()
     self.CONF = service.prepare_service([], [])
     self.nc = neutron_client.Client(self.CONF)
     self.nc.lb_version = 'v1'
Пример #11
0
 def setUp(self):
     super(TestNeutronClient, self).setUp()
     conf = service.prepare_service([], [])
     self.CONF = self.useFixture(fixture_config.Config(conf)).conf
     self.nc = neutron_client.Client(self.CONF)
     self.nc.lb_version = 'v1'
Пример #12
0
 def __init__(self, conf):
     super(NetworkIPAvailabilityDiscovery, self).__init__(conf)
     conf.register_group(opt_group)
     conf.register_opts(OPTS, group=opt_group)
     self.neutron_cli = neutron_client.Client(conf).client
 def setUp(self):
     super(TestNeutronClientLBaaSV2, self).setUp()
     self.CONF = self.useFixture(fixture_config.Config()).conf
     self.nc = neutron_client.Client(self.CONF)
Пример #14
0
 def __init__(self):
     self.neutron_cli = neutron_client.Client()
 def setUp(self):
     super(TestNeutronClient, self).setUp()
     self.CONF = self.useFixture(fixture_config.Config()).conf
     self.nc = neutron_client.Client(self.CONF)
     self.nc.lb_version = 'v1'
Пример #16
0
 def __init__(self):
     super(_LBStatsPollster, self).__init__()
     self.client = neutron_client.Client()
Пример #17
0
 def __init__(self, conf):
     super(_BaseServicesDiscovery, self).__init__(conf)
     self.neutron_cli = neutron_client.Client(conf)
Пример #18
0
 def __init__(self):
     super(_LBStatsPollster, self).__init__()
     self.client = neutron_client.Client()
     self.lb_version = cfg.CONF.service_types.neutron_lbaas_version
Пример #19
0
 def setUp(self):
     super(TestNeutronClient, self).setUp()
     self.nc = neutron_client.Client()
     self.nc.lb_version = 'v1'