Exemplo n.º 1
0
    def stop(self):
        """Stop the actor and release acquired resources
        """
        for dom_id, dom_actor in six.iteritems(self.migration_monitors):
            dom_actor.stop()
            log.debug("Destroy DomJobMonitorActor for domain with id %s",
                      dom_id)

        self.db_actor.stop()
        for conn in self.connections:
            log.debug("Closing " + conn.getURI())
            conn.close()
Exemplo n.º 2
0
def _create_vcenter_connection():
    context = ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE

    log.debug("Connecting to vCenter %s",
              migrationmonitor.settings.VCENTER["HOST"])

    connection = vcenter_connect.SmartConnect(
        host=migrationmonitor.settings.VCENTER["HOST"],
        user=migrationmonitor.settings.VCENTER["USERNAME"],
        pwd=migrationmonitor.settings.VCENTER["PASSWORD"],
        sslContext=context)

    return connection
Exemplo n.º 3
0
def _create_vcenter_connection():
    context = ssl.create_default_context()
    context.check_hostname = False
    context.verify_mode = ssl.CERT_NONE

    log.debug(
        "Connecting to vCenter %s",
        migrationmonitor.settings.VCENTER["HOST"])

    connection = vcenter_connect.SmartConnect(
        host=migrationmonitor.settings.VCENTER["HOST"],
        user=migrationmonitor.settings.VCENTER["USERNAME"],
        pwd=migrationmonitor.settings.VCENTER["PASSWORD"],
        sslContext=context)

    return connection
Exemplo n.º 4
0
    def _on_receive(self, msg):
        _, dom_id = msg
        try:
            dom = self.conn.lookupByID(self.dom_id)
            job_info = dom.jobStats()
            log.debug("jobStats: {0}".format(job_info))
            self.db_actor.tell(({"domain_id": self.dom_id,
                                 "domain_name": dom.name()},
                                job_info,
                                self.settings.INFLUXDB["JOBINFO_MEASUREMENT"]))

            time.sleep(self.settings.LIBVIRT["POLL_FREQ"])
            self.tell(("continue", dom_id))

        except libvirt.libvirtError:
            self.stop()
            log.debug("Destroy DomJobMonitorActor for domain with id %s",
                      self.dom_id)
            del self.migration_monitors[self.dom_id]
Exemplo n.º 5
0
    def _on_receive(self, msg):
        _, dom_id = msg
        try:
            dom = self.conn.lookupByID(self.dom_id)
            job_info = dom.jobStats()
            log.debug("jobStats: {0}".format(job_info))
            self.db_actor.tell(({"domain_id": self.dom_id,
                                 "domain_name": dom.name()},
                                job_info,
                                self.settings.INFLUXDB["JOBINFO_MEASUREMENT"]))

            time.sleep(self.settings.LIBVIRT["POLL_FREQ"])
            self.tell(("continue", dom_id))

        except libvirt.libvirtError:
            self.stop()
            log.debug("Destroy DomJobMonitorActor for domain with id %s",
                      self.dom_id)
            del self.migration_monitors[self.dom_id]
Exemplo n.º 6
0
    def _on_receive(self, item):
        events = self._fetch_vcenter_events()
        log.debug("Got %s events from vCenter.", len(events))

        for event in events:
            event_id = event.key
            if event_id not in self.reported_event_ids:
                self.reported_event_ids.append(event_id)
                tags = {"vm_name": event.vm.name,
                        "vm_id": event.vm.vm}

                values = {"value": 1}
                self.db_actor.tell((
                    tags,
                    values,
                    self.settings.INFLUXDB["EVENTS_MEASUREMENT"],
                    event.createdTime))

                log.info("Reported %s event to influxdb.", event_id)
                log.debug("%s %s %s",
                          event.createdTime,
                          type(event).__name__,
                          event)
            else:
                log.debug("Event: %s already reported.", event_id)

        time.sleep(self.settings.VCENTER["POLL_FREQ"])
        self.tell("continue")
Exemplo n.º 7
0
    def _on_receive(self, item):
        events = self._fetch_vcenter_events()
        log.debug("Got %s events from vCenter.", len(events))

        for event in events:
            event_id = event.key
            if event_id not in self.reported_event_ids:
                self.reported_event_ids.append(event_id)
                tags = {"vm_name": event.vm.name, "vm_id": event.vm.vm}

                values = {"value": 1}
                self.db_actor.tell(
                    (tags, values,
                     self.settings.INFLUXDB["EVENTS_MEASUREMENT"],
                     event.createdTime))

                log.info("Reported %s event to influxdb.", event_id)
                log.debug("%s %s %s", event.createdTime,
                          type(event).__name__, event)
            else:
                log.debug("Event: %s already reported.", event_id)

        time.sleep(self.settings.VCENTER["POLL_FREQ"])
        self.tell("continue")
Exemplo n.º 8
0
 def _reconnect(self, conn):
     uri = conn.getURI()
     log.debug("Reconnection %s" % (uri, ))
     self.connections.remove(conn)
     self._start(uri)