/usr/lib/python2.7/dist-packages/novaclient/tests/unit/v2/contrib/fakes.py is in python-novaclient 2:6.0.0-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 | # Copyright 2012 OpenStack Foundation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from novaclient.tests.unit.v2 import fakes
from novaclient.v2 import client
FAKE_REQUEST_ID_LIST = fakes.FAKE_REQUEST_ID_LIST
FAKE_RESPONSE_HEADERS = fakes.FAKE_RESPONSE_HEADERS
class FakeClient(fakes.FakeClient):
def __init__(self, *args, **kwargs):
client.Client.__init__(self, 'username', 'password',
'project_id', 'auth_url',
extensions=kwargs.get('extensions'),
direct_use=False)
self.client = FakeHTTPClient(**kwargs)
class FakeHTTPClient(fakes.FakeHTTPClient):
def get_os_tenant_networks(self):
return (200, FAKE_RESPONSE_HEADERS, {
'networks': [{"label": "1", "cidr": "10.0.0.0/24",
'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
'id': '1'}]})
def get_os_tenant_networks_1(self, **kw):
return (200, FAKE_RESPONSE_HEADERS, {
'network': {"label": "1", "cidr": "10.0.0.0/24",
'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
'id': '1'}})
def post_os_tenant_networks(self, **kw):
return (201, FAKE_RESPONSE_HEADERS, {
'network': {"label": "1", "cidr": "10.0.0.0/24",
'project_id': '4ffc664c198e435e9853f2538fbcd7a7',
'id': '1'}})
def delete_os_tenant_networks_1(self, **kw):
return (204, FAKE_RESPONSE_HEADERS, None)
def get_os_baremetal_nodes(self, **kw):
return (
200, FAKE_RESPONSE_HEADERS, {
'nodes': [
{
"id": 1,
"instance_uuid": None,
"interfaces": [],
"cpus": 2,
"local_gb": 10,
"memory_mb": 5,
"pm_address": "2.3.4.5",
"pm_user": "pmuser",
"pm_password": "pmpass",
"prov_mac_address": "aa:bb:cc:dd:ee:ff",
"prov_vlan_id": 1,
"service_host": "somehost",
"terminal_port": 8080,
}
]
}
)
def get_os_baremetal_nodes_1(self, **kw):
return (
200, FAKE_RESPONSE_HEADERS, {
'node': {
"id": 1,
"instance_uuid": None,
"pm_address": "1.2.3.4",
"interfaces": [],
"cpus": 2,
"local_gb": 10,
"memory_mb": 5,
"pm_user": "pmuser",
"pm_password": "pmpass",
"prov_mac_address": "aa:bb:cc:dd:ee:ff",
"prov_vlan_id": 1,
"service_host": "somehost",
"terminal_port": 8080,
}
}
)
def post_os_baremetal_nodes(self, **kw):
return (
200, FAKE_RESPONSE_HEADERS, {
'node': {
"id": 1,
"instance_uuid": None,
"cpus": 2,
"local_gb": 10,
"memory_mb": 5,
"pm_address": "2.3.4.5",
"pm_user": "pmuser",
"pm_password": "pmpass",
"prov_mac_address": "aa:bb:cc:dd:ee:ff",
"prov_vlan_id": 1,
"service_host": "somehost",
"terminal_port": 8080,
}
}
)
def delete_os_baremetal_nodes_1(self, **kw):
return (202, FAKE_RESPONSE_HEADERS, {})
def post_os_baremetal_nodes_1_action(self, **kw):
body = kw['body']
action = list(body)[0]
if action == "add_interface":
return (
200, FAKE_RESPONSE_HEADERS, {
'interface': {
"id": 2,
"address": "bb:cc:dd:ee:ff:aa",
"datapath_id": 1,
"port_no": 2,
}
}
)
elif action == "remove_interface":
return (202, FAKE_RESPONSE_HEADERS, {})
else:
return (500, {}, {})
def post_os_assisted_volume_snapshots(self, **kw):
return (202, FAKE_RESPONSE_HEADERS,
{'snapshot': {'id': 'blah', 'volumeId': '1'}})
def delete_os_assisted_volume_snapshots_x(self, **kw):
return (202, FAKE_RESPONSE_HEADERS, {})
def post_os_server_external_events(self, **kw):
return (200, FAKE_RESPONSE_HEADERS, {
'events': [
{'name': 'test-event',
'status': 'completed',
'tag': 'tag',
'server_uuid': 'fake-uuid1'},
{'name': 'test-event',
'status': 'completed',
'tag': 'tag',
'server_uuid': 'fake-uuid2'}]})
|