def check(self): if not self.vm_id: return state = self._get_vm_state() self.log("VM state is ‘{0}’".format(state)) if state == "poweroff" or state == "aborted": self.state = self.STOPPED elif state == "running": self._update_ip() MachineState.check(self) else: self.state = self.UNKNOWN
def check(self): if not self.vm_id: return self.connect() instance = self._get_instance_by_id(self.vm_id, allow_missing=True) old_state = self.state self.log("instance state is ‘{0}’".format(instance.state if instance else "gone")) if instance is None or instance.state in {"shutting-down", "terminated"}: self.state = self.MISSING elif instance.state == "pending": self.state = self.STARTING elif instance.state == "running": if self.private_ipv4 != instance.private_ip_address or self.public_ipv4 != instance.ip_address: self.warn("IP address has changed, you may need to run ‘charon deploy’") self.private_ipv4 = instance.private_ip_address self.public_ipv4 = instance.ip_address MachineState.check(self) elif instance.state == "stopping": self.state = self.STOPPING elif instance.state == "stopped": self.state = self.STOPPED