Ejemplo n.º 1
0
    def test_attach_volume_to_server(self):
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.check_attach',
                      lambda *a, **k: None)
        self.stub_out('nova.volume.cinder.API.reserve_volume',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out(
            'nova.compute.manager.ComputeManager.attach_volume',
            lambda *a, **k: None)
        self.stub_out(
            'nova.objects.BlockDeviceMapping.get_by_volume_and_instance',
            classmethod(lambda *a, **k: None))

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/os-volume_attachments'
                                 % server_id,
                                 'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs,
                              response, 200)
Ejemplo n.º 2
0
    def test_attach_volume_to_server(self):
        self.stub_out('nova.objects.Service.get_minimum_version',
                      lambda *a, **k: COMPUTE_VERSION_OLD_ATTACH_FLOW)
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.reserve_volume',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out('nova.compute.manager.ComputeManager.attach_volume',
                      lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       self.OLD_VOLUME_ID)
        subs = {'volume_id': volume['id'], 'device': device_name}
        server_id = self._post_server()
        response = self._do_post(
            'servers/%s/os-volume_attachments' % server_id,
            'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs, response,
                              200)
Ejemplo n.º 3
0
    def test_attach_volume_to_server(self):
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.check_attach',
                      lambda *a, **k: None)
        self.stub_out('nova.volume.cinder.API.reserve_volume',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out('nova.compute.manager.ComputeManager.attach_volume',
                      lambda *a, **k: None)
        self.stub_out(
            'nova.objects.BlockDeviceMapping.get_by_volume_and_instance',
            classmethod(lambda *a, **k: None))

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {'volume_id': volume['id'], 'device': device_name}
        server_id = self._post_server()
        response = self._do_post(
            'servers/%s/os-volume_attachments' % server_id,
            'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs, response,
                              200)
Ejemplo n.º 4
0
    def test_attach_volume_to_server_new_flow(self):
        self.stub_out('nova.volume.cinder.is_microversion_supported',
                      lambda *a, **k: None)
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.attachment_create',
                      lambda *a, **k: {'id': uuids.volume})
        self.stub_out('nova.objects.BlockDeviceMapping.save',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out('nova.compute.manager.ComputeManager.attach_volume',
                      lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {'volume_id': volume['id'], 'device': device_name}
        server_id = self._post_server()
        response = self._do_post(
            'servers/%s/os-volume_attachments' % server_id,
            'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs, response,
                              200)
Ejemplo n.º 5
0
    def test_attach_volume_to_server(self):
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.reserve_volume',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out(
            'nova.compute.manager.ComputeManager.attach_volume',
            lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       self.OLD_VOLUME_ID)
        subs = {
            'volume_id': volume['id'],
            'device': device_name
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/os-volume_attachments'
                                 % server_id,
                                 'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs,
                              response, 200)
Ejemplo n.º 6
0
    def test_attach_volume(self):
        bdm = objects.BlockDeviceMapping()
        device_name = '/dev/vdd'
        bdm['device_name'] = device_name
        self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
        self.stubs.Set(cinder.API, 'check_attach', lambda *a, **k: None)
        self.stubs.Set(cinder.API, 'reserve_volume', lambda *a, **k: None)
        self.stubs.Set(compute_manager.ComputeManager,
                       "reserve_block_device_name",
                       lambda *a, **k: bdm)
        self.stubs.Set(compute_manager.ComputeManager,
                       'attach_volume',
                       lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name,
            'disk_bus': 'ide',
            'device_type': 'cdrom'
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/action'
                                 % server_id,
                                 'attach-volume-req', subs)
        self.assertEqual(response.status_code, 202)
        self.assertEqual(response.content, '')
Ejemplo n.º 7
0
    def test_attach_volume_to_server_new_flow(self):
        self.stub_out('nova.volume.cinder.is_microversion_supported',
                      lambda *a, **k: None)
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.attachment_create',
                      lambda *a, **k: {'id': uuids.volume})
        self.stub_out('nova.objects.BlockDeviceMapping.save',
                      lambda *a, **k: None)
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        self.stub_out(
            'nova.compute.manager.ComputeManager.attach_volume',
            lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/os-volume_attachments'
                                 % server_id,
                                 'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs,
                              response, 200)
