コード例 #1
0
    def test_attach(self, mock_dedicate, mock_add_disk, mock_check):

        connection_info = {
            'platform': 'x86_64',
            'ip': '1.2.3.4',
            'os_version': 'rhel7',
            'multipath': False,
            'target_wwpn': '1111',
            'target_lun': '2222',
            'zvm_fcp': 'b83c',
            'mount_point': '/dev/sdz',
            'assigner_id': 'user1'
        }
        mock_check.return_value = True
        self.db_op = database.FCPDbOperator()
        self.db_op.new('b83c')

        try:
            self.volumeops.attach(connection_info)
            mock_dedicate.assert_called_once_with('b83c', 'USER1')
            mock_add_disk.assert_called_once_with('b83c', 'USER1', '1111',
                                                  '2222', False, 'rhel7',
                                                  '/dev/sdz')
        finally:
            self.db_op.delete('b83c')
コード例 #2
0
ファイル: test_volumeop.py プロジェクト: chris6154/feilong
    def test_detach_no_undedicate(self, mock_undedicate, mock_remove_disk,
                                  mock_check):

        connection_info = {
            'platform': 'x86_64',
            'ip': '1.2.3.4',
            'os_version': 'rhel7',
            'multipath': 'False',
            'target_wwpn': ['1111'],
            'target_lun': '2222',
            'zvm_fcp': ['283c'],
            'mount_point': '/dev/sdz',
            'assigner_id': 'user1'
        }
        mock_check.return_value = True
        self.db_op = database.FCPDbOperator()
        self.db_op.new('283c', 0)
        self.db_op.assign('283c', 'user1')
        self.db_op.increase_usage('283c')

        try:
            self.volumeops.detach(connection_info)
            self.assertFalse(mock_undedicate.called)
            mock_remove_disk.assert_called_once_with('283c', 'USER1', ['1111'],
                                                     '2222', False, 'rhel7',
                                                     '/dev/sdz', 1, True)
        finally:
            self.db_op.delete('283c')
コード例 #3
0
 def __init__(self):
     # _fcp_pool store the objects of FCP index by fcp id
     self._fcp_pool = {}
     # _fcp_path_info store the FCP path mapping index by path no
     self._fcp_path_mapping = {}
     self.db = database.FCPDbOperator()
     self._smtclient = smtclient.get_smtclient()
コード例 #4
0
    def test_attach_no_dedicate(self, mock_dedicate, mock_add_disk,
                                mock_check, mock_fcp_info):

        connection_info = {'platform': 'x86_64',
                           'ip': '1.2.3.4',
                           'os_version': 'rhel7',
                           'multipath': 'false',
                           'target_wwpn': ['20076D8500005182',
                                           '20076D8500005183'],
                           'target_lun': '2222',
                           'zvm_fcp': ['c123', 'd123'],
                           'mount_point': '/dev/sdz',
                           'assigner_id': 'user1'}
        fcp_list = ['opnstk1: FCP device number: C123',
                    'opnstk1:   Status: Free',
                    'opnstk1:   NPIV world wide port number: '
                    '20076D8500005182',
                    'opnstk1:   Channel path ID: 59',
                    'opnstk1:   Physical world wide port number: '
                    '20076D8500005181',
                    'opnstk1: FCP device number: D123',
                    'opnstk1:   Status: Active',
                    'opnstk1:   NPIV world wide port number: '
                    '20076D8500005183',
                    'opnstk1:   Channel path ID: 50',
                    'opnstk1:   Physical world wide port number: '
                    '20076D8500005185']
        mock_fcp_info.return_value = fcp_list
        mock_check.return_value = True
        wwpns = ['20076D8500005182', '20076D8500005183']
        self.db_op = database.FCPDbOperator()
        self.db_op.new('c123', 0)
        # assign will set connections to 1
        self.db_op.assign('c123', 'USER1')

        self.db_op.new('d123', 1)
        self.db_op.assign('d123', 'USER1')

        # set connections to 2
        self.db_op.increase_usage('c123')
        self.db_op.increase_usage('d123')

        try:
            self.volumeops.attach(connection_info)
            self.assertFalse(mock_dedicate.called)
            mock_add_disk.assert_has_calls([mock.call('c123', 'USER1',
                                                      wwpns,
                                                      '2222', False, 'rhel7',
                                                      '/dev/sdz', False,
                                                      False),
                                            mock.call('d123', 'USER1',
                                                      wwpns,
                                                      '2222', False, 'rhel7',
                                                      '/dev/sdz', False,
                                                      True)])

        finally:
            self.db_op.delete('c123')
            self.db_op.delete('d123')
