Пример #1
0
 def __init__(self, **kwargs):
     self.connection = netapp_api.NaServer(
         host=kwargs['hostname'],
         transport_type=kwargs['transport_type'],
         port=kwargs['port'],
         username=kwargs['username'],
         password=kwargs['password'])
Пример #2
0
    def test_cl_vols_ssc_single(self):
        """Test cluster ssc for single vol."""
        na_server = api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set([copy.deepcopy(self.vol1)])
        sis = {'vola': {'dedup': False, 'compression': False}}
        mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'},
                             {'dest_loc': 'openstack2:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'snapmirrored'}]}

        self.mox.StubOutWithMock(ssc_cmode, 'query_cluster_vols_for_ssc')
        self.mox.StubOutWithMock(ssc_cmode, 'get_sis_vol_dict')
        self.mox.StubOutWithMock(ssc_cmode, 'get_snapmirror_vol_dict')
        self.mox.StubOutWithMock(ssc_cmode, 'query_aggr_options')
        self.mox.StubOutWithMock(ssc_cmode, 'query_aggr_storage_disk')
        ssc_cmode.query_cluster_vols_for_ssc(
            na_server, vserver, 'vola').AndReturn(test_vols)
        ssc_cmode.get_sis_vol_dict(
            na_server, vserver, 'vola').AndReturn(sis)
        ssc_cmode.get_snapmirror_vol_dict(
            na_server, vserver, 'vola').AndReturn(mirrored)
        raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
        ssc_cmode.query_aggr_options(
            na_server, 'aggr1').AndReturn(raiddp)
        ssc_cmode.query_aggr_storage_disk(na_server, 'aggr1').AndReturn('SSD')
        self.mox.ReplayAll()

        res_vols = ssc_cmode.get_cluster_vols_with_ssc(
            na_server, vserver, volume='vola')

        self.mox.VerifyAll()
        self.assertEqual(len(res_vols), 1)
Пример #3
0
 def test_setter_invalid_value(self):
     """Tests invalid value raises exception."""
     root = netapp_api.NaElement('root')
     try:
         root['k'] = netapp_api.NaServer('localhost')
     except Exception as e:
         if not isinstance(e, TypeError):
             self.fail(_('Error not a TypeError.'))
Пример #4
0
 def test_query_aggr_options(self):
     na_server = api.NaServer('127.0.0.1')
     aggr_attribs = ssc_cmode.query_aggr_options(na_server, 'aggr0')
     if aggr_attribs:
         self.assertEqual('cfo', aggr_attribs['ha_policy'])
         self.assertEqual('raid_dp', aggr_attribs['raid_type'])
     else:
         raise exception.InvalidParameterValue("Incorrect aggr options")
Пример #5
0
 def test_query_cl_vols_for_ssc(self):
     na_server = api.NaServer('127.0.0.1')
     na_server.set_api_version(1, 15)
     vols = ssc_cmode.query_cluster_vols_for_ssc(na_server, 'Openstack')
     self.assertEqual(2, len(vols))
     for vol in vols:
         if vol.id['name'] != 'iscsi' or vol.id['name'] != 'nfsvol':
             pass
         else:
             raise exception.InvalidVolume('Invalid volume returned.')
Пример #6
0
    def __init__(self, **kwargs):
        host = kwargs['hostname']
        username = kwargs['username']
        password = kwargs['password']
        self.connection = netapp_api.NaServer(
            host=host,
            transport_type=kwargs['transport_type'],
            port=kwargs['port'],
            username=username,
            password=password)

        self.ssh_client = self._init_ssh_client(host, username, password)
Пример #7
0
    def test_cl_vols_ssc_all(self):
        """Test cluster ssc for all vols."""
        na_server = api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set([copy.deepcopy(self.vol1),
                         copy.deepcopy(self.vol2), copy.deepcopy(self.vol3)])
        sis = {'vola': {'dedup': False, 'compression': False},
               'volb': {'dedup': True, 'compression': False}}
        mirrored = {'vola': [{'dest_loc': 'openstack1:vol1',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'},
                             {'dest_loc': 'openstack2:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'snapmirrored'}],
                    'volb': [{'dest_loc': 'openstack1:vol2',
                              'rel_type': 'data_protection',
                              'mirr_state': 'broken'}]}

        self.mox.StubOutWithMock(ssc_cmode, 'query_cluster_vols_for_ssc')
        self.mox.StubOutWithMock(ssc_cmode, 'get_sis_vol_dict')
        self.mox.StubOutWithMock(ssc_cmode, 'get_snapmirror_vol_dict')
        self.mox.StubOutWithMock(ssc_cmode, 'query_aggr_options')
        self.mox.StubOutWithMock(ssc_cmode, 'query_aggr_storage_disk')
        ssc_cmode.query_cluster_vols_for_ssc(
            na_server, vserver, None).AndReturn(test_vols)
        ssc_cmode.get_sis_vol_dict(na_server, vserver, None).AndReturn(sis)
        ssc_cmode.get_snapmirror_vol_dict(na_server, vserver, None).AndReturn(
            mirrored)
        raiddp = {'ha_policy': 'cfo', 'raid_type': 'raiddp'}
        ssc_cmode.query_aggr_options(
            na_server, IgnoreArg()).AndReturn(raiddp)
        ssc_cmode.query_aggr_storage_disk(
            na_server, IgnoreArg()).AndReturn('SSD')
        raid4 = {'ha_policy': 'cfo', 'raid_type': 'raid4'}
        ssc_cmode.query_aggr_options(
            na_server, IgnoreArg()).AndReturn(raid4)
        ssc_cmode.query_aggr_storage_disk(
            na_server, IgnoreArg()).AndReturn('SAS')
        self.mox.ReplayAll()

        res_vols = ssc_cmode.get_cluster_vols_with_ssc(
            na_server, vserver, volume=None)

        self.mox.VerifyAll()
        for vol in res_vols:
            if vol.id['name'] == 'volc':
                self.assertEqual(vol.sis['compression'], False)
                self.assertEqual(vol.sis['dedup'], False)
            else:
                pass
Пример #8
0
    def test__get_url(self, host):
        port = '80'
        root = netapp_api.NaServer(host, port=port)

        protocol = root.TRANSPORT_TYPE_HTTP
        url = root.URL_FILER

        if netutils.is_valid_ipv6(host):
            host = netutils.escape_ipv6(host)

        result = '%s://%s:%s/%s' % (protocol, host, port, url)

        url = root._get_url()

        self.assertEqual(result, url)
 def test_query_cluster_vols_for_ssc(self, na_server_exists, volume):
     if na_server_exists:
         na_server = netapp_api.NaServer('127.0.0.1')
         fake_api_return = mock.Mock(return_value=[])
         self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
                          new_attr=fake_api_return)
         ssc_cmode.query_cluster_vols_for_ssc(na_server, 'vserver',
                                              volume)
     else:
         na_server = None
         fake_api_error = mock.Mock(side_effect=exception.InvalidInput)
         self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
                          new_attr=fake_api_error)
         self.assertRaises(KeyError, ssc_cmode.query_cluster_vols_for_ssc,
                           na_server, 'vserver', volume)
Пример #10
0
    def test_query_aggr_storage_disk(self):
        na_server = netapp_api.NaServer('127.0.0.1')
        body = etree.XML("""<results status="passed">
        <attributes-list>
        <storage-disk-info>
        <disk-raid-info>
        <effective-disk-type>SATA</effective-disk-type>
        </disk-raid-info>
        </storage-disk-info>
        </attributes-list>
        </results>""")

        self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
                         mock.Mock(return_value=[netapp_api.NaElement(body)]))

        eff_disk_type = ssc_cmode.query_aggr_storage_disk(na_server, 'aggr0')
        self.assertEqual('SATA', eff_disk_type)
Пример #11
0
    def test_get_cluster_ssc(self):
        """Test get cluster ssc map."""
        na_server = netapp_api.NaServer('127.0.0.1')
        vserver = 'openstack'
        test_vols = set(
            [self.vol1, self.vol2, self.vol3, self.vol4, self.vol5])

        self.mox.StubOutWithMock(ssc_cmode, 'get_cluster_vols_with_ssc')
        ssc_cmode.get_cluster_vols_with_ssc(na_server,
                                            vserver).AndReturn(test_vols)
        self.mox.ReplayAll()

        res_map = ssc_cmode.get_cluster_ssc(na_server, vserver)

        self.mox.VerifyAll()
        self.assertEqual(1, len(res_map['mirrored']))
        self.assertEqual(3, len(res_map['dedup']))
        self.assertEqual(1, len(res_map['compression']))
        self.assertEqual(2, len(res_map['thin']))
        self.assertEqual(5, len(res_map['all']))
Пример #12
0
    def test_query_aggr_options(self):
        na_server = netapp_api.NaServer('127.0.0.1')
        body = etree.XML("""<results status="passed">
        <options>
        <aggr-option-info>
        <name>ha_policy</name>
        <value>cfo</value>
        </aggr-option-info>
        <aggr-option-info>
        <name>raidtype</name>
        <value>raid_dp</value>
        </aggr-option-info>
        </options>
        </results>""")

        self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
                         mock.Mock(return_value=[netapp_api.NaElement(body)]))

        aggr_attribs = ssc_cmode.query_aggr_options(na_server, 'aggr0')
        if aggr_attribs:
            self.assertEqual('cfo', aggr_attribs['ha_policy'])
            self.assertEqual('raid_dp', aggr_attribs['raid_type'])
        else:
            raise exception.InvalidParameterValue("Incorrect aggr options")
