~ubuntu-branches/ubuntu/saucy/nova/saucy-proposed

« back to all changes in this revision

Viewing changes to nova/tests/api/openstack/fakes.py

  • Committer: Package Import Robot
  • Author(s): Chuck Short
  • Date: 2012-05-24 13:12:53 UTC
  • mfrom: (1.1.55)
  • Revision ID: package-import@ubuntu.com-20120524131253-ommql08fg1en06ut
Tags: 2012.2~f1-0ubuntu1
* New upstream release.
* Prepare for quantal:
  - Dropped debian/patches/upstream/0006-Use-project_id-in-ec2.cloud._format_image.patch
  - Dropped debian/patches/upstream/0005-Populate-image-properties-with-project_id-again.patch
  - Dropped debian/patches/upstream/0004-Fixed-bug-962840-added-a-test-case.patch
  - Dropped debian/patches/upstream/0003-Allow-unprivileged-RADOS-users-to-access-rbd-volumes.patch
  - Dropped debian/patches/upstream/0002-Stop-libvirt-test-from-deleting-instances-dir.patch
  - Dropped debian/patches/upstream/0001-fix-bug-where-nova-ignores-glance-host-in-imageref.patch 
  - Dropped debian/patches/0001-fix-useexisting-deprecation-warnings.patch
* debian/control: Add python-keystone as a dependency. (LP: #907197)
* debian/patches/kombu_tests_timeout.patch: Refreshed.
* debian/nova.conf, debian/nova-common.postinst: Convert to new ini
  file configuration
* debian/patches/nova-manage_flagfile_location.patch: Refreshed

Show diffs side-by-side

added added

removed removed

Lines of Context:
26
26
 
27
27
from nova.api import auth as api_auth
28
28
from nova.api import openstack as openstack_api
 
29
from nova.api.openstack import auth
29
30
from nova.api.openstack import compute
30
 
from nova.api.openstack import auth
31
31
from nova.api.openstack.compute import limits
 
32
from nova.api.openstack.compute import versions
32
33
from nova.api.openstack import urlmap
33
 
from nova.api.openstack.compute import versions
34
34
from nova.api.openstack import wsgi as os_wsgi
35
35
import nova.auth.manager as auth_manager
36
36
from nova.compute import instance_types
39
39
from nova.db.sqlalchemy import models
40
40
from nova import exception as exc
41
41
import nova.image.fake
 
42
from nova.openstack.common import jsonutils
42
43
from nova.tests import fake_network
43
44
from nova.tests.glance import stubs as glance_stubs
44
45
from nova import utils
77
78
    return self.application
78
79
 
79
80
 
80
 
def wsgi_app(inner_app_v2=None, fake_auth=True, fake_auth_context=None,
 
81
def wsgi_app(inner_app_v2=None, fake_auth_context=None,
81
82
        use_no_auth=False, ext_mgr=None):
82
83
    if not inner_app_v2:
83
84
        inner_app_v2 = compute.APIRouter(ext_mgr)
84
85
 
85
 
    if fake_auth:
 
86
    if use_no_auth:
 
87
        api_v2 = openstack_api.FaultWrapper(auth.NoAuthMiddleware(
 
88
              limits.RateLimitingMiddleware(inner_app_v2)))
 
89
    else:
86
90
        if fake_auth_context is not None:
87
91
            ctxt = fake_auth_context
88
92
        else:
89
93
            ctxt = context.RequestContext('fake', 'fake', auth_token=True)
90
94
        api_v2 = openstack_api.FaultWrapper(api_auth.InjectContext(ctxt,
91
95
              limits.RateLimitingMiddleware(inner_app_v2)))
92
 
    elif use_no_auth:
93
 
        api_v2 = openstack_api.FaultWrapper(auth.NoAuthMiddleware(
94
 
              limits.RateLimitingMiddleware(inner_app_v2)))
95
 
    else:
96
 
        api_v2 = openstack_api.FaultWrapper(auth.AuthMiddleware(
97
 
              limits.RateLimitingMiddleware(inner_app_v2)))
98
96
 
99
97
    mapper = urlmap.URLMap()
100
98
    mapper['/v2'] = api_v2
131
129
        lambda: nova.image.fake.FakeImageService())
132
130
 
133
131
 
134
 
def stub_out_auth(stubs):
135
 
    def fake_auth_init(self, app):
136
 
        self.application = app
137
 
 
138
 
    stubs.Set(auth.AuthMiddleware,
139
 
        '__init__', fake_auth_init)
140
 
    stubs.Set(auth.AuthMiddleware,
141
 
        '__call__', fake_wsgi)
142
 
 
143
 
 
144
132
def stub_out_rate_limiting(stubs):
145
133
    def fake_rate_init(self, app):
146
134
        super(limits.RateLimitingMiddleware, self).__init__(app)
477
465
        return {"info_cache": {"network_info": nw_cache}}
478
466
 
479
467
    if not isinstance(nw_cache, basestring):
480
 
        nw_cache = utils.dumps(nw_cache)
 
468
        nw_cache = jsonutils.dumps(nw_cache)
481
469
 
482
470
    return {"info_cache": {"network_info": nw_cache}}
483
471
 
605
593
        'host': 'fakehost',
606
594
        'size': 1,
607
595
        'availability_zone': 'fakeaz',
608
 
        'instance': {'uuid': 'fakeuuid'},
 
596
        'instance_uuid': 'fakeuuid',
609
597
        'mountpoint': '/',
610
598
        'status': 'fakestatus',
611
599
        'attach_status': 'attached',
624
612
 
625
613
def stub_volume_create(self, context, size, name, description, snapshot,
626
614
                       **param):
627
 
    vol = stub_volume(1)
 
615
    vol = stub_volume('1')
628
616
    vol['size'] = size
629
617
    vol['display_name'] = name
630
618
    vol['display_description'] = description
653
641
 
654
642
 
655
643
def stub_volume_get_all(self, context, search_opts=None):
656
 
    return [stub_volume_get(self, context, 1)]
 
644
    return [stub_volume_get(self, context, '1')]