コード例 #5
0
    def test_detach(self, mock_undedicate, mock_remove_disk, mock_check,
                    mock_fcp_info):

        connection_info = {'platform': 'x86_64',
                           'ip': '1.2.3.4',
                           'os_version': 'rhel7',
                           'multipath': 'True',
                           'target_wwpn': ['20076D8500005182',
                                           '20076D8500005183'],
                           'target_lun': '2222',
                           'zvm_fcp': ['183c', '283c'],
                           'mount_point': '/dev/sdz',
                           'assigner_id': 'user1'}
        fcp_list = ['opnstk1: FCP device number: 183C',
                    'opnstk1:   Status: Free',
                    'opnstk1:   NPIV world wide port number: 20076D8500005182',
                    'opnstk1:   Channel path ID: 59',
                    'opnstk1:   Physical world wide port number: '
                    '20076D8500005181',
                    'opnstk1: FCP device number: 283C',
                    'opnstk1:   Status: Active',
                    'opnstk1:   NPIV world wide port number: '
                    '20076D8500005183',
                    'opnstk1:   Channel path ID: 50',
                    'opnstk1:   Physical world wide port number: '
                    '20076D8500005185']
        mock_fcp_info.return_value = fcp_list
        mock_check.return_value = True
        wwpns = ['20076D8500005182', '20076D8500005183']
        self.db_op = database.FCPDbOperator()
        self.db_op.new('183c', 0)
        self.db_op.assign('183c', 'USER1')

        self.db_op.new('283c', 1)
        # assign will set the connections to 1
        self.db_op.assign('283c', 'USER1')

        try:
            self.volumeops.detach(connection_info)
            mock_undedicate.assert_has_calls([mock.call('183c', 'USER1'),
                                              mock.call('283c', 'USER1')])
            mock_remove_disk.assert_has_calls([mock.call('183c', 'USER1',
                                                         wwpns,
                                                         '2222', True, 'rhel7',
                                                         '/dev/sdz', 0, False),
                                               mock.call('283c', 'USER1',
                                                         wwpns,
                                                         '2222', True, 'rhel7',
                                                         '/dev/sdz', 0, True)])
            res1 = self.db_op.is_reserved('183c')
            res2 = self.db_op.is_reserved('283c')
            self.assertFalse(res1)
            self.assertFalse(res2)
        finally:
            self.db_op.delete('183c')
            self.db_op.delete('283c')
コード例 #6
0
ファイル: test_volumeop.py プロジェクト: chris6154/feilong
    def test_find_and_reserve_fcp_old(self):
        self.db_op = database.FCPDbOperator()
        # create 2 FCP
        self.db_op.new('c83c', 0)
        self.db_op.new('c83d', 0)

        # find FCP for user and FCP not exist, should allocate them
        try:
            fcp1 = self.fcpops.find_and_reserve_fcp('user1')
            self.assertEqual('c83c', fcp1)
            self.fcpops.increase_fcp_usage('c83c', 'user1')

            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 1, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            # After usage, we need find c83d now
            fcp2 = self.fcpops.find_and_reserve_fcp('user2')
            self.assertEqual('c83d', fcp2)
            fcp_list = self.db_op.get_from_fcp('c83d')
            expected = [(u'c83d', u'', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.increase_fcp_usage('c83c', 'user1')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 2, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.decrease_fcp_usage('c83c', 'user1')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 1, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.decrease_fcp_usage('c83c')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            # unreserve makes this fcp free
            self.fcpops.unreserve_fcp('c83c')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 0, 0, u'')]
            self.assertEqual(expected, fcp_list)

            fcp3 = self.fcpops.find_and_reserve_fcp('user3')
            self.assertEqual('c83c', fcp3)
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)
        finally:
            self.db_op.delete('c83c')
            self.db_op.delete('c83d')
