コード例 #1
0
ファイル: test_volumes.py プロジェクト: liunian0o0/nova-1
 def _set_up_controller(self):
     ext_mgr = extensions.ExtensionManager()
     ext_mgr.extensions = {'os-volume-attachment-update'}
     self.attachments = volumes.VolumeAttachmentController(ext_mgr)
     ext_mgr_no_update = extensions.ExtensionManager()
     ext_mgr_no_update.extensions = {}
     self.attachments_no_update = volumes.VolumeAttachmentController(
         ext_mgr_no_update)
コード例 #2
0
    def test_show(self):
        attachments = volumes.VolumeAttachmentController()
        req = webob.Request.blank('/v2/fake/os-volumes/show')
        req.method = 'POST'
        req.body = jsonutils.dumps({})
        req.headers['content-type'] = 'application/json'
        req.environ['nova.context'] = self.context

        result = attachments.show(req, FAKE_UUID, FAKE_UUID_A)
        self.assertEqual(self.expected_show, result)
コード例 #3
0
    def test_delete_vol_not_found(self):
        self.stubs.Set(compute_api.API, 'detach_volume', fake_detach_volume)
        attachments = volumes.VolumeAttachmentController()
        req = webob.Request.blank('/v2/fake/os-volumes/delete')
        req.method = 'POST'
        req.body = jsonutils.dumps({})
        req.headers['content-type'] = 'application/json'
        req.environ['nova.context'] = self.context

        self.assertRaises(exc.HTTPNotFound, attachments.delete, req, FAKE_UUID,
                          FAKE_UUID_C)
コード例 #4
0
    def test_delete(self):
        self.stubs.Set(compute_api.API, 'detach_volume', fake_detach_volume)
        attachments = volumes.VolumeAttachmentController()
        req = webob.Request.blank('/v2/fake/os-volumes/delete')
        req.method = 'POST'
        req.body = jsonutils.dumps({})
        req.headers['content-type'] = 'application/json'
        req.environ['nova.context'] = self.context

        result = attachments.delete(req, FAKE_UUID, FAKE_UUID_A)
        self.assertEqual('202 Accepted', result.status)
コード例 #5
0
 def test_attach_volume(self):
     self.stubs.Set(nova.compute.API, 'attach_volume', fake_attach_volume)
     attachments = volumes.VolumeAttachmentController()
     body = {'volumeAttachment': {'volumeId': FAKE_UUID_A,
                                 'device': '/dev/fake'}}
     req = webob.Request.blank('/v2/fake/os-volumes/attach')
     req.method = 'POST'
     req.body = json.dumps({})
     req.headers['content-type'] = 'application/json'
     req.environ['nova.context'] = self.context
     result = attachments.create(req, FAKE_UUID, body)
     self.assertEqual(result['volumeAttachment']['id'],
         '00000000-aaaa-aaaa-aaaa-000000000000')
コード例 #6
0
 def setUp(self):
     super(VolumeAttachTests, self).setUp()
     self.stubs.Set(db, 'block_device_mapping_get_all_by_instance',
                    fake_bdms_get_all_by_instance)
     self.stubs.Set(compute_api.API, 'get', fake_get_instance)
     self.stubs.Set(cinder.API, 'get', fake_get_volume)
     self.context = context.get_admin_context()
     self.expected_show = {'volumeAttachment':
         {'device': '/dev/fake0',
          'serverId': FAKE_UUID,
          'id': FAKE_UUID_A,
          'volumeId': FAKE_UUID_A
         }}
     self.ext_mgr = extensions.ExtensionManager()
     self.ext_mgr.extensions = {}
     self.attachments = volumes.VolumeAttachmentController(self.ext_mgr)
コード例 #7
0
ファイル: test_volumes.py プロジェクト: zestrada/nova-cs498cc
    def test_attach_volume_bad_id(self):
        self.stubs.Set(compute_api.API, 'attach_volume', fake_attach_volume)
        attachments = volumes.VolumeAttachmentController()

        body = {
            'volumeAttachment': {
                'device': None,
                'volumeId': 'TESTVOLUME',
            }
        }

        req = fakes.HTTPRequest.blank('/v2/fake/os-volumes/attach')
        req.method = 'POST'
        req.content_type = 'application/json'
        req.body = jsonutils.dumps(body)

        self.assertRaises(webob.exc.HTTPBadRequest, attachments.create, req,
                          FAKE_UUID, body)