~markmc/nova/flat-dhcp-without-bridge-iface

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/contrib/test_virtual_interfaces.py

  • Committer: Tarmac
  • Author(s): Ryu Ishimoto, Dan Wendlandt
  • Date: 2011-08-19 08:54:49 UTC
  • mfrom: (1360.7.18 nova-quantum-vifid)
  • Revision ID: tarmac-20110819085449-g5rs3tfsdhumopsr
Added uuid column in virtual_interfaces table, and an OpenStack extension API for virtual interfaces to expose these IDs.  Also set this UUID as one of the external IDs in the OVS vif driver.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Copyright (C) 2011 Midokura KK
 
2
# All Rights Reserved.
 
3
#
 
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
 
7
#
 
8
#         http://www.apache.org/licenses/LICENSE-2.0
 
9
#
 
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
 
14
#    under the License.
 
15
 
 
16
import json
 
17
import stubout
 
18
import webob
 
19
 
 
20
from nova import test
 
21
from nova import compute
 
22
from nova.tests.api.openstack import fakes
 
23
from nova.api.openstack.contrib.virtual_interfaces import \
 
24
    ServerVirtualInterfaceController
 
25
 
 
26
 
 
27
def compute_api_get(self, context, server_id):
 
28
    return {'virtual_interfaces': [
 
29
                {'uuid': '00000000-0000-0000-0000-00000000000000000',
 
30
                 'address': '00-00-00-00-00-00'},
 
31
                {'uuid': '11111111-1111-1111-1111-11111111111111111',
 
32
                 'address': '11-11-11-11-11-11'}]}
 
33
 
 
34
 
 
35
class ServerVirtualInterfaceTest(test.TestCase):
 
36
 
 
37
    def setUp(self):
 
38
        super(ServerVirtualInterfaceTest, self).setUp()
 
39
        self.controller = ServerVirtualInterfaceController()
 
40
        self.stubs.Set(compute.api.API, "get", compute_api_get)
 
41
 
 
42
    def tearDown(self):
 
43
        super(ServerVirtualInterfaceTest, self).tearDown()
 
44
 
 
45
    def test_get_virtual_interfaces_list(self):
 
46
        req = webob.Request.blank('/v1.1/servers/1/os-virtual-interfaces')
 
47
        res = req.get_response(fakes.wsgi_app())
 
48
        self.assertEqual(res.status_int, 200)
 
49
        res_dict = json.loads(res.body)
 
50
        response = {'virtual_interfaces': [
 
51
                        {'id': '00000000-0000-0000-0000-00000000000000000',
 
52
                         'mac_address': '00-00-00-00-00-00'},
 
53
                        {'id': '11111111-1111-1111-1111-11111111111111111',
 
54
                         'mac_address': '11-11-11-11-11-11'}]}
 
55
        self.assertEqual(res_dict, response)