コード例 #7
0
ファイル: test_volumeop.py プロジェクト: chris6154/feilong
    def test_root_volume_detach(self, mock_undedicate, mock_remove_disk,
                                mock_check, mock_fcp_info):

        connection_info = {
            'platform': 's390x',
            'ip': '1.2.3.4',
            'os_version': 'rhel7',
            'multipath': 'True',
            'target_wwpn': ['20076D8500005182', '20076D8500005183'],
            'target_lun': '2222',
            'zvm_fcp': ['183c', '283c'],
            'mount_point': '/dev/sdz',
            'assigner_id': 'user1',
            'is_root_volume': True
        }
        fcp_list = [
            'opnstk1: FCP device number: 183C', 'opnstk1:   Status: Free',
            'opnstk1:   NPIV world wide port number: 20076D8500005182',
            'opnstk1:   Channel path ID: 59',
            'opnstk1:   Physical world wide port number: '
            '20076D8500005181', 'opnstk1: FCP device number: 283C',
            'opnstk1:   Status: Active',
            'opnstk1:   NPIV world wide port number: 20076D8500005183',
            'opnstk1:   Channel path ID: 50',
            'opnstk1:   Physical world wide port number: '
            '20076D8500005185'
        ]
        mock_fcp_info.return_value = fcp_list
        mock_check.return_value = True
        base.set_conf('volume', 'fcp_list', '183c')
        base.set_conf('volume', 'fcp_list', '283c')
        self.db_op = database.FCPDbOperator()
        self.db_op.new('183c', 0)
        self.db_op.assign('183c', 'USER1')

        self.db_op.new('283c', 1)
        # assign will set the connections to 1
        self.db_op.assign('283c', 'USER1')

        try:
            self.volumeops.detach(connection_info)
            self.assertFalse(mock_undedicate.called)
            self.assertFalse(mock_remove_disk.called)
        finally:
            self.db_op.delete('183c')
            self.db_op.delete('283c')
コード例 #8
0
    def test_detach(self, mock_undedicate, mock_remove_disk):

        connection_info = {'platform': 'x86_64',
                           'ip': '1.2.3.4',
                           'os_version': 'rhel7',
                           'multipath': False,
                           'target_wwpn': '1111',
                           'target_lun': '2222',
                           'zvm_fcp': 'b83c',
                           'assigner_id': 'user1'}
        db_op = database.FCPDbOperator()
        db_op.new('b83c')
        db_op.assign('b83c', 'user1')

        try:
            self.volumeops.detach(connection_info)
            mock_remove_disk.assert_called_once_with('b83c', 'user1', '1111',
                                                     '2222', False, 'rhel7')
            mock_undedicate.assert_called_once_with('b83c', 'user1')
        finally:
            db_op.delete('b83c')
コード例 #9
0
    def test_get_volume_connector(self):
        db_op = database.FCPDbOperator()
        base.set_conf('network', 'my_ip', '1.2.3.4')
        # create 1 FCP
        db_op.new('b83c')

        try:
            connections = self.volumeops.get_volume_connector('dummy')
            expected = {'multipath': True,
                        'platform': 's390x',
                        'do_local_attach': False,
                        'fcp': u'b83c',
                        'os_version': '',
                        'os_type': 'linux',
                        'ip': '1.2.3.4'}
            self.assertEqual(expected, connections)

            fcp_list = db_op.get_from_fcp('b83c')
            expected = [(u'b83c', u'', 0, 1, u'')]
            self.assertEqual(expected, fcp_list)
        finally:
            db_op.delete('b83c')
コード例 #10
0
    def test_find_and_reserve_fcp_new(self):
        db_op = database.FCPDbOperator()
        # create 2 FCP
        db_op.new('b83c')
        db_op.new('b83d')

        # find FCP for user and FCP not exist, should allocate them
        try:
            fcp1 = self.fcpops.find_and_reserve_fcp('dummy1')
            fcp2 = self.fcpops.find_and_reserve_fcp('dummy2')

            self.assertEqual('b83c', fcp1)
            self.assertEqual('b83d', fcp2)

            fcp_list = db_op.get_from_fcp('b83c')
            expected = [(u'b83c', u'', 0, 1, u'')]
            self.assertEqual(expected, fcp_list)

            fcp_list = db_op.get_from_fcp('b83d')
            expected = [(u'b83d', u'', 0, 1, u'')]
            self.assertEqual(expected, fcp_list)
        finally:
            db_op.delete('b83c')
            db_op.delete('b83d')
