当前位置: 首页>>代码示例>>Python>>正文


Python MachineState._check方法代码示例

本文整理汇总了Python中nixops.backends.MachineState._check方法的典型用法代码示例。如果您正苦于以下问题:Python MachineState._check方法的具体用法?Python MachineState._check怎么用?Python MachineState._check使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nixops.backends.MachineState的用法示例。


在下文中一共展示了MachineState._check方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
    def _check(self, res):
        try:
            node = self.node()
            res.exists = True
            res.is_up = node.state == NodeState.RUNNING or node.state == NodeState.REBOOTING
            if node.state == NodeState.REBOOTING or node.state == NodeState.PENDING: self.state = self.STARTING
            if node.state == NodeState.STOPPED or node.state == NodeState.TERMINATED: self.state = self.STOPPED
            if node.state == NodeState.UNKNOWN: self.state = self.UNKNOWN
            if node.state == NodeState.RUNNING:
                # check that all disks are attached
                res.disks_ok = True
                for k, v in self.block_device_mapping.iteritems():
                    disk_name = v['disk_name'] or v['disk']
                    if all(d.get("deviceName", None) != disk_name for d in node.extra['disks']):
                        res.disks_ok = False
                        res.messages.append("disk {0} is detached".format(disk_name))
                        try:
                            disk = self.connect().ex_get_volume(disk_name, v.get('region', None))
                        except libcloud.common.google.ResourceNotFoundError:
                            res.messages.append("disk {0} is destroyed".format(disk_name))
                self.handle_changed_property('public_ipv4',
                                              node.public_ips[0] if node.public_ips else None,
                                              property_name = 'IP address')
                if self.public_ipv4:
                    known_hosts.add(self.public_ipv4, self.public_host_key)

                MachineState._check(self, res)

        except libcloud.common.google.ResourceNotFoundError:
            res.exists = False
            res.is_up = False
            self.state = self.MISSING;
开发者ID:andrewlmurray,项目名称:nixops,代码行数:34,代码来源:gce.py

示例2: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
    def _check(self, res):
        if not self.vm_id:
            res.exists = False
            return

        if self.state in (self.STOPPED, self.STOPPING):
            res.is_up = ping_tcp_port(self.main_ipv4, 22)
            if not res.is_up:
                self.state = self.STOPPED
                res.is_reachable = False
                return

        res.exists = True
        avg = self.get_load_avg()
        if avg is None:
            if self.state in (self.UP, self.RESCUE):
                self.state = self.UNREACHABLE
            res.is_reachable = False
            res.is_up = False
        elif self.run_command("test -f /etc/NIXOS", check=False) != 0:
            self.state = self.RESCUE
            self.ssh_pinged = True
            self._ssh_pinged_this_time = True
            res.is_reachable = True
            res.is_up = False
        else:
            res.is_up = True
            MachineState._check(self, res)
开发者ID:pombredanne,项目名称:nixops,代码行数:30,代码来源:hetzner.py

示例3: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
    def _check(self, res):
        if not self.vm_id:
            res.exists = False
            return
        state = self._get_vm_state(can_fail=True)
        if state is None:
            with self.depl._db:
                self.vm_id = None
                self.private_ipv4 = None
                self.sata_controller_created = False
                self.public_host_key = None
                self.private_host_key = None
                self.shared_folders = {}
                self.disks = {}
                self.state = self.MISSING
                return

        res.exists = True
        #self.log("VM state is ‘{0}’".format(state))
        if state == "poweroff" or state == "aborted":
            res.is_up = False
            self.state = self.STOPPED
        elif state == "running":
            res.is_up = True
            self._update_ip()
            MachineState._check(self, res)
        else:
            self.state = self.UNKNOWN
开发者ID:NixOS,项目名称:nixops,代码行数:30,代码来源:virtualbox.py

