1# Copyright (c) 2014 NetApp, Inc.  All Rights Reserved.
2# Copyright (c) 2015 Alex Meade.  All Rights Reserved.
3# Copyright (c) 2015 Rushil Chugh.  All Rights Reserved.
4# Copyright (c) 2015 Navneet Singh.  All Rights Reserved.
5#
6#    Licensed under the Apache License, Version 2.0 (the "License"); you may
7#    not use this file except in compliance with the License. You may obtain
8#    a copy of the License at
9#
10#         http://www.apache.org/licenses/LICENSE-2.0
11#
12#    Unless required by applicable law or agreed to in writing, software
13#    distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14#    WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15#    License for the specific language governing permissions and limitations
16#    under the License.
17"""
18Volume driver for NetApp E-Series iSCSI storage systems.
19"""
20
21from cinder import interface
22from cinder.volume import driver
23from cinder.volume.drivers.netapp.eseries import library
24from cinder.volume.drivers.netapp import utils as na_utils
25
26
27@interface.volumedriver
28class NetAppEseriesISCSIDriver(driver.BaseVD,
29                               driver.ManageableVD):
30    """NetApp E-Series iSCSI volume driver."""
31
32    DRIVER_NAME = 'NetApp_iSCSI_ESeries'
33
34    # ThirdPartySystems wiki page
35    CI_WIKI_NAME = "NetApp_Eseries_CI"
36    VERSION = library.NetAppESeriesLibrary.VERSION
37
38    def __init__(self, *args, **kwargs):
39        super(NetAppEseriesISCSIDriver, self).__init__(*args, **kwargs)
40        na_utils.validate_instantiation(**kwargs)
41        self.library = library.NetAppESeriesLibrary(self.DRIVER_NAME,
42                                                    'iSCSI', **kwargs)
43
44    def do_setup(self, context):
45        self.library.do_setup(context)
46
47    def check_for_setup_error(self):
48        self.library.check_for_setup_error()
49
50    def create_volume(self, volume):
51        self.library.create_volume(volume)
52
53    def create_volume_from_snapshot(self, volume, snapshot):
54        self.library.create_volume_from_snapshot(volume, snapshot)
55
56    def create_cloned_volume(self, volume, src_vref):
57        self.library.create_cloned_volume(volume, src_vref)
58
59    def delete_volume(self, volume):
60        self.library.delete_volume(volume)
61
62    def create_snapshot(self, snapshot):
63        return self.library.create_snapshot(snapshot)
64
65    def delete_snapshot(self, snapshot):
66        self.library.delete_snapshot(snapshot)
67
68    def get_volume_stats(self, refresh=False):
69        return self.library.get_volume_stats(refresh)
70
71    def extend_volume(self, volume, new_size):
72        self.library.extend_volume(volume, new_size)
73
74    def ensure_export(self, context, volume):
75        return self.library.ensure_export(context, volume)
76
77    def create_export(self, context, volume, connector):
78        return self.library.create_export(context, volume)
79
80    def remove_export(self, context, volume):
81        self.library.remove_export(context, volume)
82
83    def manage_existing(self, volume, existing_ref):
84        return self.library.manage_existing(volume, existing_ref)
85
86    def manage_existing_get_size(self, volume, existing_ref):
87        return self.library.manage_existing_get_size(volume, existing_ref)
88
89    def unmanage(self, volume):
90        return self.library.unmanage(volume)
91
92    def initialize_connection(self, volume, connector):
93        return self.library.initialize_connection_iscsi(volume, connector)
94
95    def terminate_connection(self, volume, connector, **kwargs):
96        return self.library.terminate_connection_iscsi(volume, connector,
97                                                       **kwargs)
98
99    def get_pool(self, volume):
100        return self.library.get_pool(volume)
101
102    def create_cgsnapshot(self, context, cgsnapshot, snapshots):
103        return self.library.create_cgsnapshot(cgsnapshot, snapshots)
104
105    def delete_cgsnapshot(self, context, cgsnapshot, snapshots):
106        return self.library.delete_cgsnapshot(cgsnapshot, snapshots)
107
108    def create_consistencygroup(self, context, group):
109        return self.library.create_consistencygroup(group)
110
111    def delete_consistencygroup(self, context, group, volumes):
112        return self.library.delete_consistencygroup(group, volumes)
113
114    def update_consistencygroup(self, context, group,
115                                add_volumes=None, remove_volumes=None):
116        return self.library.update_consistencygroup(
117            group, add_volumes, remove_volumes)
118
119    def create_consistencygroup_from_src(self, context, group, volumes,
120                                         cgsnapshot=None, snapshots=None,
121                                         source_cg=None, source_vols=None):
122        return self.library.create_consistencygroup_from_src(
123            group, volumes, cgsnapshot, snapshots, source_cg, source_vols)
124
125    def create_group(self, context, group):
126        return self.create_consistencygroup(context, group)
127
128    def delete_group(self, context, group, volumes):
129        return self.library.delete_consistencygroup(group, volumes)
130