Example #1
0
    def test_private_url(self):
        ns = Namespace(name='namespace', data=self.valid_data)
        ns.data['nsName'] = 'nsName'
        ns.state.set('actions', 'install', 'ok')
        ns.api = MagicMock()
        ns._zerodb.schedule_action = MagicMock(return_value=task_mock('url'))

        assert ns.private_url() == 'url'
        ns._zerodb.schedule_action.assert_called_once_with(
            'namespace_private_url', args={'name': 'nsName'})
Example #2
0
 def test_connection_info(self):
     ns = Namespace(name='namespace', data=self.valid_data)
     ns.state.set('actions', 'install', 'ok')
     ns.state.set('status', 'running', 'ok')
     ns.api = MagicMock()
     result = {'ip': '127.0.0.1', 'port': 9900}
     task = task_mock(result)
     ns._zerodb.schedule_action = MagicMock(return_value=task)
     assert ns.connection_info() == result
     ns._zerodb.schedule_action.assert_called_once_with('connection_info')
Example #3
0
    def test_info(self):
        ns = Namespace(name='namespace', data=self.valid_data)
        ns.data['nsName'] = 'nsName'
        ns.state.set('actions', 'install', 'ok')
        ns.api = MagicMock()
        task = task_mock('info')
        ns._zerodb.schedule_action = MagicMock(return_value=task)

        assert ns.info() == 'info'
        ns._zerodb.schedule_action.assert_called_once_with(
            'namespace_info', args={'name': ns.data['nsName']})
Example #4
0
    def test_private_url(self):
        vdisk = Vdisk(name='vdisk', data=self.valid_data)
        vdisk.data['nsName'] = 'ns_name'
        vdisk.state.set('actions', 'install', 'ok')
        vdisk.api = MagicMock()
        vdisk._zerodb.schedule_action = MagicMock(
            return_value=task_mock('url'))

        assert vdisk.private_url() == 'url'
        vdisk._zerodb.schedule_action.assert_called_once_with(
            'namespace_private_url', args={'name': 'ns_name'})
Example #5
0
    def test_info(self):
        vdisk = Vdisk(name='vdisk', data=self.valid_data)
        vdisk.data['nsName'] = 'ns_name'
        vdisk.state.set('actions', 'install', 'ok')
        vdisk.api = MagicMock()
        task = task_mock('info')
        vdisk._zerodb.schedule_action = MagicMock(return_value=task)

        assert vdisk.info() == 'info'
        vdisk._zerodb.schedule_action.assert_called_once_with(
            'namespace_info', args={'name': vdisk.data['nsName']})
Example #6
0
 def test_install(self):
     vdisk = Vdisk(name='vdisk', data=self.valid_data)
     node = MagicMock()
     node.schedule_action = MagicMock(return_value=task_mock(('instance',
                                                              'ns_name')))
     vdisk.api = MagicMock()
     vdisk.api.services.get = MagicMock(return_value=node)
     vdisk.install()
     args = {
         'disktype': vdisk.data['diskType'].upper(),
         'mode': 'user',
         'password': vdisk.data['password'],
         'public': False,
         'size': int(vdisk.data['size']),
     }
     node.schedule_action.assert_called_once_with('create_zdb_namespace',
                                                  args)
     vdisk.state.check('actions', 'install', 'ok')
     assert vdisk.data['nsName'] == 'ns_name'
     assert vdisk.data['zerodb'] == 'instance'
Example #7
0
    def test_install(self):
        ns = Namespace(name='namespace', data=self.valid_data)
        node = MagicMock()
        node.schedule_action = MagicMock(return_value=task_mock(('instance',
                                                                 'nsName')))
        ns.api = MagicMock()
        ns.api.services.get = MagicMock(return_value=node)
        args = {
            'disktype': ns.data['diskType'].upper(),
            'mode': ns.data['mode'],
            'password': ns.data['password'],
            'public': ns.data['public'],
            'size': ns.data['size'],
            'name': ns.data['nsName']
        }
        ns.install()

        node.schedule_action.assert_called_once_with('create_zdb_namespace',
                                                     args)
        ns.state.check('actions', 'install', 'ok')
        assert ns.data['nsName'] == 'nsName'
        assert ns.data['zerodb'] == 'instance'