diff options
author | Jason Koelker <jason@koelker.net> | 2011-09-20 16:13:12 -0500 |
---|---|---|
committer | Jason Kölker <jason@koelker.net> | 2011-09-25 12:24:52 -0500 |
commit | 8be1c68f809b55088c1ad00ef86cb13b0103aab0 (patch) | |
tree | 7d5a5be076d679d70d84b2afcbf73828b17e6d50 /nova/tests/api/openstack/fakes.py | |
parent | bca7dd3e1d8bec758faf511338617f6d4121e0b8 (diff) | |
download | nova-8be1c68f809b55088c1ad00ef86cb13b0103aab0.tar.gz |
* Rework osapi to use network API not FK backref
* Fixes lp854585
Change-Id: I270794a08a1bfafe7af427cd31f1f60df1faa4ba
Diffstat (limited to 'nova/tests/api/openstack/fakes.py')
-rw-r--r-- | nova/tests/api/openstack/fakes.py | 42 |
1 files changed, 35 insertions, 7 deletions
diff --git a/nova/tests/api/openstack/fakes.py b/nova/tests/api/openstack/fakes.py index 3a567f0cc4..a1c956324a 100644 --- a/nova/tests/api/openstack/fakes.py +++ b/nova/tests/api/openstack/fakes.py @@ -15,16 +15,11 @@ # License for the specific language governing permissions and limitations # under the License. -import copy -import random -import string - import webob import webob.dec from paste import urlmap from glance import client as glance_client -from glance.common import exception as glance_exc from nova import context from nova import exception as exc @@ -39,8 +34,6 @@ from nova.api.openstack import versions from nova.api.openstack import limits from nova.auth.manager import User, Project import nova.image.fake -from nova.image import glance -from nova.tests import fake_flags from nova.tests.glance import stubs as glance_stubs @@ -177,6 +170,41 @@ def stub_out_compute_api_backup(stubs): stubs.Set(nova.compute.API, 'backup', backup) +def stub_out_nw_api_get_instance_nw_info(stubs, func=None): + def get_instance_nw_info(self, context, instance): + return [(None, {'label': 'public', + 'ips': [{'ip': '192.168.0.3'}], + 'ip6s': []})] + + if func is None: + func = get_instance_nw_info + stubs.Set(nova.network.API, 'get_instance_nw_info', func) + + +def stub_out_nw_api_get_floating_ips_by_fixed_address(stubs, func=None): + def get_floating_ips_by_fixed_address(self, context, fixed_ip): + return ['1.2.3.4'] + + if func is None: + func = get_floating_ips_by_fixed_address + stubs.Set(nova.network.API, 'get_floating_ips_by_fixed_address', func) + + +def stub_out_nw_api(stubs, cls=None): + class Fake: + def get_instance_nw_info(*args, **kwargs): + pass + + def get_floating_ips_by_fixed_address(*args, **kwargs): + pass + + if cls is None: + cls = Fake + stubs.Set(nova.network, 'API', cls) + stub_out_nw_api_get_floating_ips_by_fixed_address(stubs) + stub_out_nw_api_get_instance_nw_info(stubs) + + def _make_image_fixtures(): NOW_GLANCE_FORMAT = "2010-10-11T10:30:22" |