Ejemplo n.º 8
0
    def test_attach_volume_to_server(self):
        self.stub_out('nova.volume.cinder.API.get', fakes.stub_volume_get)
        self.stub_out('nova.volume.cinder.API.attachment_create',
                      lambda *a, **k: {'id': uuids.volume})
        device_name = '/dev/vdd'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        bdm['delete_on_termination'] = True
        self.stub_out(
            'nova.compute.manager.ComputeManager.reserve_block_device_name',
            lambda *a, **k: bdm)
        # 2.79+ will save the delete_on_termination value on the BDM after
        # reserve_block_device_name "creates" the BDM.
        self.stub_out('nova.objects.BlockDeviceMapping.save',
                      lambda *a, **k: None)
        self.stub_out(
            'nova.compute.manager.ComputeManager.attach_volume',
            lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name
        }
        server_id = self._post_server()
        subs = self._get_vol_attachment_subs(subs)
        response = self._do_post('servers/%s/os-volume_attachments'
                                 % server_id,
                                 'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs,
                              response, 200)
    def test_attach_volume(self):
        bdm = objects.BlockDeviceMapping()
        device_name = '/dev/vdd'
        bdm['device_name'] = device_name
        self.stubs.Set(cinder.API, 'get', fakes.stub_volume_get)
        self.stubs.Set(cinder.API, 'check_attach', lambda *a, **k: None)
        self.stubs.Set(cinder.API, 'reserve_volume', lambda *a, **k: None)
        self.stubs.Set(compute_manager.ComputeManager,
                       "reserve_block_device_name", lambda *a, **k: bdm)
        self.stubs.Set(compute_manager.ComputeManager, 'attach_volume',
                       lambda *a, **k: None)

        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name,
            'disk_bus': 'ide',
            'device_type': 'cdrom'
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/action' % server_id,
                                 'attach-volume-req', subs)
        self.assertEqual(response.status_code, 202)
        self.assertEqual(response.content, '')
Ejemplo n.º 10
0
    def test_attach_volume_to_server(self):
        self.stub_out("nova.volume.cinder.API.get", fakes.stub_volume_get)
        self.stub_out("nova.volume.cinder.API.check_attach", lambda *a, **k: None)
        self.stub_out("nova.volume.cinder.API.reserve_volume", lambda *a, **k: None)
        device_name = "/dev/vdd"
        bdm = objects.BlockDeviceMapping()
        bdm["device_name"] = device_name
        self.stub_out("nova.compute.manager.ComputeManager.reserve_block_device_name", lambda *a, **k: bdm)
        self.stub_out("nova.compute.manager.ComputeManager.attach_volume", lambda *a, **k: None)
        self.stub_out("nova.objects.BlockDeviceMapping.get_by_volume_id", classmethod(lambda *a, **k: None))

        volume = fakes.stub_volume_get(None, context.get_admin_context(), "a26887c6-c47b-4654-abb5-dfadf7d3f803")
        subs = {"volume_id": volume["id"], "device": device_name}
        server_id = self._post_server()
        response = self._do_post("servers/%s/os-volume_attachments" % server_id, "attach-volume-to-server-req", subs)

        self._verify_response("attach-volume-to-server-resp", subs, response, 200)
Ejemplo n.º 11
0
    def test_attach_volume_to_server(self):
        device_name = '/dev/sdb'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name,
            'tag': 'foo',
        }
        server_id = self._post_server()
        response = self._do_post(
            'servers/%s/os-volume_attachments' % server_id,
            'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs, response,
                              200)
Ejemplo n.º 12
0
    def test_attach_volume_to_server(self):
        device_name = '/dev/sdb'
        bdm = objects.BlockDeviceMapping()
        bdm['device_name'] = device_name
        volume = fakes.stub_volume_get(None, context.get_admin_context(),
                                       'a26887c6-c47b-4654-abb5-dfadf7d3f803')
        subs = {
            'volume_id': volume['id'],
            'device': device_name,
            'tag': 'foo',
        }
        server_id = self._post_server()
        response = self._do_post('servers/%s/os-volume_attachments'
                                 % server_id,
                                 'attach-volume-to-server-req', subs)

        self._verify_response('attach-volume-to-server-resp', subs,
                              response, 200)