Esempio n. 1
0
 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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)
Esempio n. 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')
Esempio n. 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)
Esempio n. 7
0
    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)