Ejemplo n.º 1
0
    def on_start_audit(self):
        """
        On service start audit
        Audit all subclouds that are out-of-sync
        """
        dc_role = utils.get_dc_role()
        if dc_role != constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
            # Do nothing if it is not systemcontroller
            return

        number_of_sc_to_audit = 0
        token = utils.get_token()
        subclouds = utils.get_subclouds_from_dcmanager(token)
        for sc in subclouds:
            if sc[utils.
                  ENDPOINT_TYPE_DC_CERT] == utils.SYNC_STATUS_OUT_OF_SYNC:
                self.subclouds_to_audit.append(sc['name'])
                LOG.info('%s is out-of-sync, adding it to audit.' % sc['name'])
                number_of_sc_to_audit = number_of_sc_to_audit + 1

        if number_of_sc_to_audit > 0:
            LOG.info('%d subcloud(s) found out-of-sync to be audited' %
                     number_of_sc_to_audit)
        else:
            LOG.info('All subclouds are in-sync. No startup audit is required')
Ejemplo n.º 2
0
    def start_monitor(self):
        utils.init_keystone_auth_opts()
        dc_role = utils.get_dc_role()
        while True:
            try:
                # init platformcert monitor
                self.init_platformcert_monitor()

                # init dc monitor only if running in DC role
                if (dc_role
                        == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER or
                        dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SUBCLOUD):
                    self.init_dc_monitor()
            except Exception as e:
                LOG.exception(e)
                time.sleep(5)
            else:
                break

        # spawn threads (DC thread spawned only if running in DC role)
        self.platcert_mon_thread = greenthread.spawn(
            self.platcert_monitor_cert)

        if (dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER
                or dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SUBCLOUD):
            self.dc_mon_thread = greenthread.spawn(self.dc_monitor_cert)
Ejemplo n.º 3
0
 def stop(self):
     dc_role = utils.get_dc_role()
     if dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
         self._stop_rpc_server()
         self.manager.stop_audit()
     self.manager.stop_monitor()
     super(CertificateMonitorService, self).stop()
     rpc_messaging.cleanup()
Ejemplo n.º 4
0
    def audit_sc_cert_start(self, context):
        # auditing subcloud certificate
        # this task runs every very long period of time, such as 24 hours
        dc_role = utils.get_dc_role()
        if dc_role != constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
            # Do nothing if it is not systemcontroller
            return

        self.subclouds_to_audit = utils.get_subclouds()[:]
Ejemplo n.º 5
0
    def start(self):
        super(CertificateMonitorService, self).start()
        self.manager.start_monitor()
        dc_role = utils.get_dc_role()
        if dc_role == constants.DISTRIBUTED_CLOUD_ROLE_SYSTEMCONTROLLER:
            self.manager.start_audit()
            self.target = oslo_messaging.Target(version=self.rpc_api_version,
                                                server=CONF.host,
                                                topic=self.topic)

            self._rpc_server = rpc_messaging.get_rpc_server(self.target, self)
            self._rpc_server.start()
Ejemplo n.º 6
0
 def initialize(self):
     self.dc_role = utils.get_dc_role()