Ejemplo n.º 1
0
    def monitorstatusmessage(self, req):

        context = req.environ['nova.context']
        statusdict = {
            'nova': '0',
            'glance': '0',
            'cinder': '0',
            'neutron': '0',
            'keystone': '0',
            'mysql': '0',
            'rabbitmq': '0'
        }

        for (key, value) in statusdict.items():
            try:
                if key == 'cinder':
                    self.cinder_api.get_all(context)
                elif key == 'glance':
                    glance.get_default_image_service()
                elif key == 'nova':
                    self.aggregate_api.get_aggregate_list(context)
                elif key == 'neutron':
                    self.network_api.get_all(context)
                elif key == 'db':
                    dbapi.service_get_all(context)
                elif key == 'rabbitmq' or key == 'keystone':
                    api_version_request.min_api_version()
            except Exception, e:
                statusdict[key] = '1'
Ejemplo n.º 2
0
 def get_all(cls, context, disabled=None, set_zones=False):
     db_services = db.service_get_all(context, disabled=disabled)
     if set_zones:
         db_services = availability_zones.set_availability_zones(
             context, db_services)
     return base.obj_make_list(context, cls(context), objects.Service,
                               db_services)
Ejemplo n.º 3
0
 def test_set_availability_zone_not_compute_service(self):
     """Test not compute service get right availability zone."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     new_service = az.set_availability_zones(self.context, services)[0]
     self.assertEqual(self.default_in_az, new_service['availability_zone'])
     self._destroy_service(service)
 def test_set_availability_zone_not_compute_service(self):
     """Test not compute service get right availability zone."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     new_service = az.set_availability_zones(self.context, services)[0]
     self.assertEqual(self.default_in_az, new_service['availability_zone'])
     self._destroy_service(service)
Ejemplo n.º 5
0
 def _find_all_resources(self, context, resource_class,
                         filters=None, transaction=None):
     """Factory implementation to query all resources matching the filter"""
     hosts = list()
     services = db_api.service_get_all(context)
     #Since the topic/host filter excludes disabled, filter ourselves
     services = [svc for svc in services if svc['topic'] == 'compute']
     #If they asked to filter on Host Name, then we need something special
     if filters is not None and filters.get('host_name') is not None:
         host_name = filters['host_name']
         services = [svc for svc in services if svc['host'] == host_name]
     #Now add in all the attributes for the given Compute Service
     for service in services:
         host = dict(host_name=service['host'],
                     registered_at=service['created_at'])
         #Populate extra properties from the DB Table and CONF file
         self._populate_from_compute_node(context, host, service['id'])
         self._populate_from_conf_file(context, host, service['host'])
         #Retrieve the list of HMC UUID's from the Database Table
         hmcfact = ManagementConsoleFactory.get_factory()
         hmcs = hmcfact.find_all_hmcs_by_host(context, service['host'])
         host['hmc_uuids'] = [hmc['hmc_uuid'] for hmc in hmcs]
         hosts.append(host)
     #Convert the Compute Node instances to the given DOM Resource instance
     return self._construct_resources(
         resource_class, context, hosts, transaction)
Ejemplo n.º 6
0
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     az.set_availability_zones(self.context, services)
     self.assertIsInstance(services[0]['host'], six.text_type)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertIsInstance(cached_key, str)
     self._destroy_service(service)
 def test_set_availability_zone_unicode_key(self):
     """Test set availability zone cache key is unicode."""
     service = self._create_service_with_topic('network', self.host)
     services = db.service_get_all(self.context)
     az.set_availability_zones(self.context, services)
     self.assertIsInstance(services[0]['host'], six.text_type)
     cached_key = az._make_cache_key(services[0]['host'])
     self.assertIsInstance(cached_key, str)
     self._destroy_service(service)
Ejemplo n.º 8
0
    def test_set_availability_zone_compute_service(self):
        """Test for compute service get right availability zone."""
        service = self._create_service_with_topic('compute', self.host)
        services = db.service_get_all(self.context)

        # The service is not add into aggregate, so confirm it is default
        # availability zone.
        new_service = az.set_availability_zones(self.context, services)[0]
        self.assertEqual(self.default_az, new_service['availability_zone'])

        # The service is added into aggregate, confirm return the aggregate
        # availability zone.
        self._add_to_aggregate(service, self.agg)
        new_service = az.set_availability_zones(self.context, services)[0]
        self.assertEqual(self.availability_zone,
                         new_service['availability_zone'])

        self._destroy_service(service)
    def test_set_availability_zone_compute_service(self):
        """Test for compute service get right availability zone."""
        service = self._create_service_with_topic('compute', self.host)
        services = db.service_get_all(self.context)

        # The service is not add into aggregate, so confirm it is default
        # availability zone.
        new_service = az.set_availability_zones(self.context, services)[0]
        self.assertEqual(self.default_az, new_service['availability_zone'])

        # The service is added into aggregate, confirm return the aggregate
        # availability zone.
        self._add_to_aggregate(service, self.agg)
        new_service = az.set_availability_zones(self.context, services)[0]
        self.assertEqual(self.availability_zone,
                         new_service['availability_zone'])

        self._destroy_service(service)