Coverage for manila/tests/share/drivers/container/fakes.py: 100%
51 statements
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
« prev ^ index » next coverage.py v7.11.0, created at 2026-02-18 22:19 +0000
1# Copyright 2016 Mirantis, Inc.
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"""Some useful fakes."""
17from manila.tests.db import fakes as db_fakes
19FAKE_VSCTL_LIST_INTERFACES_X = (
20 'fake stuff\n'
21 'foo not_a_veth something_fake bar\n'
22 'foo veth11b2c34 something_fake bar\n'
23 'foo veth25f6g7h manila-container="fake1" bar\n'
24 'foo veth3jd83j7 manila-container="my_container" bar\n'
25 'foo veth4i9j10k manila-container="fake2" bar\n'
26 'more fake stuff\n'
27)
29FAKE_VSCTL_LIST_INTERFACES = (
30 'fake stuff\n'
31 'foo not_a_veth something_fake bar\n'
32 'foo veth11b2c34 something_fake bar\n'
33 'foo veth25f6g7h manila-container="fake1" bar\n'
34 'foo veth3jd83j7 manila-container="manila_my_container" bar\n'
35 'foo veth4i9j10k manila-container="fake2" bar\n'
36 'more fake stuff\n'
37)
39FAKE_VSCTL_LIST_INTERFACE_1 = (
40 'fake stuff\n'
41 'foo veth11b2c34 something_fake bar\n'
42 'more fake stuff\n'
43)
45FAKE_VSCTL_LIST_INTERFACE_2 = (
46 'fake stuff\n'
47 'foo veth25f6g7h manila-container="fake1" bar\n'
48 'more fake stuff\n'
49)
51FAKE_VSCTL_LIST_INTERFACE_3_X = (
52 'fake stuff\n'
53 'foo veth3jd83j7 manila-container="my_container" bar\n'
54 'more fake stuff\n'
55)
57FAKE_VSCTL_LIST_INTERFACE_3 = (
58 'fake stuff\n'
59 'foo veth3jd83j7 manila-container="manila_my_container" bar\n'
60 'more fake stuff\n'
61)
63FAKE_VSCTL_LIST_INTERFACE_4 = (
64 'fake stuff\n'
65 'foo veth4i9j10k manila-container="fake2" bar\n'
66 'more fake stuff\n'
67)
69FAKE_IP_LINK_SHOW = (
70 ('1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN '
71 'mode DEFAULT group default qlen 1000\\ link/loopback '
72 '00:00:00:00:00:00 brd 00:00:00:00:00:00\n'
73 '13: eth0@if16: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue '
74 'state UP mode DEFAULT group default \\ link/ether 02:42:ac:15:00:02 '
75 'brd ff:ff:ff:ff:ff:ff\n'
76 '15: eth1@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue '
77 'state UP mode DEFAULT group default \\ link/ether 02:42:ac:14:00:02 '
78 'brd ff:ff:ff:ff:ff:ff\n', '')
79)
81FAKE_IP_LINK_SHOW_MASTER = (
82 ('16: fake_veth@if14: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc '
83 'noqueue master br-a7d71c3e77c2 state UP mode DEFAULT group default\n'
84 ' link/ether 4a:10:0c:f2:d2:2c brd ff:ff:ff:ff:ff:ff link-netnsid 0\n',
85 '')
86)
88FAKE_IP_ADDR_SHOW = (
89 [('283: eth0 inet 192.168.144.19/24 brd 192.168.144.255 scope global '
90 'eth0\\ valid_lft forever preferred_lft forever', ''),
91 ('287: eth1 inet 10.0.0.131/8 brd 8.255.255.255 scope global eth1\\ '
92 ' valid_lft forever preferred_lft forever', '')]
93)
95FAKE_DOCKER_INSPECT_NETWORKS = (
96 ('{"fake_docker_network_0":{"IPAMConfig":{},"Links":null,"Aliases":'
97 '["dab16d2703dc"],"NetworkID":'
98 '"cf8c7cb5cecda1ef8240921d5d09e2a1bf9e308a0261459f5a69114cd4e6283c",'
99 '"EndpointID":'
100 '"312a035f32be713c7b56093dde2beec950785ddeb29c9bd18018d43ffd4f64bd",'
101 '"Gateway":"10.10.10.1","IPAddress":"10.10.10.10","IPPrefixLen":24,'
102 '"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,'
103 '"MacAddress":"10:10:10:10:10:10","DriverOpts":{}},'
104 '"fake_docker_network_1":{"IPAMConfig":{},"Links":null,"Aliases":'
105 '["dab16d2703dc"],"NetworkID":'
106 '"e978d91d70c30695557018c8847a551267e99c083063391c07dc9a730bfef9dc",'
107 '"EndpointID":'
108 '"8e34044764cd52b9d092ac66af8fb7130cdd423b521c3bf6e57b8095f6f0a085",'
109 '"Gateway":"20.20.20.1","IPAddress":"20.20.20.20","IPPrefixLen":24,'
110 '"IPv6Gateway":"","GlobalIPv6Address":"","GlobalIPv6PrefixLen":0,'
111 '"MacAddress":"20:20:20:20:20:20","DriverOpts":{}}}', '')
112)
115def fake_share(**kwargs):
116 share = {
117 'id': 'fakeid',
118 'share_id': 'fakeshareid',
119 'name': 'fakename',
120 'size': 1,
121 'share_proto': 'NFS',
122 'host': 'host@backend#vg',
123 'export_location': '127.0.0.1:/mnt/nfs/volume-00002',
124 }
125 share.update(kwargs)
126 return db_fakes.FakeModel(share)
129def fake_share_instances(**kwargs):
130 share_instances = {
131 'id': 'fakeid',
132 'share_id': 'fakeshareid',
133 'host': 'host@backend#vg',
134 'export_location': '127.0.0.1:/mnt/nfs/volume-00002',
135 }
136 share_instances.update(kwargs)
137 return [db_fakes.FakeModel(share_instances)]
140def fake_access(**kwargs):
141 access = {
142 'id': 'fakeaccid',
143 'access_type': 'ip',
144 'access_to': '10.0.0.2',
145 'access_level': 'rw',
146 'state': 'active',
147 }
148 access.update(kwargs)
149 return db_fakes.FakeModel(access)
152def fake_network(**kwargs):
153 allocations = db_fakes.FakeModel({'id': 'fake_allocation_id',
154 'ip_address': '127.0.0.0.1',
155 'mac_address': 'fe:16:3e:61:e0:58'})
156 network = {
157 'id': 'fake_network_id',
158 'server_id': 'fake_server_id',
159 'network_allocations': [allocations],
160 'neutron_net_id': 'fake_net',
161 'neutron_subnet_id': 'fake_subnet'
162 }
163 network.update(kwargs)
164 return [db_fakes.FakeModel(network)]
167def fake_network_with_security_services(**kwargs):
168 allocations = db_fakes.FakeModel({'id': 'fake_allocation_id',
169 'ip_address': '127.0.0.0.1',
170 'mac_address': 'fe:16:3e:61:e0:58'})
171 security_services = db_fakes.FakeModel({'status': 'fake_status',
172 'id': 'fake_security_service_id',
173 'project_id': 'fake_project_id',
174 'type': 'fake_type',
175 'name': 'fake_name'})
176 network = {
177 'id': 'fake_network_id',
178 'server_id': 'fake_server_id',
179 'network_allocations': [allocations],
180 'neutron_net_id': 'fake_net',
181 'neutron_subnet_id': 'fake_subnet',
182 'security_services': [security_services],
183 }
184 network.update(kwargs)
185 return [db_fakes.FakeModel(network)]
188def fake_share_server(**kwargs):
189 share_server = {
190 'id': 'fake'
191 }
192 share_server.update(kwargs)
193 return db_fakes.FakeModel(share_server)
196def fake_identifier():
197 return '7cf7c200-d3af-4e05-b87e-9167c95dfcad'
200def fake_share_no_export_location(**kwargs):
201 share = {
202 'share_id': 'fakeshareid',
203 }
204 share.update(kwargs)
205 return db_fakes.FakeModel(share)
208def fake_current_network_allocations():
209 current_network_allocations = {
210 'subnets': [
211 {
212 'network_allocations': [
213 {
214 'id': 'fake_id_current',
215 'ip_address': '192.168.144.100',
216 }
217 ]
218 }
219 ]
220 }
222 return current_network_allocations
225def fake_new_network_allocations():
226 new_network_allocations = {
227 'network_allocations': [
228 {
229 'id': 'fake_id_new',
230 'ip_address': '10.0.0.100',
231 }
232 ]
233 }
235 return new_network_allocations