示例4: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
    def _check(self, res):
        if not self.vm_id:
            res.exists = False
            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
            return

        res.exists = True
        if instance.state == "pending":
            res.is_up = False
            self.state = self.STARTING

        elif instance.state == "running":
            res.is_up = True

            res.disks_ok = True
            for k, v in self.block_device_mapping.items():
                if k not in instance.block_device_mapping.keys() and v.get('volumeId', None):
                    res.disks_ok = False
                    res.messages.append("volume ‘{0}’ not attached to ‘{1}’".format(v['volumeId'], _sd_to_xvd(k)))
                    volume = self._get_volume_by_id(v['volumeId'], allow_missing=True)
                    if not volume:
                        res.messages.append("volume ‘{0}’ no longer exists".format(v['volumeId']))

                if k in instance.block_device_mapping.keys() and instance.block_device_mapping[k].status != 'attached' :
                    res.disks_ok = False
                    res.messages.append("volume ‘{0}’ on device ‘{1}’ has unexpected state: ‘{2}’".format(v['volumeId'], _sd_to_xvd(k), instance.block_device_mapping[k].status))


            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 ‘nixops deploy’")
                self.private_ipv4 = instance.private_ip_address
                self.public_ipv4 = instance.ip_address

            MachineState._check(self, res)

        elif instance.state == "stopping":
            res.is_up = False
            self.state = self.STOPPING

        elif instance.state == "stopped":
            res.is_up = False
            self.state = self.STOPPED

        # check for scheduled events
        instance_status = self._conn.get_all_instance_status(instance_ids=[instance.id])
        for ist in instance_status:
            if ist.events:
                for e in ist.events:
                    res.messages.append("Event ‘{0}’:".format(e.code))
                    res.messages.append("  * {0}".format(e.description))
                    res.messages.append("  * {0} - {1}".format(e.not_before, e.not_after))
开发者ID:wizeman,项目名称:nixops,代码行数:61,代码来源:ec2.py

示例5: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
 def _check(self, res):
     if not self.vm_id:
         res.exists = False
         return
     res.exists = True
     res.is_up = nixops.util.ping_tcp_port(self.target_host, self.ssh_port)
     if res.is_up:
         MachineState._check(self, res)
开发者ID:Acidburn0zzz,项目名称:nixops,代码行数:10,代码来源:none.py

示例6: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
 def _check(self, res):
     if not self.vm_id:
         res.exists = False
         return
     state = self._get_vm_state()
     res.exists = True
     #self.log("VM state is ‘{0}’".format(state))
     if state == "poweroff" or state == "aborted":
         res.is_up = False
         self.state = self.STOPPED
     elif state == "running":
         res.is_up = True
         self._update_ip()
         MachineState._check(self, res)
     else:
         self.state = self.UNKNOWN
开发者ID:MostAwesomeDude,项目名称:nixops,代码行数:18,代码来源:virtualbox.py

示例7: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
    def _check(self, res):
        if not self.vm_id:
            res.exists = False
            return

        status = self.host_ssh.run_command("nixos-container status {0}".format(self.vm_id), capture_stdout=True).rstrip()

        if status == "gone":
            res.exists = False
            self.state = self.MISSING
            return

        res.exists = True

        if status == "down":
            res.is_up = False
            self.state = self.STOPPED
            return

        res.is_up = True
        MachineState._check(self, res)
开发者ID:coreyoconnor,项目名称:nixops,代码行数:23,代码来源:container.py

示例8: _check

# 需要导入模块: from nixops.backends import MachineState [as 别名]
# 或者: from nixops.backends.MachineState import _check [as 别名]
 def _check(self, res):
     res.exists = True # can't really check
     res.is_up = nixops.util.ping_tcp_port(self.target_host, self.ssh_port)
     if res.is_up:
         MachineState._check(self, res)
开发者ID:mbbx6spp,项目名称:nixops,代码行数:7,代码来源:none.py


注:本文中的nixops.backends.MachineState._check方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。