Пример #13
0
FAKE_XML2 = b"""<root><options>somecontent</options></root>"""

FAKE_NA_ELEMENT = netapp_api.NaElement(etree.XML(FAKE_VOL_XML))

FAKE_INVOKE_DATA = 'somecontent'

FAKE_XML_STR = 'abc'

FAKE_API_NAME = 'volume-get-iter'

FAKE_API_NAME_ELEMENT = netapp_api.NaElement(FAKE_API_NAME)

FAKE_NA_SERVER_STR = '127.0.0.1'

FAKE_NA_SERVER = netapp_api.NaServer(FAKE_NA_SERVER_STR)

FAKE_NA_SERVER_API_1_5 = netapp_api.NaServer(FAKE_NA_SERVER_STR)
FAKE_NA_SERVER_API_1_5.set_vfiler('filer')
FAKE_NA_SERVER_API_1_5.set_api_version(1, 5)

FAKE_NA_SERVER_API_1_14 = netapp_api.NaServer(FAKE_NA_SERVER_STR)
FAKE_NA_SERVER_API_1_14.set_vserver('server')
FAKE_NA_SERVER_API_1_14.set_api_version(1, 14)

FAKE_NA_SERVER_API_1_20 = netapp_api.NaServer(FAKE_NA_SERVER_STR)
FAKE_NA_SERVER_API_1_20.set_vfiler('filer')
FAKE_NA_SERVER_API_1_20.set_vserver('server')
FAKE_NA_SERVER_API_1_20.set_api_version(1, 20)

