Esempio n. 1
0
    def _startStopVmAndGetVmInfo(self):
        """Return VM monitoring info and VM id."""

        self._startVm(noCheckImageUrl=True, raiseOnFailed=False)
        vmId = self.runner.vmIds[0]
        self._stopVm(self.runner)

        options = {}
        options["endpoint"] = getattr(self, "endpoint")
        options["username"] = getattr(self, "username", self.oneUsername)
        options["password"] = getattr(self, "password", self.proxyOneadminPassword)

        monitor = Monitor(ConfigHolder(options))
        info = monitor._vmDetail(vmId)

        return info, vmId
Esempio n. 2
0
        printInfo("Waiting %i sec for image bundling." % timeout)

        while time.time() < t_stop:
            if creator.getVmState() in ("Done", "Failed"):
                break
            printInfo("Time remaining: %d" % (t_stop - time.time()))
            time.sleep(t_step)

        # Assert instance state
        vm_state = creator.getVmState()
        if vm_state != "Done":
            self.configHolder.username = self.testUsername
            self.configHolder.password = self.testPassword
            self.configHolder.endpoint = self.endpoint
            monitor = Monitor(self.configHolder)
            info = monitor._vmDetail(creator.getVmId())
            info_attributes = info.getAttributes()
            msg = "Image creation failed. Instance final state '%s'. Error: %s" % (
                vm_state,
                info_attributes.get("template_error_message", "not set"),
            )
            self.fail(msg)

        # Assert new image.
        # Assuming we are running on FE and can access VM log file.
        vm_id = creator.getVmId()
        mp_and_id = ""
        for line in open("/var/log/one/%s.log" % vm_id).readlines():
            if re.search("MARKETPLACE_AND_IMAGEID", line):
                mp_and_id = line.split()
                break