コード例 #1
0
ファイル: server.py プロジェクト: open-craft/opencraft
    def update_status(self):
        """
        Refresh the status by querying the openstack server via nova
        """
        # TODO: Check when server is stopped or terminated

        # First check if it makes sense to update the current status.
        # This is not the case if we can not interact with the server:
        if self.status in (Status.BuildFailed, Status.Terminated):
            return self.status
        try:
            os_server = self.os_server
        except (requests.RequestException, novaclient.exceptions.ClientException):
            self.logger.debug("Could not reach the OpenStack API")
            if self.status not in (Status.BuildFailed, Status.Terminated, Status.Pending, Status.Unknown):
                self._status_to_unknown()
            return self.status
        self.logger.debug("Updating status from nova (currently %s):\n%s", self.status, to_json(os_server))

        if self.status == Status.Unknown:
            if os_server.status in ("INITIALIZED", "BUILDING"):
                # OpenStack has multiple API versions; INITIALIZED is current; BUILDING was used in the past
                self._status_to_building()

        if self.status in (Status.Building, Status.Unknown):
            self.logger.debug('OpenStack: loaded="%s" status="%s"', os_server._loaded, os_server.status)
            if os_server._loaded and os_server.status == "ACTIVE":
                self._status_to_booting()

        if self.status in (Status.Booting, Status.Unknown) and self.public_ip and is_port_open(self.public_ip, 22):
            self._status_to_ready()

        return self.status
コード例 #2
0
ファイル: server.py プロジェクト: omarkhan/opencraft
    def update_status(self, provisioning=False, rebooting=False, failed=None):
        """
        Refresh the status by querying the openstack server via nova
        """
        # TODO: Check when server is stopped or terminated
        os_server = self.os_server
        self.logger.debug('Updating status from nova (currently %s):\n%s', self.status, to_json(os_server))

        if self.status == self.STARTED:
            self.logger.debug('OpenStack: loaded="%s" status="%s"', os_server._loaded, os_server.status)
            if os_server._loaded and os_server.status == 'ACTIVE':
                self._set_status(self.ACTIVE, self.PROGRESS_SUCCESS)
            else:
                self._set_status(self.ACTIVE, self.PROGRESS_RUNNING)

        elif self.status == self.ACTIVE and self.public_ip and is_port_open(self.public_ip, 22):
            self._set_status(self.BOOTED, self.PROGRESS_RUNNING)

        elif self.status == self.BOOTED:
            if provisioning:
                self._set_status(self.PROVISIONING, self.PROGRESS_RUNNING)
            else:
                self._set_status(self.BOOTED, self.PROGRESS_SUCCESS)

        elif self.status == self.PROVISIONING and failed is not None:
            if failed:
                self._set_status(self.PROVISIONING, self.PROGRESS_FAILED)
            else:
                self._set_status(self.PROVISIONING, self.PROGRESS_SUCCESS)

        elif self.status in (self.PROVISIONING, self.READY) and rebooting:
            self._set_status(self.REBOOTING, self.PROGRESS_RUNNING)

        elif self.status == self.REBOOTING and not rebooting and is_port_open(self.public_ip, 22):
            self._set_status(self.READY, self.PROGRESS_SUCCESS)

        return self.status
コード例 #3
0
ファイル: server.py プロジェクト: sshyran/opencraft
 def _update_status_from_nova(self, os_server):
     """
     Update the status from the Nova Server object given in os_server.
     """
     self.logger.debug('Updating status from nova (currently %s):\n%s', self.status, to_json(os_server))
     if self.status == Status.Unknown:
         if os_server.status in ('INITIALIZED', 'BUILDING'):
             # OpenStack has multiple API versions; INITIALIZED is current; BUILDING was used in the past
             self._status_to_building()
     if self.status in (Status.Building, Status.Unknown):
         self.logger.debug('OpenStack: loaded="%s" status="%s"', os_server._loaded, os_server.status)
         if os_server._loaded and os_server.status == 'ACTIVE':
             self._status_to_booting()
     if self.status in (Status.Booting, Status.Unknown) and self.public_ip and is_port_open(self.public_ip, 22):
         self._status_to_ready()
コード例 #4
0
ファイル: server.py プロジェクト: taivo/opencraft
    def update_status(self):
        """
        Refresh the status by querying the openstack server via nova
        """
        # TODO: Check when server is stopped or terminated

        # First check if it makes sense to update the current status.
        # This is not the case if we can not interact with the server:
        if self.status == Status.BuildFailed:
            return self.status

        os_server = self.os_server
        self.logger.debug('Updating status from nova (currently %s):\n%s', self.status, to_json(os_server))

        if self.status == Status.Building:
            self.logger.debug('OpenStack: loaded="%s" status="%s"', os_server._loaded, os_server.status)
            if os_server._loaded and os_server.status == 'ACTIVE':
                self._status_to_booting()

        elif self.status == Status.Booting and self.public_ip and is_port_open(self.public_ip, 22):
            self._status_to_ready()

        return self.status