FAKE_QUERY = {'volume-attributes': None}
Пример #14
0
 def setUp(self):
     self.root = netapp_api.NaServer('127.0.0.1')
     super(NetAppApiServerTests, self).setUp()
Пример #15
0
    def test_query_cl_vols_for_ssc(self):
        na_server = netapp_api.NaServer('127.0.0.1')
        body = etree.XML("""<results status="passed"><attributes-list>
                <volume-attributes>
                <volume-id-attributes>
                    <name>iscsi</name>
                    <owning-vserver-name>Openstack</owning-vserver-name>
                    <containing-aggregate-name>aggr0
                    </containing-aggregate-name>
                    <junction-path>/iscsi</junction-path>
                    <type>rw</type>
                </volume-id-attributes>
                <volume-space-attributes>
                    <space-guarantee-enabled>enabled</space-guarantee-enabled>
                    <space-guarantee>file</space-guarantee>
                </volume-space-attributes>
                <volume-state-attributes>
                    <is-cluster-volume>true
                    </is-cluster-volume>
                    <is-vserver-root>false</is-vserver-root>
                    <state>online</state>
                    <is-inconsistent>false</is-inconsistent>
                    <is-invalid>false</is-invalid>
                    <is-junction-active>true</is-junction-active>
                </volume-state-attributes>
                </volume-attributes>
                <volume-attributes>
                <volume-id-attributes>
                    <name>nfsvol</name>
                    <owning-vserver-name>Openstack
                    </owning-vserver-name>
                    <containing-aggregate-name>aggr0
                    </containing-aggregate-name>
                    <junction-path>/nfs</junction-path>
                    <type>rw</type>
                </volume-id-attributes>
                <volume-space-attributes>
                    <space-guarantee-enabled>enabled
                    </space-guarantee-enabled>
                    <space-guarantee>volume</space-guarantee>
                </volume-space-attributes>
                <volume-state-attributes>
                    <is-cluster-volume>true
                    </is-cluster-volume>
                    <is-vserver-root>false</is-vserver-root>
                    <state>online</state>
                    <is-inconsistent>false</is-inconsistent>
                    <is-invalid>false</is-invalid>
                    <is-junction-active>true</is-junction-active>
                </volume-state-attributes>
                </volume-attributes>
                <volume-attributes>
                <volume-id-attributes>
                    <name>nfsvol2</name>
                    <owning-vserver-name>Openstack
                    </owning-vserver-name>
                    <containing-aggregate-name>aggr0
                    </containing-aggregate-name>
                    <junction-path>/nfs2</junction-path>
                    <type>rw</type>
                </volume-id-attributes>
                <volume-space-attributes>
                    <space-guarantee-enabled>enabled
                    </space-guarantee-enabled>
                    <space-guarantee>volume</space-guarantee>
                </volume-space-attributes>
                <volume-state-attributes>
                    <is-cluster-volume>true
                    </is-cluster-volume>
                    <is-vserver-root>false</is-vserver-root>
                    <state>online</state>
                    <is-inconsistent>true</is-inconsistent>
                    <is-invalid>true</is-invalid>
                    <is-junction-active>true</is-junction-active>
                </volume-state-attributes>
                </volume-attributes>
                <volume-attributes>
                <volume-id-attributes>
                    <name>nfsvol3</name>
                    <owning-vserver-name>Openstack
                    </owning-vserver-name>
                    <containing-aggregate-name>aggr0
                    </containing-aggregate-name>
                    <junction-path>/nfs3</junction-path>
                    <type>rw</type>
                </volume-id-attributes>
                <volume-space-attributes>
                    <space-guarantee-enabled>enabled
                    </space-guarantee-enabled>
                    <space-guarantee>volume
                    </space-guarantee>
                </volume-space-attributes>
                <volume-state-attributes>
                    <is-cluster-volume>true
                    </is-cluster-volume>
                    <is-vserver-root>false</is-vserver-root>
                    <state>online</state>
                    <is-inconsistent>false</is-inconsistent>
                    <is-invalid>false</is-invalid>
                    <is-junction-active>true</is-junction-active>
                </volume-state-attributes>
                </volume-attributes>
                </attributes-list>
                <num-records>4</num-records></results>""")

        self.mock_object(ssc_cmode.netapp_api, 'invoke_api',
                         mock.Mock(return_value=[netapp_api.NaElement(body)]))

        vols = ssc_cmode.query_cluster_vols_for_ssc(na_server, 'Openstack')
        self.assertEqual(3, len(vols))
        for vol in vols:
            if vol.id['name'] != 'iscsi' or vol.id['name'] != 'nfsvol':
                pass
            else:
                raise exception.InvalidVolume('Invalid volume returned.')
Пример #16
0
 def test_query_aggr_storage_disk(self):
     na_server = api.NaServer('127.0.0.1')
     eff_disk_type = ssc_cmode.query_aggr_storage_disk(na_server, 'aggr0')
     self.assertEqual('SATA', eff_disk_type)