Class: Fog::OpenStack::Baremetal::Mock
- Inherits:
-
Object
- Object
- Fog::OpenStack::Baremetal::Mock
- Defined in:
- lib/fog/openstack/baremetal.rb,
lib/fog/openstack/baremetal/requests/get_node.rb,
lib/fog/openstack/baremetal/requests/get_port.rb,
lib/fog/openstack/baremetal/requests/get_driver.rb,
lib/fog/openstack/baremetal/requests/list_nodes.rb,
lib/fog/openstack/baremetal/requests/list_ports.rb,
lib/fog/openstack/baremetal/requests/patch_node.rb,
lib/fog/openstack/baremetal/requests/patch_port.rb,
lib/fog/openstack/baremetal/requests/create_node.rb,
lib/fog/openstack/baremetal/requests/create_port.rb,
lib/fog/openstack/baremetal/requests/delete_node.rb,
lib/fog/openstack/baremetal/requests/delete_port.rb,
lib/fog/openstack/baremetal/requests/get_chassis.rb,
lib/fog/openstack/baremetal/requests/list_chassis.rb,
lib/fog/openstack/baremetal/requests/list_drivers.rb,
lib/fog/openstack/baremetal/requests/patch_chassis.rb,
lib/fog/openstack/baremetal/requests/create_chassis.rb,
lib/fog/openstack/baremetal/requests/delete_chassis.rb,
lib/fog/openstack/baremetal/requests/list_nodes_detailed.rb,
lib/fog/openstack/baremetal/requests/list_ports_detailed.rb,
lib/fog/openstack/baremetal/requests/set_node_maintenance.rb,
lib/fog/openstack/baremetal/requests/set_node_power_state.rb,
lib/fog/openstack/baremetal/requests/get_driver_properties.rb,
lib/fog/openstack/baremetal/requests/list_chassis_detailed.rb,
lib/fog/openstack/baremetal/requests/unset_node_maintenance.rb,
lib/fog/openstack/baremetal/requests/set_node_provision_state.rb
Overview
Driver requests request :get_vendor_passthru_methods
Class Method Summary collapse
Instance Method Summary collapse
- #create_chassis(_attributes) ⇒ Object
- #create_node(_attributes) ⇒ Object
- #create_port(_attributes) ⇒ Object
- #credentials ⇒ Object
- #data ⇒ Object
- #delete_chassis(_chassis_uuid) ⇒ Object
- #delete_node(_node_uuid) ⇒ Object
- #delete_port(_port_uuid) ⇒ Object
- #get_chassis(_chassis_uuid) ⇒ Object
- #get_driver(_driver_name) ⇒ Object
- #get_driver_properties(_driver_name) ⇒ Object
- #get_node(_node_id) ⇒ Object
- #get_port(_port_id) ⇒ Object
-
#initialize(options = {}) ⇒ Mock
constructor
A new instance of Mock.
- #list_chassis(_parameters = nil) ⇒ Object
- #list_chassis_detailed(_options = {}) ⇒ Object
- #list_drivers(_options = {}) ⇒ Object
- #list_nodes(_options = {}) ⇒ Object
- #list_nodes_detailed(_options = {}) ⇒ Object
- #list_ports(_options = {}) ⇒ Object
- #list_ports_detailed(_options = {}) ⇒ Object
- #patch_chassis(_chassis_uuid, _patch) ⇒ Object
- #patch_node(_node_uuid, _patch) ⇒ Object
- #patch_port(_port_uuid, _patch) ⇒ Object
- #reset_data ⇒ Object
- #set_node_maintenance(_node_uuid, _parameters = nil) ⇒ Object
- #set_node_power_state(_node_id, _power_state) ⇒ Object
- #set_node_provision_state(_node_id, _provision_state) ⇒ Object
- #unset_node_maintenance(_node_uuid, _parameters = nil) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Mock
Returns a new instance of Mock.
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
# File 'lib/fog/openstack/baremetal.rb', line 204 def initialize( = {}) @openstack_username = [:openstack_username] @openstack_tenant = [:openstack_tenant] @openstack_auth_uri = URI.parse([:openstack_auth_url]) @auth_token = Fog::Mock.random_base64(64) @auth_token_expiration = (Time.now.utc + 86400).iso8601 management_url = URI.parse([:openstack_auth_url]) management_url.port = 9292 management_url.path = '/v1' @openstack_management_url = management_url.to_s @data ||= {:users => {}} unless @data[:users].find { |u| u['name'] == [:openstack_username] } id = Fog::Mock.random_numbers(6).to_s @data[:users][id] = { 'id' => id, 'name' => [:openstack_username], 'email' => "#{[:openstack_username]}@mock.com", 'tenantId' => Fog::Mock.random_numbers(6).to_s, 'enabled' => true } end end |
Class Method Details
.data ⇒ Object
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 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/fog/openstack/baremetal.rb', line 86 def self.data @data ||= Hash.new do |hash, key| chassis_uuid = Fog::UUID.uuid instance_uuid = Fog::UUID.uuid node_uuid = Fog::UUID.uuid hash[key] = { :chassis_collection => [ { "created_at" => "2000-01-01T12:00:00", "description" => "Sample chassis", "extra" => {}, "links" => [ { "href" => "http://localhost:6385/v1/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89", "rel" => "self" }, { "href" => "http://localhost:6385/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89", "rel" => "bookmark" } ], "nodes" => [ { "href" => "http://localhost:6385/v1/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89/nodes", "rel" => "self" }, { "href" => "http://localhost:6385/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89/nodes", "rel" => "bookmark" } ], "updated_at" => "2000-01-01T12:00:00", "uuid" => chassis_uuid } ], :drivers => [ { "hosts" => [ "fake-host" ], "name" => "sample-driver" } ], :nodes => [{ "chassis_uuid" => chassis_uuid, "console_enabled" => false, "created_at" => "2000-01-01T12:00:00", "driver" => "sample-driver", "driver_info" => {}, "extra" => {}, "instance_info" => {}, "instance_uuid" => instance_uuid, "last_error" => nil, "links" => [ { "href" => "http://localhost:6385/v1/nodes/1be26c0b-03f2-4d2e-ae87-c02d7f33c123", "rel" => "self" }, { "href" => "http://localhost:6385/nodes/1be26c0b-03f2-4d2e-ae87-c02d7f33c123", "rel" => "bookmark" } ], "maintenance" => false, "maintenance_reason" => nil, "ports" => [ { "href" => "http://localhost:6385/v1/nodes/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/ports", "rel" => "self" }, { "href" => "http://localhost:6385/nodes/1be26c0b-03f2-4d2e-ae87-c02d7f33c123/ports", "rel" => "bookmark" } ], "power_state" => "power on", "properties" => { "cpus" => "1", "local_gb" => "10", "memory_mb" => "1024" }, "provision_state" => "active", "provision_updated_at" => "2000-01-01T12:00:00", "reservation" => nil, "target_power_state" => nil, "target_provision_state" => nil, "updated_at" => "2000-01-01T12:00:00", "uuid" => node_uuid }], :ports => [{ "address" => "fe:54:00:77:07:d9", "created_at" => "2014-12-23T19:35:30.734116", "extra" => { "foo" => "bar" }, "links" => [ { "href" => "http://localhost:6385/v1/ports/27e3153e-d5bf-4b7e-b517-fb518e17f34c", "rel" => "self" }, { "href" => "http://localhost:6385/ports/27e3153e-d5bf-4b7e-b517-fb518e17f34c", "rel" => "bookmark" } ], "node_uuid" => "7ae81bb3-dec3-4289-8d6c-da80bd8001ae", "updated_at" => "2014-12-23T19:35:30.734119", "uuid" => "27e3153e-d5bf-4b7e-b517-fb518e17f34c" }] } end end |
.reset ⇒ Object
200 201 202 |
# File 'lib/fog/openstack/baremetal.rb', line 200 def self.reset @data = nil end |
Instance Method Details
#create_chassis(_attributes) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/fog/openstack/baremetal/requests/create_chassis.rb', line 29 def create_chassis(_attributes) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:chassis_collection].first response end |
#create_node(_attributes) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/fog/openstack/baremetal/requests/create_node.rb', line 39 def create_node(_attributes) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:nodes].first response end |
#create_port(_attributes) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/fog/openstack/baremetal/requests/create_port.rb', line 31 def create_port(_attributes) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:ports].first response end |
#credentials ⇒ Object
238 239 240 241 242 243 244 |
# File 'lib/fog/openstack/baremetal.rb', line 238 def credentials {:provider => 'openstack', :openstack_auth_url => @openstack_auth_uri.to_s, :openstack_auth_token => @auth_token, :openstack_region => @openstack_region, :openstack_management_url => @openstack_management_url} end |
#data ⇒ Object
230 231 232 |
# File 'lib/fog/openstack/baremetal.rb', line 230 def data self.class.data[@openstack_username] end |
#delete_chassis(_chassis_uuid) ⇒ Object
17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/delete_chassis.rb', line 17 def delete_chassis(_chassis_uuid) response = Excon::Response.new response.status = 200 response end |
#delete_node(_node_uuid) ⇒ Object
17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/delete_node.rb', line 17 def delete_node(_node_uuid) response = Excon::Response.new response.status = 200 response end |
#delete_port(_port_uuid) ⇒ Object
17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/delete_port.rb', line 17 def delete_port(_port_uuid) response = Excon::Response.new response.status = 200 response end |
#get_chassis(_chassis_uuid) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/openstack/baremetal/requests/get_chassis.rb', line 15 def get_chassis(_chassis_uuid) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = data[:chassis_collection].first response end |
#get_driver(_driver_name) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/openstack/baremetal/requests/get_driver.rb', line 15 def get_driver(_driver_name) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = data[:drivers].first response end |
#get_driver_properties(_driver_name) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/fog/openstack/baremetal/requests/get_driver_properties.rb', line 17 def get_driver_properties(_driver_name) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = { "pxe_deploy_ramdisk" => "UUID (from Glance) of the ramdisk.", "ipmi_transit_address" => "transit address for bridged request.", "ipmi_terminal_port" => "node's UDP port to connect to.", "ipmi_target_channel" => "destination channel for bridged request.", "ipmi_transit_channel" => "transit channel for bridged request.", "ipmi_local_address" => "local IPMB address for bridged requests. ", "ipmi_username" => "username; default is NULL user. Optional.", "ipmi_address" => "IP address or hostname of the node. Required.", "ipmi_target_address" => "destination address for bridged request.", "ipmi_password" => "password. Optional.", "pxe_deploy_kernel" => "UUID (from Glance) of the deployment kernel.", "ipmi_priv_level" => "privilege level; default is ADMINISTRATOR. ", "ipmi_bridging" => "bridging_type." } response end |
#get_node(_node_id) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/openstack/baremetal/requests/get_node.rb', line 15 def get_node(_node_id) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = data[:nodes].first response end |
#get_port(_port_id) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/fog/openstack/baremetal/requests/get_port.rb', line 15 def get_port(_port_id) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = data[:ports].first response end |
#list_chassis(_parameters = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/openstack/baremetal/requests/list_chassis.rb', line 16 def list_chassis(_parameters = nil) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = { "chassis" => [ { "description" => "Sample chassis", "links" => [ { "href" => "http =>//localhost:6385/v1/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89", "rel" => "self" }, { "href" => "http =>//localhost:6385/chassis/eaaca217-e7d8-47b4-bb41-3f99f20eed89", "rel" => "bookmark" } ], "uuid" => Fog::UUID.uuid } ] } response end |
#list_chassis_detailed(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/list_chassis_detailed.rb', line 16 def list_chassis_detailed( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = {"chassis" => data[:chassis_collection]} response end |
#list_drivers(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/list_drivers.rb', line 16 def list_drivers( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = {"drivers" => data[:drivers]} response end |
#list_nodes(_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/fog/openstack/baremetal/requests/list_nodes.rb', line 16 def list_nodes( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = { "nodes" => [{ "instance_uuid" => Fog::UUID.uuid, "maintenance" => false, "power_state" => "power on", "provision_state" => "active", "uuid" => Fog::UUID.uuid, "links" => [] }] } response end |
#list_nodes_detailed(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/list_nodes_detailed.rb', line 16 def list_nodes_detailed( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = {"nodes" => data[:nodes]} response end |
#list_ports(_options = {}) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/fog/openstack/baremetal/requests/list_ports.rb', line 16 def list_ports( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = { "ports" => [ { "address" => "fe:54:00:77:07:d9", "links" => [ { "href" => "http://localhost:6385/v1/ports/27e3153e-d5bf-4b7e-b517-fb518e17f34c", "rel" => "self" }, { "href" => "http://localhost:6385/ports/27e3153e-d5bf-4b7e-b517-fb518e17f34c", "rel" => "bookmark" } ], "uuid" => Fog::UUID.uuid } ] } response end |
#list_ports_detailed(_options = {}) ⇒ Object
16 17 18 19 20 21 |
# File 'lib/fog/openstack/baremetal/requests/list_ports_detailed.rb', line 16 def list_ports_detailed( = {}) response = Excon::Response.new response.status = [200, 204][rand(2)] response.body = {"ports" => data[:ports]} response end |
#patch_chassis(_chassis_uuid, _patch) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/openstack/baremetal/requests/patch_chassis.rb', line 26 def patch_chassis(_chassis_uuid, _patch) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:chassis_collection].first response end |
#patch_node(_node_uuid, _patch) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/openstack/baremetal/requests/patch_node.rb', line 26 def patch_node(_node_uuid, _patch) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:nodes].first response end |
#patch_port(_port_uuid, _patch) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/fog/openstack/baremetal/requests/patch_port.rb', line 26 def patch_port(_port_uuid, _patch) response = Excon::Response.new response.status = 200 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:ports].first response end |
#reset_data ⇒ Object
234 235 236 |
# File 'lib/fog/openstack/baremetal.rb', line 234 def reset_data self.class.data.delete(@openstack_username) end |
#set_node_maintenance(_node_uuid, _parameters = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/baremetal/requests/set_node_maintenance.rb', line 16 def set_node_maintenance(_node_uuid, _parameters = nil) response = Excon::Response.new response.status = 202 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response end |
#set_node_power_state(_node_id, _power_state) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/fog/openstack/baremetal/requests/set_node_power_state.rb', line 20 def set_node_power_state(_node_id, _power_state) response = Excon::Response.new response.status = 202 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:nodes].first response end |
#set_node_provision_state(_node_id, _provision_state) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/fog/openstack/baremetal/requests/set_node_provision_state.rb', line 23 def set_node_provision_state(_node_id, _provision_state) response = Excon::Response.new response.status = 202 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response.body = data[:nodes].first response end |
#unset_node_maintenance(_node_uuid, _parameters = nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/fog/openstack/baremetal/requests/unset_node_maintenance.rb', line 16 def unset_node_maintenance(_node_uuid, _parameters = nil) response = Excon::Response.new response.status = 202 response.headers = { "X-Compute-Request-Id" => "req-fdc6f99e-55a2-4ab1-8904-0892753828cf", "Content-Type" => "application/json", "Content-Length" => "356", "Date" => Date.new } response end |