Ejemplo n.º 1
0
    def download(self, logger=None):
        header_comment = ('# Editing the hosted engine VM is only possible via'
                          ' the manager UI\API\n'
                          '# This file was generated at {}\n'
                          '\n').format(time.asctime())
        print(header_comment)

        if self._logger:
            self._logger.debug(
                "Reloading vm.conf from the shared storage domain")

        content_from_ovf = self._get_vm_conf_content_from_ovf_store()
        if content_from_ovf:
            content = content_from_ovf
        else:
            self.legacy_vm_conf.download()
            content = self.legacy_vm_conf.raw()

        if content:
            content = "%s%s" % (header_comment, content)
            if self._publish_local_conf_file(content):
                mtime = monotonic.time()
                self.vm_conf_refresh_time = int(mtime)
                self.vm_conf_refresh_time_epoch = int(time.time() - mtime)
                self.load()
Ejemplo n.º 2
0
    def download(self, logger=None):
        header_comment = (
            '# Editing the hosted engine VM is only possible via'
            ' the manager UI\API\n'
            '# This file was generated at %s\n'
            '\n'
        ) % time.asctime()

        if self._logger:
            self._logger.debug(
                "Reloading vm.conf from the shared storage domain"
            )

        content_from_ovf = self._get_vm_conf_content_from_ovf_store()
        if content_from_ovf:
            content = content_from_ovf
        else:
            self.legacy_vm_conf.download()
            content = self.legacy_vm_conf.raw()

        if content:
            content = "%s%s" % (header_comment, content)
            if self._publish_local_conf_file(content):
                mtime = monotonic.time()
                self.vm_conf_refresh_time = int(mtime)
                self.vm_conf_refresh_time_epoch = int(time.time() - mtime)
                self.load()
Ejemplo n.º 3
0
    def action(self, options):
        # First, see if vdsm tells us it's up
        cli = util.connect_vdsm_json_rpc(logger=self._log)

        # Get timestamp before RPC call, so any future event with
        # status change will have a newer timestamp
        local_ts = monotonic.time()

        try:
            stats = cli.VM.getStats(vmID=self._vm_uuid)[0]
        except ServerError as e:
            if e.code == vdsm_exception.NoSuchVM.code:
                self._log.info("VM not on this host",
                               extra=log_filter.lf_args('status', 60))

                if self._vm_state == engine.VMState.UP:
                    self._vm_state = engine.VMState.DOWN_MISSING

                d = {
                    'vm': self._vm_state,
                    'health': engine.Health.BAD,
                    'detail': 'unknown',
                    'reason': 'vm not running on this host'
                }
            else:
                self._log.error(e)
                d = {
                    'vm': 'unknown',
                    'health': 'unknown',
                    'detail': 'unknown',
                    'reason': 'failed to getVmStats'
                }

            with self._lock:
                self._stats_local_timestamp = local_ts
                self._stats_vdsm_timestamp = None
                self.update_result(json.dumps(d))

            return

        # Convert timestamp to string in case it is an int
        vdsm_ts = str(stats.get("statusTime"))
        self._update_stats(stats, vdsm_ts, local_ts)
Ejemplo n.º 4
0
    def _handle_events(self):
        while True:
            ev = self._events_queue.get()
            if ev is None:
                break

            name, params = ev

            if ((self._event_name not in name)
                    or (str(self._vm_uuid) not in params)):
                continue

            self._log.debug("Received event. Name: %s, Params: %s", name,
                            params)

            # Convert timestamp to string in case it is an int
            vdsm_ts = str(params["notify_time"])

            local_ts = monotonic.time()
            stats = params[str(self._vm_uuid)]
            self._update_stats(stats, vdsm_ts, local_ts)
Ejemplo n.º 5
0
    def action(self, options):
        # First, see if vdsm tells us it's up
        cli = util.connect_vdsm_json_rpc(
            logger=self._log
        )

        # Get timestamp before RPC call, so any future event with
        # status change will have a newer timestamp
        local_ts = monotonic.time()

        try:
            stats = cli.VM.getStats(vmID=self._vm_uuid)[0]
        except ServerError as e:
            if e.code == vdsm_exception.NoSuchVM.code:
                self._log.info("VM not on this host",
                               extra=log_filter.lf_args('status', 60))

                if self._vm_state == engine.VMState.UP:
                    self._vm_state = engine.VMState.DOWN_MISSING

                d = {'vm': self._vm_state,
                     'health': engine.Health.BAD,
                     'detail': 'unknown',
                     'reason': 'vm not running on this host'}
            else:
                self._log.error(e)
                d = {'vm': 'unknown', 'health': 'unknown', 'detail': 'unknown',
                     'reason': 'failed to getVmStats'}

            with self._lock:
                self._stats_local_timestamp = local_ts
                self._stats_vdsm_timestamp = None
                self.update_result(json.dumps(d))

            return

        # Convert timestamp to string in case it is an int
        vdsm_ts = str(stats.get("statusTime"))
        self._update_stats(stats, vdsm_ts, local_ts)
Ejemplo n.º 6
0
    def _handle_events(self):
        while True:
            ev = self._events_queue.get()
            if ev is None:
                break

            name, params = ev

            if ((self._event_name not in name) or
                    (str(self._vm_uuid) not in params)):
                continue

            self._log.debug("Received event. Name: %s, Params: %s",
                            name,
                            params)

            # Convert timestamp to string in case it is an int
            vdsm_ts = str(params["notify_time"])

            local_ts = monotonic.time()
            stats = params[str(self._vm_uuid)]
            self._update_stats(stats, vdsm_ts, local_ts)