예제 #1
0
 def waitForServerDeletion(self, server_id, timeout=600):
     for count in iterate_timeout(600, "server %s deletion in %s" %
                                  (server_id, self.provider.name)):
         try:
             self.getServerFromList(server_id)
         except NotFound:
             return
예제 #2
0
    def _waitForResource(self, resource_type, resource_id, timeout):
        last_status = None
        for count in iterate_timeout(
                timeout, "%s %s in %s" %
            (resource_type, resource_id, self.provider.name)):
            try:
                if resource_type == 'server':
                    resource = self.getServerFromList(resource_id)
                elif resource_type == 'image':
                    resource = self.getImage(resource_id)
            except NotFound:
                continue
            except ManagerStoppedException:
                raise
            except Exception:
                self.log.exception('Unable to list %ss while waiting for '
                                   '%s will retry' %
                                   (resource_type, resource_id))
                continue

            status = resource.get('status')
            if (last_status != status):
                self.log.debug(
                    'Status of {type} in {provider} {id}: {status}'.format(
                        type=resource_type,
                        provider=self.provider.name,
                        id=resource_id,
                        status=status))
            last_status = status
            if status in ['ACTIVE', 'ERROR']:
                return resource
예제 #3
0
    def _waitForResource(self, resource_type, resource_id, timeout):
        last_status = None
        for count in iterate_timeout(timeout,
                                     "%s %s in %s" % (resource_type,
                                                      resource_id,
                                                      self.provider.name)):
            try:
                if resource_type == 'server':
                    resource = self.getServerFromList(resource_id)
                elif resource_type == 'image':
                    resource = self.getImage(resource_id)
            except NotFound:
                continue
            except ManagerStoppedException:
                raise
            except Exception:
                self.log.exception('Unable to list %ss while waiting for '
                                   '%s will retry' % (resource_type,
                                                      resource_id))
                continue

            status = resource.get('status')
            if (last_status != status):
                self.log.debug(
                    'Status of {type} in {provider} {id}: {status}'.format(
                        type=resource_type,
                        provider=self.provider.name,
                        id=resource_id,
                        status=status))
            last_status = status
            if status in ['ACTIVE', 'ERROR']:
                return resource
예제 #4
0
    def waitForImage(self, image_id, timeout=3600):
        last_status = None
        for count in iterate_timeout(timeout, exceptions.ImageCreateException, "image creation"):
            try:
                image = self.getImage(image_id)
            except NotFound:
                continue
            except ManagerStoppedException:
                raise
            except Exception:
                self.log.exception("Unable to list images while waiting for " "%s will retry" % (image_id))
                continue

            # shade returns None when not found
            if not image:
                continue

            status = image["status"]
            if last_status != status:
                self.log.debug(
                    "Status of image in {provider} {id}: {status}".format(
                        provider=self.provider.name, id=image_id, status=status
                    )
                )
                if status == "ERROR" and "fault" in image:
                    self.log.debug(
                        "ERROR in {provider} on {id}: {resason}".format(
                            provider=self.provider.name, id=image_id, resason=image["fault"]["message"]
                        )
                    )
            last_status = status
            # Glance client returns lower case statuses - but let's be sure
            if status.lower() in ["active", "error"]:
                return image
예제 #5
0
 def waitForServerDeletion(self, server_id, timeout=600):
     for count in iterate_timeout(
             600,
             "server %s deletion in %s" % (server_id, self.provider.name)):
         try:
             self.getServerFromList(server_id)
         except NotFound:
             return
