Пример #1
0
 def update_topology_state(self):
     #get stack details and set the topology state
     try:
         stack_details = self.heatclient.show(stack_id=self.topology.ext_id)
         LOG.debug('Stack details of %s: %s' % (self.topology.ext_name, stack_details))
         old_state = self.topology.state
         old_detailed_state = self.topology.detailed_state
         if stack_details:
             self.topology.state = translate(stack_details.get('stack_status'), HEAT_TO_EMM_STATE)
             self.topology.detailed_state = stack_details.get('stack_status_reason')
         if old_state != self.topology.state or old_detailed_state != self.topology.detailed_state:
             self.db.update(self.topology)
     except Exception, exc:
         LOG.exception(exc)
         self.topology.state='ERROR'
         raise
Пример #2
0
 def update_topology_state(self):
     #get stack details and set the topology state
     try:
         stack_details = self.heatclient.show(stack_id=self.topology.ext_id)
         LOG.debug('Stack details of %s: %s' %
                   (self.topology.ext_name, stack_details))
         old_state = self.topology.state
         old_detailed_state = self.topology.detailed_state
         if stack_details:
             self.topology.state = translate(
                 stack_details.get('stack_status'), HEAT_TO_EMM_STATE)
             self.topology.detailed_state = stack_details.get(
                 'stack_status_reason')
         if old_state != self.topology.state or old_detailed_state != self.topology.detailed_state:
             self.db.update(self.topology)
     except Exception, exc:
         LOG.exception(exc)
         self.topology.state = 'ERROR'
         raise
Пример #3
0
        #Update only when the state is changed
        if old_state != service_instance.state:
            self.db.update(service_instance)

    def update_unit_state(self, unit, resource_details=None):
        if not resource_details:
            try:
                resource_details = self.heatclient.list_resources(self.topology.ext_id)
                LOG.debug('Resource details of %s: %s' % (self.topology.ext_name, resource_details))
            except HTTPNotFound, exc:
                self.topology.state='DELETED'
                return
            except Exception, exc:
                LOG.exception(exc)
                self.topology.state='ERROR'
        for vm in resource_details:
            if vm.get('resource_type') == "OS::Nova::Server":
                if vm.get('resource_name') == unit.hostname:
                    unit.ext_id = vm['physical_resource_id']
                    heat_state = vm.get('resource_status')
                    if heat_state:
                        _new_state = translate(heat_state, HEAT_TO_EMM_STATE)
                        LOG.debug("State of unit %s: translate from %s to %s" % (unit.hostname, heat_state, _new_state))
                        if _new_state != unit.state:
                            unit.state = _new_state
                            self.db.update(unit)
                    else:
                        LOG.warning("State of unit %s: %s" % (unit.hostname, vm.get('resource_status')))
                        raise Exception
Пример #4
0
    def update_unit_state(self, unit, resource_details=None):
        if not resource_details:
            try:
                resource_details = self.heatclient.list_resources(
                    self.topology.ext_id)
                LOG.debug('Resource details of %s: %s' %
                          (self.topology.ext_name, resource_details))
            except HTTPNotFound, exc:
                self.topology.state = 'DELETED'
                return
            except Exception, exc:
                LOG.exception(exc)
                self.topology.state = 'ERROR'
        for vm in resource_details:
            if vm.get('resource_type') == "OS::Nova::Server":
                if vm.get('resource_name') == unit.hostname:
                    unit.ext_id = vm['physical_resource_id']
                    heat_state = vm.get('resource_status')
                    if heat_state:
                        _new_state = translate(heat_state, HEAT_TO_EMM_STATE)
                        LOG.debug("State of unit %s: translate from %s to %s" %
                                  (unit.hostname, heat_state, _new_state))
                        if _new_state != unit.state:
                            unit.state = _new_state
                            self.db.update(unit)
                    else:
                        LOG.warning("State of unit %s: %s" %
                                    (unit.hostname, vm.get('resource_status')))
                        raise Exception