Exemplo n.º 1
0
 def instance_pull(self, req=None, instancePull=None):
     progress = Progress(req)
     with lock(self._image_pull_lock(instancePull)):
         result = self._do_instance_pull(instancePull, progress)
     if result is None:
         result = {}
     else:
         result = {
             'fields': {
                 'dockerImage': result,
             },
         }
     return self._reply(req, result)
Exemplo n.º 2
0
 def instance_pull(self, req=None, instancePull=None):
     progress = Progress(req)
     with lock(self._image_pull_lock(instancePull)):
         result = self._do_instance_pull(instancePull, progress)
     if result is None:
         result = {}
     else:
         result = {
             'fields': {
                 'dockerImage': result,
             },
         }
     return self._reply(req, result)
Exemplo n.º 3
0
    def volume_remove(self, req=None, volumeStoragePoolMap=None, **kw):
        volume = volumeStoragePoolMap.volume
        storage_pool = volumeStoragePoolMap.storagePool
        progress = Progress(req)

        with lock(volume):
            if volume.deviceNumber == 0:
                get_compute().purge_state(docker_client(), volume.instance)

            if not self._is_volume_removed(volume, storage_pool):
                self._do_volume_remove(volume, storage_pool, progress)

            data = self._get_response_data(req, volumeStoragePoolMap)
            return self._reply(req, data)
Exemplo n.º 4
0
    def volume_remove(self, req=None, volumeStoragePoolMap=None, **kw):
        volume = volumeStoragePoolMap.volume
        storage_pool = volumeStoragePoolMap.storagePool
        progress = Progress(req)

        with lock(volume):
            if volume.deviceNumber == 0:
                get_compute().purge_state(docker_client(), volume.instance)

            if not self._is_volume_removed(volume, storage_pool):
                self._do_volume_remove(volume, storage_pool, progress)

            data = self._get_response_data(req, volumeStoragePoolMap)
            return self._reply(req, data)
Exemplo n.º 5
0
    def _do(self, req=None, check=None, result=None, lock_obj=None,
            action=None, post_check=True):
        if check():
            return self._reply(req, result())

        with lock(lock_obj):
            if check():
                return self._reply(req, result())

            action()

            data = result()

            if post_check and not check():
                raise Exception("Operation failed")

            return self._reply(req, data)
Exemplo n.º 6
0
    def instance_activate(self, req=None, instanceHostMap=None, processData=None, **kw):
        instance, host = BaseComputeDriver.get_instance_host_from_map(self, instanceHostMap)

        progress = Progress(req)
        client = self._get_docker_client(host)
        if instance is not None:
            instance.processData = processData

        with lock(instance):
            if self._is_instance_active(instance, host):
                self._record_state(client, instance)
                return self._reply(req, self._get_response_data(req, instanceHostMap))

            self._do_instance_activate(instance, host, progress)

            data = self._get_response_data(req, instanceHostMap)

            return self._reply(req, data)
Exemplo n.º 7
0
    def _do(self,
            req=None,
            check=None,
            result=None,
            lock_obj=None,
            action=None):
        if check():
            return self._reply(req, result())

        with lock(lock_obj):
            if check():
                return self._reply(req, result())

            action()

            data = result()

            if not check():
                raise Exception("Operation failed")

            return self._reply(req, data)
Exemplo n.º 8
0
    def instance_activate(self,
                          req=None,
                          instanceHostMap=None,
                          processData=None,
                          **kw):
        instance, host = \
            BaseComputeDriver.get_instance_host_from_map(self, instanceHostMap)

        progress = Progress(req)
        client = docker_client()
        if instance is not None:
            instance.processData = processData

        with lock(instance):
            if self._is_instance_active(instance, host):
                self._record_state(client, instance)
                return self._reply(
                    req, self._get_response_data(req, instanceHostMap))

            self._do_instance_activate(instance, host, progress)

            data = self._get_response_data(req, instanceHostMap)

            return self._reply(req, data)