Beispiel #1
0
 def do_setup(self, context):
     """Instantiate common class and log in storage system."""
     self.common = RestCommon(configuration=self.configuration)
     return self.common.login()
 def do_setup(self, context):
     """Instantiate common class and log in storage system."""
     self.common = RestCommon(configuration=self.configuration)
     return self.common.login()
Beispiel #3
0
class Huawei18000ISCSIDriver(driver.ISCSIDriver):
    """ISCSI driver for Huawei OceanStor 18000 storage arrays.

    Version history:
        1.0.0 - Initial driver
        1.1.0 - Provide Huawei OceanStor 18000 storage volume driver.
    """

    VERSION = "1.1.0"

    def __init__(self, *args, **kwargs):
        super(Huawei18000ISCSIDriver, self).__init__(*args, **kwargs)

    def do_setup(self, context):
        """Instantiate common class and log in storage system."""
        self.common = RestCommon(configuration=self.configuration)
        return self.common.login()

    def check_for_setup_error(self):
        """Check configuration file."""
        return self.common._check_conf_file()

    def create_volume(self, volume):
        """Create a volume."""
        lun_info = self.common.create_volume(volume)
        return {'provider_location': lun_info['ID'],
                'lun_info': lun_info}

    def create_volume_from_snapshot(self, volume, snapshot):
        """Create a volume from a snapshot."""
        lun_info = self.common.create_volume_from_snapshot(volume, snapshot)
        return {'provider_location': lun_info['ID'],
                'lun_info': lun_info}

    def create_cloned_volume(self, volume, src_vref):
        """Create a clone of the specified volume."""
        lun_info = self.common.create_cloned_volume(volume, src_vref)
        return {'provider_location': lun_info['ID'],
                'lun_info': lun_info}

    def extend_volume(self, volume, new_size):
        """Extend a volume."""
        return self.common.extend_volume(volume, new_size)

    def delete_volume(self, volume):
        """Delete a volume."""
        return self.common.delete_volume(volume)

    def create_snapshot(self, snapshot):
        """Create a snapshot."""
        lun_info = self.common.create_snapshot(snapshot)
        return {'provider_location': lun_info['ID'],
                'lun_info': lun_info}

    def delete_snapshot(self, snapshot):
        """Delete a snapshot."""
        return self.common.delete_snapshot(snapshot)

    def get_volume_stats(self, refresh=False):
        """Get volume stats."""
        data = self.common.update_volume_stats()
        backend_name = self.configuration.safe_get('volume_backend_name')
        data['volume_backend_name'] = backend_name or self.__class__.__name__
        data['storage_protocol'] = 'iSCSI'
        data['driver_version'] = self.VERSION
        return data

    def initialize_connection(self, volume, connector):
        """Map a volume to a host."""
        return self.common.initialize_connection_iscsi(volume, connector)

    def terminate_connection(self, volume, connector, **kwargs):
        """Terminate the map."""
        self.common.terminate_connection_iscsi(volume, connector)

    def create_export(self, context, volume):
        """Export the volume."""
        pass

    def ensure_export(self, context, volume):
        """Synchronously recreate an export for a volume."""
        pass

    def remove_export(self, context, volume):
        """Remove an export for a volume."""
        pass
class Huawei18000ISCSIDriver(driver.ISCSIDriver):
    """ISCSI driver for Huawei OceanStor 18000 storage arrays.

    Version history:
        1.0.0 - Initial driver
        1.1.0 - Provide Huawei OceanStor 18000 storage volume driver.
    """

    VERSION = "1.1.0"

    def __init__(self, *args, **kwargs):
        super(Huawei18000ISCSIDriver, self).__init__(*args, **kwargs)

    def do_setup(self, context):
        """Instantiate common class and log in storage system."""
        self.common = RestCommon(configuration=self.configuration)
        return self.common.login()

    def check_for_setup_error(self):
        """Check configuration file."""
        return self.common._check_conf_file()

    def create_volume(self, volume):
        """Create a volume."""
        volume_id = self.common.create_volume(volume)
        return {"provider_location": volume_id}

    def create_volume_from_snapshot(self, volume, snapshot):
        """Create a volume from a snapshot."""
        snapshot_id = self.common.create_volume_from_snapshot(volume, snapshot)
        return {"provider_location": snapshot_id}

    def create_cloned_volume(self, volume, src_vref):
        """Create a clone of the specified volume."""
        volume_id = self.common.create_cloned_volume(volume, src_vref)
        return {"provider_location": volume_id}

    def extend_volume(self, volume, new_size):
        """Extend a volume."""
        return self.common.extend_volume(volume, new_size)

    def delete_volume(self, volume):
        """Delete a volume."""
        return self.common.delete_volume(volume)

    def create_snapshot(self, snapshot):
        """Create a snapshot."""
        snapshot_id = self.common.create_snapshot(snapshot)
        return {"provider_location": snapshot_id}

    def delete_snapshot(self, snapshot):
        """Delete a snapshot."""
        return self.common.delete_snapshot(snapshot)

    def get_volume_stats(self, refresh=False):
        """Get volume stats."""
        data = self.common.update_volume_stats()
        backend_name = self.configuration.safe_get("volume_backend_name")
        data["volume_backend_name"] = backend_name or self.__class__.__name__
        data["storage_protocol"] = "iSCSI"
        data["driver_version"] = self.VERSION
        return data

    def initialize_connection(self, volume, connector):
        """Map a volume to a host."""
        return self.common.initialize_connection_iscsi(volume, connector)

    def terminate_connection(self, volume, connector, **kwargs):
        """Terminate the map."""
        return self.common.terminate_connection_iscsi(volume, connector)

    def create_export(self, context, volume):
        """Export the volume."""
        pass

    def ensure_export(self, context, volume):
        """Synchronously recreate an export for a volume."""
        pass

    def remove_export(self, context, volume):
        """Remove an export for a volume."""
        pass