예제 #6
0
 def addPublicIP(self, server_id, pool=None):
     ip = self.createFloatingIP(pool)
     try:
         self.addFloatingIP(server_id, ip['ip'])
     except novaclient.exceptions.ClientException:
         # Delete the floating IP here as cleanupServer will not
         # have access to the ip -> server mapping preventing it
         # from removing this IP.
         self.deleteFloatingIP(ip['id'])
         raise
     for count in iterate_timeout(600, "ip to be added to %s in %s" %
                                  (server_id, self.provider.name)):
         try:
             newip = self.getFloatingIP(ip['id'])
         except ManagerStoppedException:
             raise
         except Exception:
             self.log.exception('Unable to get IP details for server %s, '
                                'will retry' % (server_id))
             continue
         if newip['instance_id'] == server_id:
             return newip['ip']
예제 #7
0
 def addPublicIP(self, server_id, pool=None):
     ip = self.createFloatingIP(pool)
     try:
         self.addFloatingIP(server_id, ip['ip'])
     except novaclient.exceptions.ClientException:
         # Delete the floating IP here as cleanupServer will not
         # have access to the ip -> server mapping preventing it
         # from removing this IP.
         self.deleteFloatingIP(ip['id'])
         raise
     for count in iterate_timeout(
             600, "ip to be added to %s in %s" %
         (server_id, self.provider.name)):
         try:
             newip = self.getFloatingIP(ip['id'])
         except ManagerStoppedException:
             raise
         except Exception:
             self.log.exception('Unable to get IP details for server %s, '
                                'will retry' % (server_id))
             continue
         if newip['instance_id'] == server_id:
             return newip['ip']
예제 #8
0
    def waitForImage(self, image_id, timeout=3600):
        last_status = None
        for count in iterate_timeout(timeout, exceptions.ImageCreateException,
                                     "image creation"):
            try:
                image = self.getImage(image_id)
            except NotFound:
                continue
            except ManagerStoppedException:
                raise
            except Exception:
                self.log.exception('Unable to list images while waiting for '
                                   '%s will retry' % (image_id))
                continue

            # shade returns None when not found
            if not image:
                continue

            status = image['status']
            if (last_status != status):
                self.log.debug(
                    'Status of image in {provider} {id}: {status}'.format(
                        provider=self.provider.name,
                        id=image_id,
                        status=status))
                if status == 'ERROR' and 'fault' in image:
                    self.log.debug(
                        'ERROR in {provider} on {id}: {resason}'.format(
                            provider=self.provider.name,
                            id=image_id,
                            resason=image['fault']['message']))
            last_status = status
            # Glance client returns lower case statuses - but let's be sure
            if status.lower() in ['active', 'error']:
                return image
예제 #9
0
    def waitForImage(self, image_id, timeout=3600):
        last_status = None
        for count in iterate_timeout(
                timeout, exceptions.ImageCreateException, "image creation"):
            try:
                image = self.getImage(image_id)
            except NotFound:
                continue
            except ManagerStoppedException:
                raise
            except Exception:
                self.log.exception('Unable to list images while waiting for '
                                   '%s will retry' % (image_id))
                continue

            # shade returns None when not found
            if not image:
                continue

            status = image['status']
            if (last_status != status):
                self.log.debug(
                    'Status of image in {provider} {id}: {status}'.format(
                        provider=self.provider.name,
                        id=image_id,
                        status=status))
                if status == 'ERROR' and 'fault' in image:
                    self.log.debug(
                        'ERROR in {provider} on {id}: {resason}'.format(
                            provider=self.provider.name,
                            id=image_id,
                            resason=image['fault']['message']))
            last_status = status
            # Glance client returns lower case statuses - but let's be sure
            if status.lower() in ['active', 'error']:
                return image
예제 #10
0
 def waitForServerDeletion(self, server_id, timeout=600):
     for count in iterate_timeout(timeout, exceptions.ServerDeleteException,
                                  "server %s deletion" % server_id):
         if not self.getServer(server_id):
             return
예제 #11
0
 def waitForServerDeletion(self, server_id, timeout=600):
     for count in iterate_timeout(
             timeout, exceptions.ServerDeleteException,
             "server %s deletion" % server_id):
         if not self.getServer(server_id):
             return