Class: Fog::NFV::HuaweiCloud::Mock
- Inherits:
-
Object
- Object
- Fog::NFV::HuaweiCloud::Mock
- Includes:
- HuaweiCloud::Core
- Defined in:
- lib/fog/nfv/huaweicloud.rb,
lib/fog/nfv/huaweicloud/requests/get_vnf.rb,
lib/fog/nfv/huaweicloud/requests/get_vnfd.rb,
lib/fog/nfv/huaweicloud/requests/list_vnfs.rb,
lib/fog/nfv/huaweicloud/requests/create_vnf.rb,
lib/fog/nfv/huaweicloud/requests/delete_vnf.rb,
lib/fog/nfv/huaweicloud/requests/list_vnfds.rb,
lib/fog/nfv/huaweicloud/requests/update_vnf.rb,
lib/fog/nfv/huaweicloud/requests/create_vnfd.rb,
lib/fog/nfv/huaweicloud/requests/delete_vnfd.rb
Class Method Summary collapse
Instance Method Summary collapse
- #create_vnf(_) ⇒ Object
- #create_vnfd(_) ⇒ Object
- #data ⇒ Object
- #delete_vnf(_vnf_id) ⇒ Object
- #delete_vnfd(_vnfd_id) ⇒ Object
- #get_vnf(_vnf_id) ⇒ Object
- #get_vnfd(_vnfd_id) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_vnfds(_options = {}) ⇒ Object
- #list_vnfs(_options = {}) ⇒ Object
- #reset_data ⇒ Object
- #update_vnf(_, _) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
82 83 84 85 86 87 |
# File 'lib/fog/nfv/huaweicloud.rb', line 82 def initialize( = {}) @auth_token = Fog::Mock.random_base64(64) @auth_token_expiration = (Time.now.utc + 86_400).iso8601 initialize_identity end |
Class Method Details
.data ⇒ Object
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 |
# File 'lib/fog/nfv/huaweicloud.rb', line 45 def self.data @data ||= Hash.new do |hash, key| hash[key] = { :vnfs => [ { "status" => "ACTIVE", "description" => "demo-example", "tenant_id" => "943b6ff8229a4ec2bed0a306f869a0ea", "instance_id" => "5a9a7d3b-24f5-4226-8d43-262972a1776e", "mgmt_url" => "{\"vdu1\": \"192.168.0.8\"}", "attributes" => {"monitoring_policy" => "{\"vdus\": {}}"}, "id" => "cb4cdbd8-cf1a-4758-8d36-40db788a37a1", "name" => "LadasTest" } ], :vnfds => [ { "service_types" => [{"service_type" => "vnfd", "id" => "f9211d81-b58a-4849-8d38-e25376c421bd"}], "description" => "demo-example", "tenant_id" => "943b6ff8229a4ec2bed0a306f869a0ea", "mgmt_driver" => "noop", "infra_driver" => "heat", "attributes" => {"vnfd" => "template_name: sample-vnfd"}, "id" => "1f8f33cf-8c94-427e-a040-f3e393b773b7", "name" => "sample-vnfd" } ] } end end |
.reset ⇒ Object
76 77 78 |
# File 'lib/fog/nfv/huaweicloud.rb', line 76 def self.reset @data = nil end |
Instance Method Details
#create_vnf(_) ⇒ Object
26 27 28 29 30 31 32 33 |
# File 'lib/fog/nfv/huaweicloud/requests/create_vnf.rb', line 26 def create_vnf(_) response = Excon::Response.new response.status = 201 create_data = data[:vnfs].first.merge("vnfd_id" => "id") response.body = {"vnf" => create_data} response end |
#create_vnfd(_) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fog/nfv/huaweicloud/requests/create_vnfd.rb', line 26 def create_vnfd(_) response = Excon::Response.new response.status = 201 response.body = {"vnfd" => data[:vnfds].first} response end |
#data ⇒ Object
89 90 91 |
# File 'lib/fog/nfv/huaweicloud.rb', line 89 def data self.class.data[@huaweicloud_username] end |
#delete_vnf(_vnf_id) ⇒ Object
15 16 17 18 19 |
# File 'lib/fog/nfv/huaweicloud/requests/delete_vnf.rb', line 15 def delete_vnf(_vnf_id) response = Excon::Response.new response.status = 204 response end |
#delete_vnfd(_vnfd_id) ⇒ Object
15 16 17 18 19 |
# File 'lib/fog/nfv/huaweicloud/requests/delete_vnfd.rb', line 15 def delete_vnfd(_vnfd_id) response = Excon::Response.new response.status = 204 response end |
#get_vnf(_vnf_id) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/nfv/huaweicloud/requests/get_vnf.rb', line 15 def get_vnf(_vnf_id) response = Excon::Response.new response.status = 200 response.body = {"vnf" => data[:vnfs].first} response end |
#get_vnfd(_vnfd_id) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/nfv/huaweicloud/requests/get_vnfd.rb', line 15 def get_vnfd(_vnfd_id) response = Excon::Response.new response.status = 200 response.body = {"vnfd" => data[:vnfds].first} response end |
#list_vnfds(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/nfv/huaweicloud/requests/list_vnfds.rb', line 16 def list_vnfds( = {}) response = Excon::Response.new response.status = 200 response.body = {"vnfds" => data[:vnfds]} response end |
#list_vnfs(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/nfv/huaweicloud/requests/list_vnfs.rb', line 16 def list_vnfs( = {}) response = Excon::Response.new response.status = 200 response.body = {"vnfs" => data[:vnfs]} response end |
#reset_data ⇒ Object
93 94 95 |
# File 'lib/fog/nfv/huaweicloud.rb', line 93 def reset_data self.class.data.delete(@huaweicloud_username) end |
#update_vnf(_, _) ⇒ Object
26 27 28 29 30 31 |
# File 'lib/fog/nfv/huaweicloud/requests/update_vnf.rb', line 26 def update_vnf(_, _) response = Excon::Response.new response.status = 200 response.body = {"vnf" => data[:vnfs].first} response end |