コード例 #1
0
ファイル: test_lvm.py プロジェクト: JosonYuan/manila
 def test_update_access(self, access_level):
     access_rules = [test_generic.get_fake_access_rule(
         '1.1.1.1', access_level), ]
     add_rules = [test_generic.get_fake_access_rule(
         '2.2.2.2', access_level), ]
     delete_rules = [test_generic.get_fake_access_rule(
         '3.3.3.3', access_level), ]
     self._driver.update_access(self._context, self.share, access_rules,
                                add_rules=add_rules,
                                delete_rules=delete_rules,
                                share_server=self.server)
     (self._driver._helpers[self.share['share_proto']].
         update_access.assert_called_once_with(
             self.server, self.share['name'],
             access_rules, add_rules=add_rules, delete_rules=delete_rules))
コード例 #2
0
ファイル: test_lvm.py プロジェクト: yongwc09/manila
 def test_update_access(self, access_level):
     access_rules = [test_generic.get_fake_access_rule(
         '1.1.1.1', access_level), ]
     add_rules = [test_generic.get_fake_access_rule(
         '2.2.2.2', access_level), ]
     delete_rules = [test_generic.get_fake_access_rule(
         '3.3.3.3', access_level), ]
     self._driver.update_access(self._context, self.share, access_rules,
                                add_rules=add_rules,
                                delete_rules=delete_rules,
                                share_server=self.server)
     (self._driver._helpers[self.share['share_proto']].
         update_access.assert_called_once_with(
             self.server, self.share['name'],
             access_rules, add_rules=add_rules, delete_rules=delete_rules))
コード例 #3
0
ファイル: test_helpers.py プロジェクト: openstack/manila
    def test_update_access_delete_invalid_rule(self,
                                               access_to,
                                               access_level='rw',
                                               access_type='ip'):
        mount_path = '%s:/shares/%s' % (access_to, self.share_name)
        if access_type == 'ip':
            self._helper._get_parsed_address_or_cidr = mock.Mock(
                return_value=access_to)
            not_found_msg = ("exportfs: Could not find '%s' to unexport.\n" %
                             mount_path)
            exc = exception.ProcessExecutionError
            self.mock_object(
                self._helper, '_ssh_exec',
                mock.Mock(side_effect=[(0,
                                        0), exc(stderr=not_found_msg)]))

        delete_rules = [
            test_generic.get_fake_access_rule(access_to, access_level,
                                              access_type),
        ]
        self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')

        self._helper.update_access(self.server, self.share_name, [], [],
                                   delete_rules)

        if access_type == 'ip':
            self._helper._ssh_exec.assert_has_calls([
                mock.call(self.server, ['sudo', 'exportfs']),
                mock.call(self.server, ['sudo', 'exportfs', '-u', mount_path])
            ])
        self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
            self.server)
