|
1 | | - |
2 | | - |
3 | 1 | module Fog |
4 | 2 | module Network |
5 | 3 | class OpenStack < Fog::Service |
@@ -261,187 +259,6 @@ class OpenStack < Fog::Service |
261 | 259 | request :update_quota |
262 | 260 | request :delete_quota |
263 | 261 |
|
264 | | - class Mock |
265 | | - def self.data |
266 | | - @data ||= Hash.new do |hash, key| |
267 | | - qos_policy_id = Fog::UUID.uuid |
268 | | - network_id = Fog::UUID.uuid |
269 | | - extension_id = Fog::UUID.uuid |
270 | | - subnet_id = Fog::UUID.uuid |
271 | | - tenant_id = Fog::Mock.random_hex(8) |
272 | | - |
273 | | - hash[key] = { |
274 | | - :extensions => { |
275 | | - extension_id => { |
276 | | - 'id' => extension_id, |
277 | | - 'alias' => 'dvr', |
278 | | - 'description' => 'Enables configuration of Distributed Virtual Routers.', |
279 | | - 'links' => [], |
280 | | - 'name' => 'Distributed Virtual Router' |
281 | | - } |
282 | | - }, |
283 | | - :networks => { |
284 | | - network_id => { |
285 | | - 'id' => network_id, |
286 | | - 'name' => 'Public', |
287 | | - 'subnets' => [subnet_id], |
288 | | - 'shared' => true, |
289 | | - 'status' => 'ACTIVE', |
290 | | - 'tenant_id' => tenant_id, |
291 | | - 'provider:network:type' => 'vlan', |
292 | | - 'router:external' => false, |
293 | | - 'admin_state_up' => true, |
294 | | - 'qos_policy_id' => qos_policy_id, |
295 | | - 'port_security_enabled' => true |
296 | | - }, |
297 | | - 'e624a36d-762b-481f-9b50-4154ceb78bbb' => { |
298 | | - 'id' => 'e624a36d-762b-481f-9b50-4154ceb78bbb', |
299 | | - 'name' => 'network_1', |
300 | | - 'subnets' => ['2e4ec6a4-0150-47f5-8523-e899ac03026e'], |
301 | | - 'shared' => false, |
302 | | - 'status' => 'ACTIVE', |
303 | | - 'tenant_id' => 'f8b26a6032bc47718a7702233ac708b9', |
304 | | - 'provider:network:type' => 'vlan', |
305 | | - 'router:external' => false, |
306 | | - 'admin_state_up' => true, |
307 | | - 'qos_policy_id' => qos_policy_id, |
308 | | - 'port_security_enabled' => true |
309 | | - } |
310 | | - }, |
311 | | - :ports => {}, |
312 | | - :subnets => { |
313 | | - subnet_id => { |
314 | | - 'id' => subnet_id, |
315 | | - 'name' => "Public", |
316 | | - 'network_id' => network_id, |
317 | | - 'cidr' => "192.168.0.0/22", |
318 | | - 'ip_version' => 4, |
319 | | - 'gateway_ip' => Fog::Mock.random_ip, |
320 | | - 'allocation_pools' => [], |
321 | | - 'dns_nameservers' => [Fog::Mock.random_ip, Fog::Mock.random_ip], |
322 | | - 'host_routes' => [Fog::Mock.random_ip], |
323 | | - 'enable_dhcp' => true, |
324 | | - 'tenant_id' => tenant_id, |
325 | | - } |
326 | | - }, |
327 | | - :subnet_pools => {}, |
328 | | - :floating_ips => {}, |
329 | | - :routers => {}, |
330 | | - :lb_pools => {}, |
331 | | - :lb_members => {}, |
332 | | - :lb_health_monitors => {}, |
333 | | - :lb_vips => {}, |
334 | | - :lbaas_loadbalancers => {}, |
335 | | - :lbaas_listeners => {}, |
336 | | - :lbaas_pools => {}, |
337 | | - :lbaas_pool_members => {}, |
338 | | - :lbaas_health_monitorss => {}, |
339 | | - :lbaas_l7policies => {}, |
340 | | - :lbaas_l7rules => {}, |
341 | | - :vpn_services => {}, |
342 | | - :ike_policies => {}, |
343 | | - :ipsec_policies => {}, |
344 | | - :ipsec_site_connections => {}, |
345 | | - :rbac_policies => {}, |
346 | | - :quota => { |
347 | | - "subnet" => 10, |
348 | | - "router" => 10, |
349 | | - "port" => 50, |
350 | | - "network" => 10, |
351 | | - "floatingip" => 50 |
352 | | - }, |
353 | | - :quotas => [ |
354 | | - { |
355 | | - "subnet" => 10, |
356 | | - "network" => 10, |
357 | | - "floatingip" => 50, |
358 | | - "tenant_id" => tenant_id, |
359 | | - "router" => 10, |
360 | | - "port" => 30 |
361 | | - } |
362 | | - ], |
363 | | - :security_groups => {}, |
364 | | - :security_group_rules => {}, |
365 | | - :network_ip_availabilities => [ |
366 | | - { |
367 | | - "network_id" => "4cf895c9-c3d1-489e-b02e-59b5c8976809", |
368 | | - "network_name" => "public", |
369 | | - "subnet_ip_availability" => [ |
370 | | - { |
371 | | - "cidr" => "2001:db8::/64", |
372 | | - "ip_version" => 6, |
373 | | - "subnet_id" => "ca3f46c4-c6ff-4272-9be4-0466f84c6077", |
374 | | - "subnet_name" => "ipv6-public-subnet", |
375 | | - "total_ips" => 18446744073709552000, |
376 | | - "used_ips" => 1 |
377 | | - }, |
378 | | - { |
379 | | - "cidr" => "172.24.4.0/24", |
380 | | - "ip_version" => 4, |
381 | | - "subnet_id" => "cc02efc1-9d47-46bd-bab6-760919c836b5", |
382 | | - "subnet_name" => "public-subnet", |
383 | | - "total_ips" => 253, |
384 | | - "used_ips" => 1 |
385 | | - } |
386 | | - ], |
387 | | - "project_id" => "1a02cc95f1734fcc9d3c753818f03002", |
388 | | - "tenant_id" => "1a02cc95f1734fcc9d3c753818f03002", |
389 | | - "total_ips" => 253, |
390 | | - "used_ips" => 2 |
391 | | - }, |
392 | | - { |
393 | | - "network_id" => "6801d9c8-20e6-4b27-945d-62499f00002e", |
394 | | - "network_name" => "private", |
395 | | - "subnet_ip_availability" => [ |
396 | | - { |
397 | | - "cidr" => "10.0.0.0/24", |
398 | | - "ip_version" => 4, |
399 | | - "subnet_id" => "44e70d00-80a2-4fb1-ab59-6190595ceb61", |
400 | | - "subnet_name" => "private-subnet", |
401 | | - "total_ips" => 253, |
402 | | - "used_ips" => 2 |
403 | | - }, |
404 | | - { |
405 | | - "ip_version" => 6, |
406 | | - "cidr" => "fdbf:ac66:9be8::/64", |
407 | | - "subnet_id" => "a90623df-00e1-4902-a675-40674385d74c", |
408 | | - "subnet_name" => "ipv6-private-subnet", |
409 | | - "total_ips" => 18446744073709552000, |
410 | | - "used_ips" => 2 |
411 | | - } |
412 | | - ], |
413 | | - "project_id" => "d56d3b8dd6894a508cf41b96b522328c", |
414 | | - "tenant_id" => "d56d3b8dd6894a508cf41b96b522328c", |
415 | | - "total_ips" => 18446744073709552000, |
416 | | - "used_ips" => 4 |
417 | | - } |
418 | | - ] |
419 | | - } |
420 | | - end |
421 | | - end |
422 | | - |
423 | | - def self.reset |
424 | | - @data = nil |
425 | | - end |
426 | | - |
427 | | - include Fog::OpenStack::Core |
428 | | - |
429 | | - def initialize(options = {}) |
430 | | - @auth_token = Fog::Mock.random_base64(64) |
431 | | - @auth_token_expiration = (Time.now.utc + 86400).iso8601 |
432 | | - |
433 | | - initialize_identity options |
434 | | - end |
435 | | - |
436 | | - def data |
437 | | - self.class.data["#{@openstack_username}-#{@openstack_tenant}"] |
438 | | - end |
439 | | - |
440 | | - def reset_data |
441 | | - self.class.data.delete("#{@openstack_username}-#{@openstack_tenant}") |
442 | | - end |
443 | | - end |
444 | | - |
445 | 262 | class Real |
446 | 263 | include Fog::OpenStack::Core |
447 | 264 |
|
|
0 commit comments