コード例 #11
0
    def test_sync_db_fcp_list(self, mock_add, mock_report, mock_get):

        fcp_list = ['opnstk1: FCP device number: B83D',
            'opnstk1:   Status: Free',
            'opnstk1:   NPIV world wide port number: 20076D8500005182',
            'opnstk1:   Channel path ID: 59',
            'opnstk1:   Physical world wide port number: 20076D8500005181',
            'opnstk1: FCP device number: B83E',
            'opnstk1:   Status: Active',
            'opnstk1:   NPIV world wide port number: 20076D8500005183',
            'opnstk1:   Channel path ID: 50',
            'opnstk1:   Physical world wide port number: 20076D8500005185',
            'opnstk1: FCP device number: B83F',
            'opnstk1:   Status: Active',
            'opnstk1:   NPIV world wide port number: 20076D8500005187',
            'opnstk1:   Channel path ID: 50',
            'opnstk1:   Physical world wide port number: 20076D8500005188']

        mock_get.return_value = fcp_list

        self.fcpops._init_fcp_pool('b83d-b83f')

        db_op = database.FCPDbOperator()
        db_op.new('b83c')
        db_op.new('b83d')
        db_op.new('b83e')

        try:
            self.fcpops._sync_db_fcp_list()
            mock_add.assert_called_once_with('b83f')
            mock_report.assert_called_once_with('b83c')
        finally:
            db_op.delete('b83d')
            db_op.delete('b83e')
            db_op.delete('b83f')
            db_op.delete('b83c')
コード例 #12
0
 def __init__(self):
     self._fcp_pool = {}
     self.db = database.FCPDbOperator()
     self._smtclient = smtclient.get_smtclient()
コード例 #13
0
ファイル: test_volumeop.py プロジェクト: chris6154/feilong
 def setUpClass(cls):
     super(TestFCPVolumeManager, cls).setUpClass()
     cls.volumeops = volumeop.FCPVolumeManager()
     cls.db_op = database.FCPDbOperator()
コード例 #14
0
    def test_find_and_reserve_fcp_old(self):
        self.db_op = database.FCPDbOperator()
        # create 2 FCP
        self.db_op.new('c83c', 0)
        self.db_op.new('c83d', 0)

        # find FCP for user and FCP not exist, should allocate them
        try:
            fcp1 = self.fcpops.find_and_reserve_fcp('user1')
            self.assertEqual('c83c', fcp1)
            self.fcpops.increase_fcp_usage('c83c', 'user1')

            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'', 1, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            # After usage, we need find c83d now
            fcp2 = self.fcpops.find_and_reserve_fcp('user2')
            self.assertEqual('c83d', fcp2)
            fcp_list = self.db_op.get_from_fcp('c83d')
            expected = [(u'c83d', u'', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.increase_fcp_usage('c83c', 'user1')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'', 2, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.decrease_fcp_usage('c83c', 'user1')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'', 1, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            # add_fcp_for_assigner is designed for multipath
            # so if multipath is enabled(path_count >= 2),
            # add_fcp_for_assinger used on an instance exsited in DB,
            # will not increase the connections
            self.fcpops.add_fcp_for_assigner(2, 'c83c', 'user1')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 1, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            self.fcpops.decrease_fcp_usage('c83c')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)

            # unreserve makes this fcp free
            self.fcpops.unreserve_fcp('c83c')
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 0, 0, u'')]
            self.assertEqual(expected, fcp_list)

            fcp3 = self.fcpops.find_and_reserve_fcp('user3')
            self.assertEqual('c83c', fcp3)
            fcp_list = self.db_op.get_from_fcp('c83c')
            expected = [(u'c83c', u'user1', 0, 1, 0, u'')]
            self.assertEqual(expected, fcp_list)
        finally:
            self.db_op.delete('c83c')
            self.db_op.delete('c83d')
コード例 #15
0
ファイル: volumeop.py プロジェクト: rsoaresbsb/python-zvm-sdk
 def __init__(self):
     self._fcp_pool = {}
     self.db = database.FCPDbOperator()
コード例 #16
0
 def __init__(self):
     self.fcp_mgr = FCPManager()
     self.config_api = VolumeConfiguratorAPI()
     self._smtclient = smtclient.get_smtclient()
     self.db = database.FCPDbOperator()
コード例 #17
0
ファイル: test_database.py プロジェクト: wngzhe/feilong
 def setUpClass(cls):
     super(FCPDbOperatorTestCase, cls).setUpClass()
     cls.db_op = database.FCPDbOperator()