コード例 #4
0
ファイル: test_helpers.py プロジェクト: vponomaryov/manila
 def test_update_access_recovery_mode(self, access_level):
     expected_mount_options = '%s,no_subtree_check'
     if access_level == const.ACCESS_LEVEL_RW:
         expected_mount_options = ','.join((expected_mount_options,
                                            'no_root_squash'))
     access_rules = [test_generic.get_fake_access_rule(
         '1.1.1.1', access_level), ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self.mock_object(self._helper, 'get_host_list',
                      mock.Mock(return_value=['1.1.1.1']))
     self._helper.update_access(self.server, self.share_name, access_rules,
                                [], [])
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(
             self.server, ['sudo', 'exportfs', '-u',
                           ':'.join([access_rules[0]['access_to'],
                                     local_path])]),
         mock.call(self.server, ['sudo', 'exportfs', '-o',
                                 expected_mount_options % access_level,
                                 ':'.join(['1.1.1.1', local_path])]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)
コード例 #5
0
ファイル: test_helpers.py プロジェクト: stackhpc/manila
 def test_update_access_recovery_mode(self, access_level):
     expected_mount_options = '%s,no_subtree_check'
     if access_level == const.ACCESS_LEVEL_RW:
         expected_mount_options = ','.join(
             (expected_mount_options, 'no_root_squash'))
     access_rules = [
         test_generic.get_fake_access_rule('1.1.1.1', access_level),
     ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self.mock_object(self._helper, 'get_host_list',
                      mock.Mock(return_value=['1.1.1.1']))
     self._helper.update_access(self.server, self.share_name, access_rules,
                                [], [])
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(self.server, [
             'sudo', 'exportfs', '-u', ':'.join(
                 [access_rules[0]['access_to'], local_path])
         ]),
         mock.call(self.server, [
             'sudo', 'exportfs', '-o', expected_mount_options %
             access_level, ':'.join(['1.1.1.1', local_path])
         ]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)
コード例 #6
0
ファイル: test_helpers.py プロジェクト: inspur-storage/manila
    def test_update_access(self):
        access_list = [test_generic.get_fake_access_rule(
            'user1', const.ACCESS_LEVEL_RW, access_type='user'),
            test_generic.get_fake_access_rule(
                'user2', const.ACCESS_LEVEL_RO, access_type='user')]
        self._helper.update_access(self.server_details, self.share_name,
                                   access_list, [], [])

        self._helper._ssh_exec.assert_has_calls([
            mock.call(self.server_details,
                      ['sudo', 'net', 'conf', 'setparm', self.share_name,
                       'valid users', 'user1']),
            mock.call(self.server_details,
                      ['sudo', 'net', 'conf', 'setparm', self.share_name,
                       'read list', 'user2'])
        ])
コード例 #7
0
ファイル: test_helpers.py プロジェクト: vponomaryov/manila
    def test_update_access(self):
        access_list = [test_generic.get_fake_access_rule(
            'user1', const.ACCESS_LEVEL_RW, access_type='user'),
            test_generic.get_fake_access_rule(
                'user2', const.ACCESS_LEVEL_RO, access_type='user')]
        self._helper.update_access(self.server_details, self.share_name,
                                   access_list, [], [])

        self._helper._ssh_exec.assert_has_calls([
            mock.call(self.server_details,
                      ['sudo', 'net', 'conf', 'setparm', self.share_name,
                       'valid users', 'user1']),
            mock.call(self.server_details,
                      ['sudo', 'net', 'conf', 'setparm', self.share_name,
                       'read list', 'user2'])
        ])
コード例 #8
0
 def test_update_access(self, access_level):
     expected_mount_options = '%s,no_subtree_check'
     if access_level == const.ACCESS_LEVEL_RW:
         expected_mount_options = ','.join(
             (expected_mount_options, 'no_root_squash'))
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     exec_result = ' '.join([local_path, '2.2.2.3'])
     self.mock_object(self._helper, '_ssh_exec',
                      mock.Mock(return_value=(exec_result, '')))
     access_rules = [
         test_generic.get_fake_access_rule('1.1.1.1', access_level),
         test_generic.get_fake_access_rule('2.2.2.2', access_level),
         test_generic.get_fake_access_rule('2.2.2.3', access_level)
     ]
     add_rules = [
         test_generic.get_fake_access_rule('2.2.2.2', access_level),
         test_generic.get_fake_access_rule('2.2.2.3', access_level),
         test_generic.get_fake_access_rule('5.5.5.5/24', access_level)
     ]
     delete_rules = [
         test_generic.get_fake_access_rule('3.3.3.3', access_level),
         test_generic.get_fake_access_rule('4.4.4.4', access_level, 'user'),
         test_generic.get_fake_access_rule('6.6.6.6/0', access_level)
     ]
     self._helper.update_access(self.server,
                                self.share_name,
                                access_rules,
                                add_rules=add_rules,
                                delete_rules=delete_rules)
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._helper._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(
             self.server,
             ['sudo', 'exportfs', '-u', ':'.join(['3.3.3.3', local_path])]),
         mock.call(self.server, [
             'sudo', 'exportfs', '-u', ':'.join(
                 ['6.6.6.6/0.0.0.0', local_path])
         ]),
         mock.call(self.server, [
             'sudo', 'exportfs', '-o', expected_mount_options %
             access_level, ':'.join(['2.2.2.2', local_path])
         ]),
         mock.call(self.server, [
             'sudo', 'exportfs', '-o', expected_mount_options %
             access_level, ':'.join(['5.5.5.5/255.255.255.0', local_path])
         ]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_has_calls(
         [mock.call(self.server),
          mock.call(self.server)])
コード例 #9
0
ファイル: test_helpers.py プロジェクト: openstack/manila
 def test_update_access_delete_invalid_rule(self):
     delete_rules = [test_generic.get_fake_access_rule(
         'lala', 'fake_level', access_type='user'), ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self._helper.update_access(self.server, self.share_name, [],
                                [], delete_rules)
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)
コード例 #10
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_wrong_access_level(self):
     access_rules = [
         test_generic.get_fake_access_rule('2.2.2.2',
                                           const.ACCESS_LEVEL_RO),
     ]
     self.assertRaises(exception.InvalidShareAccessLevel,
                       self._helper.update_access, self.server_details,
                       self.share_name, access_rules, [], [])
コード例 #11
0
 def test_update_access(self, access_level):
     expected_mount_options = '%s,no_subtree_check'
     if access_level == const.ACCESS_LEVEL_RW:
         expected_mount_options = ','.join((expected_mount_options,
                                            'no_root_squash'))
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     exec_result = ' '.join([local_path, '2.2.2.3'])
     self.mock_object(self._helper, '_ssh_exec',
                      mock.Mock(return_value=(exec_result, '')))
     access_rules = [
         test_generic.get_fake_access_rule('1.1.1.1', access_level),
         test_generic.get_fake_access_rule('2.2.2.2', access_level),
         test_generic.get_fake_access_rule('2.2.2.3', access_level)]
     add_rules = [
         test_generic.get_fake_access_rule('2.2.2.2', access_level),
         test_generic.get_fake_access_rule('2.2.2.3', access_level)]
     delete_rules = [
         test_generic.get_fake_access_rule('3.3.3.3', access_level),
         test_generic.get_fake_access_rule('4.4.4.4', access_level, 'user')]
     self._helper.update_access(self.server, self.share_name, access_rules,
                                add_rules=add_rules,
                                delete_rules=delete_rules)
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._helper._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(self.server, ['sudo', 'exportfs', '-u',
                                 ':'.join(['3.3.3.3', local_path])]),
         mock.call(self.server, ['sudo', 'exportfs', '-o',
                                 expected_mount_options % access_level,
                                 ':'.join(['2.2.2.2', local_path])]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_has_calls([
         mock.call(self.server), mock.call(self.server)])
コード例 #12
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_exception_level(self):
     access_rules = [
         test_generic.get_fake_access_rule('user1',
                                           'fake_level',
                                           access_type='user'),
     ]
     self.assertRaises(exception.InvalidShareAccessLevel,
                       self._helper.update_access, self.server_details,
                       self.share_name, access_rules, [], [])
コード例 #13
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_exception_type(self):
     access_rules = [
         test_generic.get_fake_access_rule('user1',
                                           const.ACCESS_LEVEL_RW,
                                           access_type='ip')
     ]
     self.assertRaises(exception.InvalidShareAccess,
                       self._helper.update_access, self.server_details,
                       self.share_name, access_rules, [], [])
コード例 #14
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_invalid_type(self):
     access_rules = [
         test_generic.get_fake_access_rule('2.2.2.2',
                                           const.ACCESS_LEVEL_RW,
                                           access_type='fake'),
     ]
     self.assertRaises(exception.InvalidShareAccess,
                       self._helper.update_access, self.server,
                       self.share_name, access_rules, [], [])
コード例 #15
0
ファイル: test_helpers.py プロジェクト: vponomaryov/manila
    def test_update_access(self):
        access_rules = [test_generic.get_fake_access_rule(
            '1.1.1.1', const.ACCESS_LEVEL_RW), ]

        self._helper.update_access(self.server_details, self.share_name,
                                   access_rules, [], [])
        self._helper._ssh_exec.assert_called_once_with(
            self.server_details, ['sudo', 'net', 'conf', 'setparm',
                                  self.share_name, 'hosts allow',
                                  '1.1.1.1'])
コード例 #16
0
ファイル: test_helpers.py プロジェクト: inspur-storage/manila
    def test_update_access(self):
        access_rules = [test_generic.get_fake_access_rule(
            '1.1.1.1', const.ACCESS_LEVEL_RW), ]

        self._helper.update_access(self.server_details, self.share_name,
                                   access_rules, [], [])
        self._helper._ssh_exec.assert_called_once_with(
            self.server_details, ['sudo', 'net', 'conf', 'setparm',
                                  self.share_name, 'hosts allow',
                                  '1.1.1.1'])
コード例 #17
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_delete_invalid_rule(self):
     delete_rules = [
         test_generic.get_fake_access_rule('lala',
                                           'fake_level',
                                           access_type='user'),
     ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self._helper.update_access(self.server, self.share_name, [], [],
                                delete_rules)
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)
コード例 #18
0
ファイル: test_helpers.py プロジェクト: vponomaryov/manila
 def test_update_access_wrong_access_type(self):
     access_rules = [test_generic.get_fake_access_rule(
         '2.2.2.2', const.ACCESS_LEVEL_RW, access_type='fake'), ]
     self.assertRaises(
         exception.InvalidShareAccess,
         self._helper.update_access,
         self.server_details,
         self.share_name,
         access_rules,
         [],
         [])
コード例 #19
0
ファイル: test_helpers.py プロジェクト: vponomaryov/manila
 def test_update_access_exception_level(self):
     access_rules = [test_generic.get_fake_access_rule(
         'user1', 'fake_level', access_type='user'), ]
     self.assertRaises(
         exception.InvalidShareAccessLevel,
         self._helper.update_access,
         self.server_details,
         self.share_name,
         access_rules,
         [],
         [])
コード例 #20
0
ファイル: test_helpers.py プロジェクト: openstack/manila
 def test_update_access_recovery_mode(self, level, ip, expected):
     expected_mount_options = '%s,no_subtree_check,no_root_squash'
     access_rules = [test_generic.get_fake_access_rule(
         ip, level), ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self.mock_object(self._helper, 'get_host_list',
                      mock.Mock(return_value=[ip]))
     self._helper.update_access(self.server, self.share_name, access_rules,
                                [], [])
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(
             self.server, ['sudo', 'exportfs', '-u',
                           ':'.join([expected,
                                     local_path])]),
         mock.call(self.server, ['sudo', 'exportfs', '-o',
                                 expected_mount_options % level,
                                 ':'.join([expected, local_path])]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)
コード例 #21
0
ファイル: test_helpers.py プロジェクト: vast-data/manila
 def test_update_access_recovery_mode(self, level, ip, expected):
     expected_mount_options = '%s,no_subtree_check,no_root_squash'
     access_rules = [
         test_generic.get_fake_access_rule(ip, level),
     ]
     self.mock_object(self._helper, '_sync_nfs_temp_and_perm_files')
     self.mock_object(self._helper, 'get_host_list',
                      mock.Mock(return_value=[ip]))
     self._helper.update_access(self.server, self.share_name, access_rules,
                                [], [])
     local_path = os.path.join(CONF.share_mount_path, self.share_name)
     self._ssh_exec.assert_has_calls([
         mock.call(self.server, ['sudo', 'exportfs']),
         mock.call(
             self.server,
             ['sudo', 'exportfs', '-u', ':'.join([expected, local_path])]),
         mock.call(self.server, [
             'sudo', 'exportfs', '-o', expected_mount_options % level,
             ':'.join([expected, local_path])
         ]),
     ])
     self._helper._sync_nfs_temp_and_perm_files.assert_called_with(
         self.server)