Beispiel #1
0
    def create_volume(self, size, name, location=None, snapshot=None):
        """
        Creates a new storage volume with the given size.  The 'name'
        corresponds to the volume tag.  The visibility of the created
        volume is 'private'.

        The snapshot parameter is currently ignored.

        The created StorageVolume contains a dict for the extra
        information with a 'location' key storing the location used
        for the volume.  This is set to 'default' if no location has
        been given.

        @inherits: L{NodeDriver.create_volume}
        """
        configHolder = self._get_config_section(location)

        pdisk = PersistentDisk(configHolder)

        # Creates a private disk.  Boolean flag = False means private.
        vol_uuid = pdisk.createVolume(size, name, False)

        extra = {'location': location}

        return StorageVolume(vol_uuid, name, size, self, extra=extra)
    def create_volume(self, size, name, location=None, snapshot=None):
        """
        Creates a new storage volume with the given size.  The 'name'
        corresponds to the volume tag.  The visibility of the created
        volume is 'private'.

        The snapshot parameter is currently ignored.

        The created StorageVolume contains a dict for the extra
        information with a 'location' key storing the location used
        for the volume.  This is set to 'default' if no location has
        been given.

        @inherits: L{NodeDriver.create_volume}
        """
        configHolder = self._get_config_section(location)

        pdisk = PersistentDisk(configHolder)

        # Creates a private disk.  Boolean flag = False means private.
        vol_uuid = pdisk.createVolume(size, name, False)

        extra = {'location': location}

        return StorageVolume(vol_uuid, name, size, self, extra=extra)
    def destroy_volume(self, volume):
        """
        Destroys the given volume.

        @inherits: L{NodeDriver.destroy_volume}
        """

        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        pdisk.deleteVolume(volume.id)

        return True
Beispiel #4
0
    def destroy_volume(self, volume):
        """
        Destroys the given volume.

        @inherits: L{NodeDriver.destroy_volume}
        """

        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        pdisk.deleteVolume(volume.id)

        return True
    def detach_volume(self, volume):

        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        try:
            node = volume.extra['node']
        except (AttributeError, KeyError):
            raise Exception('volume is not attached to a node')

        pdisk.hotDetach(node.id, volume.id)

        del(volume.extra['node'])

        return True
Beispiel #6
0
    def detach_volume(self, volume):

        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        try:
            node = volume.extra['node']
        except (AttributeError, KeyError):
            raise Exception('volume is not attached to a node')

        pdisk.hotDetach(node.id, volume.id)

        del (volume.extra['node'])

        return True
    def attach_volume(self, node, volume, device=None):
        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        try:
            host = node.host
        except AttributeError:
            raise Exception('node does not contain host information')

        pdisk.hotAttach(host, node.id, volume.id)

        try:
            volume.extra['node'] = node
        except AttributeError:
            volume.extra = {'node': node}

        return True
Beispiel #8
0
    def attach_volume(self, node, volume, device=None):
        location = self._volume_location(volume)

        configHolder = self._get_config_section(location)
        pdisk = PersistentDisk(configHolder)

        try:
            host = node.host
        except AttributeError:
            raise Exception('node does not contain host information')

        pdisk.hotAttach(host, node.id, volume.id)

        try:
            volume.extra['node'] = node
        except AttributeError:
            volume.extra = {'node': node}

        return True
    def list_volumes(self, location=None):
        """
        Creates a list of all of the volumes in the given location.
        This will include private disks of the user as well as public
        disks from other users.

        This method is not a standard part of the Libcloud node driver
        interface.
        """

        configHolder = self._get_config_section(location)

        pdisk = PersistentDisk(configHolder)

        filters = {}
        volumes = pdisk.describeVolumes(filters)

        storage_volumes = []
        for info in volumes:
            storage_volumes.append(self._create_storage_volume(info, location))

        return storage_volumes
Beispiel #10
0
    def list_volumes(self, location=None):
        """
        Creates a list of all of the volumes in the given location.
        This will include private disks of the user as well as public
        disks from other users.

        This method is not a standard part of the Libcloud node driver
        interface.
        """

        configHolder = self._get_config_section(location)

        pdisk = PersistentDisk(configHolder)

        filters = {}
        volumes = pdisk.describeVolumes(filters)

        storage_volumes = []
        for info in volumes:
            storage_volumes.append(self._create_storage_volume(info, location))

        return storage_volumes