1
# Copyright 2012 OpenStack LLC.
4
# Licensed under the Apache License, Version 2.0 (the "License"); you may
5
# not use this file except in compliance with the License. You may obtain
6
# a copy of the License at
8
# http://www.apache.org/licenses/LICENSE-2.0
10
# Unless required by applicable law or agreed to in writing, software
11
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
12
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
13
# License for the specific language governing permissions and limitations
18
from nova.api.openstack.compute.contrib import config_drive
20
from nova.openstack.common import jsonutils
22
from nova.tests.api.openstack import fakes
23
import nova.tests.image.fake
26
class ConfigDriveTest(test.TestCase):
29
super(ConfigDriveTest, self).setUp()
30
self.Controller = config_drive.Controller()
31
fakes.stub_out_networking(self.stubs)
32
fakes.stub_out_rate_limiting(self.stubs)
33
nova.tests.image.fake.stub_out_image_service(self.stubs)
36
self.stubs.Set(db, 'instance_get',
37
fakes.fake_instance_get())
38
req = webob.Request.blank('/v2/fake/servers/1')
39
req.headers['Content-Type'] = 'application/json'
40
response = req.get_response(fakes.wsgi_app())
41
self.assertEquals(response.status_int, 200)
42
res_dict = jsonutils.loads(response.body)
43
self.assertTrue('config_drive' in res_dict['server'])
45
def test_detail_servers(self):
46
self.stubs.Set(db, 'instance_get',
47
fakes.fake_instance_get())
48
req = fakes.HTTPRequest.blank('/v2/fake/servers/detail')
49
res = req.get_response(fakes.wsgi_app())
50
server_dicts = jsonutils.loads(res.body)['servers']
51
for server_dict in server_dicts:
52
self.asserTrue('config_drive' in server_dict)