Class: Fog::OpenStack::Compute::Mock

Inherits:
Object
  • Object
show all
Includes:
Fog::OpenStack::Core
Defined in:
lib/fog/openstack/compute.rb,
lib/fog/openstack/compute/requests/get_quota.rb,
lib/fog/openstack/compute/requests/get_usage.rb,
lib/fog/openstack/compute/requests/get_limits.rb,
lib/fog/openstack/compute/requests/list_hosts.rb,
lib/fog/openstack/compute/requests/list_zones.rb,
lib/fog/openstack/compute/requests/set_tenant.rb,
lib/fog/openstack/compute/requests/delete_meta.rb,
lib/fog/openstack/compute/requests/get_address.rb,
lib/fog/openstack/compute/requests/list_images.rb,
lib/fog/openstack/compute/requests/list_usages.rb,
lib/fog/openstack/compute/requests/stop_server.rb,
lib/fog/openstack/compute/requests/update_meta.rb,
lib/fog/openstack/compute/requests/add_fixed_ip.rb,
lib/fog/openstack/compute/requests/create_image.rb,
lib/fog/openstack/compute/requests/delete_image.rb,
lib/fog/openstack/compute/requests/get_key_pair.rb,
lib/fog/openstack/compute/requests/get_metadata.rb,
lib/fog/openstack/compute/requests/list_flavors.rb,
lib/fog/openstack/compute/requests/list_servers.rb,
lib/fog/openstack/compute/requests/list_volumes.rb,
lib/fog/openstack/compute/requests/pause_server.rb,
lib/fog/openstack/compute/requests/set_metadata.rb,
lib/fog/openstack/compute/requests/start_server.rb,
lib/fog/openstack/compute/requests/update_quota.rb,
lib/fog/openstack/compute/requests/attach_volume.rb,
lib/fog/openstack/compute/requests/create_flavor.rb,
lib/fog/openstack/compute/requests/create_server.rb,
lib/fog/openstack/compute/requests/create_volume.rb,
lib/fog/openstack/compute/requests/delete_flavor.rb,
lib/fog/openstack/compute/requests/delete_server.rb,
lib/fog/openstack/compute/requests/delete_volume.rb,
lib/fog/openstack/compute/requests/detach_volume.rb,
lib/fog/openstack/compute/requests/get_aggregate.rb,
lib/fog/openstack/compute/requests/list_metadata.rb,
lib/fog/openstack/compute/requests/list_services.rb,
lib/fog/openstack/compute/requests/reboot_server.rb,
lib/fog/openstack/compute/requests/rescue_server.rb,
lib/fog/openstack/compute/requests/resize_server.rb,
lib/fog/openstack/compute/requests/resume_server.rb,
lib/fog/openstack/compute/requests/shelve_server.rb,
lib/fog/openstack/compute/requests/update_server.rb,
lib/fog/openstack/compute/requests/delete_service.rb,
lib/fog/openstack/compute/requests/enable_service.rb,
lib/fog/openstack/compute/requests/get_hypervisor.rb,
lib/fog/openstack/compute/requests/list_addresses.rb,
lib/fog/openstack/compute/requests/list_key_pairs.rb,
lib/fog/openstack/compute/requests/list_snapshots.rb,
lib/fog/openstack/compute/requests/migrate_server.rb,
lib/fog/openstack/compute/requests/rebuild_server.rb,
lib/fog/openstack/compute/requests/server_actions.rb,
lib/fog/openstack/compute/requests/suspend_server.rb,
lib/fog/openstack/compute/requests/unpause_server.rb,
lib/fog/openstack/compute/requests/create_key_pair.rb,
lib/fog/openstack/compute/requests/create_snapshot.rb,
lib/fog/openstack/compute/requests/delete_key_pair.rb,
lib/fog/openstack/compute/requests/delete_metadata.rb,
lib/fog/openstack/compute/requests/delete_snapshot.rb,
lib/fog/openstack/compute/requests/disable_service.rb,
lib/fog/openstack/compute/requests/evacuate_server.rb,
lib/fog/openstack/compute/requests/get_vnc_console.rb,
lib/fog/openstack/compute/requests/list_aggregates.rb,
lib/fog/openstack/compute/requests/release_address.rb,
lib/fog/openstack/compute/requests/remote_consoles.rb,
lib/fog/openstack/compute/requests/remove_fixed_ip.rb,
lib/fog/openstack/compute/requests/unshelve_server.rb,
lib/fog/openstack/compute/requests/update_metadata.rb,
lib/fog/openstack/compute/requests/allocate_address.rb,
lib/fog/openstack/compute/requests/create_aggregate.rb,
lib/fog/openstack/compute/requests/delete_aggregate.rb,
lib/fog/openstack/compute/requests/get_host_details.rb,
lib/fog/openstack/compute/requests/get_os_interface.rb,
lib/fog/openstack/compute/requests/get_server_group.rb,
lib/fog/openstack/compute/requests/list_hypervisors.rb,
lib/fog/openstack/compute/requests/update_aggregate.rb,
lib/fog/openstack/compute/requests/add_flavor_access.rb,
lib/fog/openstack/compute/requests/associate_address.rb,
lib/fog/openstack/compute/requests/get_image_details.rb,
lib/fog/openstack/compute/requests/add_aggregate_host.rb,
lib/fog/openstack/compute/requests/add_security_group.rb,
lib/fog/openstack/compute/requests/get_console_output.rb,
lib/fog/openstack/compute/requests/get_flavor_details.rb,
lib/fog/openstack/compute/requests/get_quota_defaults.rb,
lib/fog/openstack/compute/requests/get_security_group.rb,
lib/fog/openstack/compute/requests/get_server_details.rb,
lib/fog/openstack/compute/requests/get_server_volumes.rb,
lib/fog/openstack/compute/requests/get_volume_details.rb,
lib/fog/openstack/compute/requests/list_address_pools.rb,
lib/fog/openstack/compute/requests/list_all_addresses.rb,
lib/fog/openstack/compute/requests/list_images_detail.rb,
lib/fog/openstack/compute/requests/list_os_interfaces.rb,
lib/fog/openstack/compute/requests/list_server_groups.rb,
lib/fog/openstack/compute/requests/reset_server_state.rb,
lib/fog/openstack/compute/requests/server_diagnostics.rb,
lib/fog/openstack/compute/requests/create_os_interface.rb,
lib/fog/openstack/compute/requests/create_server_group.rb,
lib/fog/openstack/compute/requests/delete_os_interface.rb,
lib/fog/openstack/compute/requests/delete_server_group.rb,
lib/fog/openstack/compute/requests/get_flavor_metadata.rb,
lib/fog/openstack/compute/requests/get_server_password.rb,
lib/fog/openstack/compute/requests/list_flavors_detail.rb,
lib/fog/openstack/compute/requests/list_servers_detail.rb,
lib/fog/openstack/compute/requests/list_volumes_detail.rb,
lib/fog/openstack/compute/requests/list_zones_detailed.rb,
lib/fog/openstack/compute/requests/live_migrate_server.rb,
lib/fog/openstack/compute/requests/disassociate_address.rb,
lib/fog/openstack/compute/requests/get_snapshot_details.rb,
lib/fog/openstack/compute/requests/list_security_groups.rb,
lib/fog/openstack/compute/requests/remove_flavor_access.rb,
lib/fog/openstack/compute/requests/revert_resize_server.rb,
lib/fog/openstack/compute/requests/confirm_resize_server.rb,
lib/fog/openstack/compute/requests/create_security_group.rb,
lib/fog/openstack/compute/requests/delete_security_group.rb,
lib/fog/openstack/compute/requests/list_public_addresses.rb,
lib/fog/openstack/compute/requests/list_snapshots_detail.rb,
lib/fog/openstack/compute/requests/remove_aggregate_host.rb,
lib/fog/openstack/compute/requests/remove_security_group.rb,
lib/fog/openstack/compute/requests/shelve_offload_server.rb,
lib/fog/openstack/compute/requests/change_server_password.rb,
lib/fog/openstack/compute/requests/create_flavor_metadata.rb,
lib/fog/openstack/compute/requests/delete_flavor_metadata.rb,
lib/fog/openstack/compute/requests/list_private_addresses.rb,
lib/fog/openstack/compute/requests/update_flavor_metadata.rb,
lib/fog/openstack/compute/requests/get_security_group_rule.rb,
lib/fog/openstack/compute/requests/list_availability_zones.rb,
lib/fog/openstack/compute/requests/list_hypervisor_servers.rb,
lib/fog/openstack/compute/requests/list_hypervisors_detail.rb,
lib/fog/openstack/compute/requests/list_volume_attachments.rb,
lib/fog/openstack/compute/requests/get_hypervisor_statistics.rb,
lib/fog/openstack/compute/requests/update_aggregate_metadata.rb,
lib/fog/openstack/compute/requests/create_security_group_rule.rb,
lib/fog/openstack/compute/requests/delete_security_group_rule.rb,
lib/fog/openstack/compute/requests/disable_service_log_reason.rb,
lib/fog/openstack/compute/requests/list_tenants_with_flavor_access.rb

Instance Attribute Summary collapse

Attributes included from Fog::OpenStack::Core

#current_user_id, #openstack_application_credential_id, #openstack_application_credential_secret, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_api_version, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Fog::OpenStack::Core

#credentials, not_found_class, #reload

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



354
355
356
357
358
359
360
361
362
# File 'lib/fog/openstack/compute.rb', line 354

def initialize(options = {})
  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86400).iso8601

  management_url = URI.parse(options[:openstack_auth_url])
  management_url.port = 8774
  management_url.path = '/v1.1/1'
  @openstack_management_url = management_url.to_s
end

Instance Attribute Details

#auth_tokenObject (readonly)

Returns the value of attribute auth_token.



253
254
255
# File 'lib/fog/openstack/compute.rb', line 253

def auth_token
  @auth_token
end

#auth_token_expirationObject (readonly)

Returns the value of attribute auth_token_expiration.



254
255
256
# File 'lib/fog/openstack/compute.rb', line 254

def auth_token_expiration
  @auth_token_expiration
end

#current_tenantObject (readonly)

Returns the value of attribute current_tenant.



256
257
258
# File 'lib/fog/openstack/compute.rb', line 256

def current_tenant
  @current_tenant
end

#current_userObject (readonly)

Returns the value of attribute current_user.



255
256
257
# File 'lib/fog/openstack/compute.rb', line 255

def current_user
  @current_user
end

Class Method Details

.dataObject



258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
# File 'lib/fog/openstack/compute.rb', line 258

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :last_modified             => {
        :images          => {},
        :servers         => {},
        :key_pairs       => {},
        :security_groups => {},
        :addresses       => {}
      },
      :aggregates                => [{
        "availability_zone" => "nova",
        "created_at"        => "2012-11-16T06:22:23.032493",
        "deleted"           => false,
        "deleted_at"        => nil,
        "id"                => 1,
        "name"              => "name",
        "updated_at"        => nil
      }],
      :images                    => {
        "0e09fbd6-43c5-448a-83e9-0d3d05f9747e" => {
          "id"       => "0e09fbd6-43c5-448a-83e9-0d3d05f9747e",
          "name"     => "cirros-0.3.0-x86_64-blank",
          'progress' => 100,
          'status'   => "ACTIVE",
          'updated'  => "",
          'minRam'   => 0,
          'minDisk'  => 0,
          'metadata' => {},
          'links'    => [{"href" => "http://nova1:8774/v1.1/admin/images/1", "rel" => "self"},
                         {"href" => "http://nova1:8774/admin/images/2", "rel" => "bookmark"}]
        }
      },
      :servers                   => {},
      :key_pairs                 => {},
      :security_groups           => {
        '0' => {
          "id"          => 0,
          "tenant_id"   => Fog::Mock.random_hex(8),
          "name"        => "default",
          "description" => "default",
          "rules"       => [
            {"id"              => 0,
             "parent_group_id" => 0,
             "from_port"       => 68,
             "to_port"         => 68,
             "ip_protocol"     => "udp",
             "ip_range"        => {"cidr" => "0.0.0.0/0"},
             "group"           => {}},
          ],
        },
      },
      :server_groups             => {},
      :server_security_group_map => {},
      :addresses                 => {},
      :quota                     => {
        'security_group_rules'        => 20,
        'security_groups'             => 10,
        'injected_file_content_bytes' => 10240,
        'injected_file_path_bytes'    => 256,
        'injected_files'              => 5,
        'metadata_items'              => 128,
        'floating_ips'                => 10,
        'instances'                   => 10,
        'key_pairs'                   => 10,
        'gigabytes'                   => 5000,
        'volumes'                     => 10,
        'cores'                       => 20,
        'ram'                         => 51200
      },
      :volumes                   => {},
      :snapshots                 => {},
      :os_interfaces             => [
        {
          "fixed_ips" => [
            {
              "ip_address" => "192.168.1.3",
              "subnet_id" => "f8a6e8f8-c2ec-497c-9f23-da9616de54ef"
            }
          ],
          "mac_addr" => "fa:16:3e:4c:2c:30",
          "net_id" => "3cb9bc59-5699-4588-a4b1-b87f96708bc6",
          "port_id" => "ce531f90-199f-48c0-816c-13e38010b442",
          "port_state" => "ACTIVE"
        }
      ]
    }
  end
end

.resetObject



348
349
350
# File 'lib/fog/openstack/compute.rb', line 348

def self.reset
  @data = nil
end

Instance Method Details

#add_aggregate_host(_uuid, _host_uuid) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/add_aggregate_host.rb', line 17

def add_aggregate_host(_uuid, _host_uuid)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#add_fixed_ip(_server_id, _network_id) ⇒ Object



23
24
25
# File 'lib/fog/openstack/compute/requests/add_fixed_ip.rb', line 23

def add_fixed_ip(_server_id, _network_id)
  true
end

#add_flavor_access(flavor_ref, tenant_id) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/add_flavor_access.rb', line 18

def add_flavor_access(flavor_ref, tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "flavor_access" => [{"tenant_id" => tenant_id.to_s, "flavor_id" => flavor_ref.to_s}]
  }
  response
end

#add_security_group(_server_id, _group_name) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/add_security_group.rb', line 12

def add_security_group(_server_id, _group_name)
  response = Excon::Response.new
  response.status = 200
  response
end

#allocate_address(_pool = nil) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/allocate_address.rb', line 16

def allocate_address(_pool = nil)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
    "Content-Type"         => "application/json",
    "Content-Length"       => "105",
    "Date"                 => Date.new
  }
  response.body = {
    "floating_ip" => {
      "instance_id" => nil,
      "ip"          => "192.168.27.132",
      "fixed_ip"    => nil,
      "id"          => 4,
      "pool"        => "nova"
    }
  }
  response
end

#associate_address(server_id, ip_address) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/associate_address.rb', line 12

def associate_address(server_id, ip_address)
  server = data[:servers][server_id]
  server["addresses"]['mocknet'] ||= []
  ip_hash = {"OS-EXT-IPS-MAC:mac_addr" => "fa:16:3e:85:47:40", "version" => 4, "addr" => ip_address, "OS-EXT-IPS:type" => "floating"}
  server["addresses"]['mocknet'] << ip_hash

  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html, charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#attach_volume(volume_id, server_id, device) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/attach_volume.rb', line 22

def attach_volume(volume_id, server_id, device)
  response = Excon::Response.new
  response.status = 200
  data = {
    'id'       => volume_id,
    'volumeId' => volume_id,
    'serverId' => server_id,
    'device'   => device
  }
  self.data[:volumes][volume_id]['attachments'] << data
  self.data[:volumes][volume_id]['status'] = 'in-use'
  response.body = {'volumeAttachment' => data}
  response
end

#change_server_password(_server_id, _admin_password) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/change_server_password.rb', line 12

def change_server_password(_server_id, _admin_password)
  response = Excon::Response.new
  response.status = 202
  response
end

#confirm_resize_server(_server_id) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/confirm_resize_server.rb', line 12

def confirm_resize_server(_server_id)
  response = Excon::Response.new
  response.status = 204
  response
end

#create_aggregate(_name, _options = {}) ⇒ Object



28
29
30
31
32
33
34
35
36
37
38
# File 'lib/fog/openstack/compute/requests/create_aggregate.rb', line 28

def create_aggregate(_name, _options = {})
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {'aggregate' => data[:aggregates].first}
  response
end

#create_flavor(attributes) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/create_flavor.rb', line 37

def create_flavor(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 = {
    "flavor" => {
      "vcpus"                      => attributes[:vcpus],
      "disk"                       => attributes[:disk],
      "name"                       => attributes[:name],
      "links"                      => [
        {
          "href" => "http://192.168.27.100:8774/v1.1/6733e93c5f5c4eb1bcabc6902ba208d6/flavors/11",
          "rel"  => "self"
        },
        {
          "href" => "http://192.168.27.100:8774/6733e93c5f5c4eb1bcabc6902ba208d6/flavors/11",
          "rel"  => "bookmark"
        }
      ],
      "rxtx_factor"                => attributes[:rxtx_factor] || 1.0,
      "OS-FLV-EXT-DATA:ephemeral"  => attributes[:ephemeral] || 0,
      "os-flavor-access:is_public" => attributes[:is_public] || false,
      "OS-FLV-DISABLED:disabled"   => attributes[:disabled] || false,
      "ram"                        => attributes[:ram],
      "id"                         => "11",
      "swap"                       => attributes[:swap] || ""
    }
  }
  response
end

#create_flavor_metadata(_flavor_ref, _metadata) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/create_flavor_metadata.rb', line 20

def (_flavor_ref, )
  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 = {"extra_specs" => {
    "cpu_arch" => "x86_64"
  }}
  response
end

#create_image(server_id, name, metadata = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/fog/openstack/compute/requests/create_image.rb', line 17

def create_image(server_id, name,  = {})
  response = Excon::Response.new
  response.status = 202

  img_id = Fog::Mock.random_numbers(6).to_s

  data = {
    'id'       => img_id,
    'server'   => {"id" => "3", "links" => [{"href" => "http://nova1:8774/admin/servers/#{server_id}", "rel" => "bookmark"}]},
    'links'    => [{"href" => "http://nova1:8774/v1.1/admin/images/#{img_id}", "rel" => "self"}, {"href" => "http://nova1:8774/admin/images/#{img_id}", "rel" => "bookmark"}],
    'metadata' =>  || {},
    'name'     => name || "server_#{rand(999)}",
    'progress' => 0,
    'status'   => 'SAVING',
    'minDisk'  => 0,
    'minRam'   => 0,
    'updated'  => "",
    'created'  => ""
  }
  self.data[:last_modified][:images][data['id']] = Time.now
  self.data[:images][data['id']] = data
  response.body = {'image' => data}
  response
end

#create_key_pair(key_name, _public_key = nil) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/fog/openstack/compute/requests/create_key_pair.rb', line 25

def create_key_pair(key_name, _public_key = nil)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-c373a42c-2825-4e60-8d34-99416ea850be",
    "Content-Type"         => "application/json",
    "Content-Length"       => "1289",
    "Date"                 => Date.new
  }
  response.body = {
    "keypair" => {
      "public_key"  => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCdAZLjljntJbLVVkNHjWFSoKen2nZbk39ZfqhZJOMdeFdz02GWBS45rcuboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7j4hVJac3yISGms+Xtu4cEv6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQ== vagrant@nova\n",
      "private_key" => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDCdAZLjljn1tJbLVVkNHjWFSoKen2nZbk39ZfqhZJOMdeFdz02\nGWBS45rcuHboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7\nj4hVJac3yISGms+Xtu4cEv6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQIDAQAB\nAoGBALBoT9m1vuQ82EONQf2RONqHAsfUzi/SMhEZRgOlv9AemXZkcWyl4uPvxmtd\nEcreiTystAtCHjw7lhCExXthipevUjtIAAt+b3pMn6Oyjad3IRvde6atMdjrje43\n/nftYtuXYyJTsvwEvLYqSioLQ0Nn/XDKhOpcM5tejDHOH35lAkEA+H4r7y9X521u\nIABVAezBWaT/wvdMjx5cwfyYEQjnI1bxfRIqkgoY5gDDBdVbT75UTsHHbHLORQcw\nRjRvS2zgewJBAMhT6eyMonJvHHvC5RcchcY+dWkscIKoOzeyUKMb+7tERQa9/UN2\njYb+jdM0VyL0ruLFwYtl2m34gfmhcXgIvGcCQGzKMEnjHEUBr7jq7EyPbobkqeSd\niDMQQ+PZxmmO0EK0ib0L+v881HG926PuKK/cz+Q7Cif8iznFT+ksg50t6YkCQQC9\nwfcAskqieSuS9A9LcCIrojhXctf0e+T0Ij2N89DlF4sHEuqXf/IZ4IB5gsfTfdE3\nUDnAkK9yogaEbu/r0uKbAkEAy5kl71bIqvKTKsY2mES9ziVxfftl/9UIi5LI+QHb\nmC/c6cTrGVCM71fi2GMxGgBeEea4+7xwoWTL4CxA00kmTg==\n-----END RSA PRIVATE KEY-----\n",
      "user_id"     => "admin",
      "name"        => key_name,
      "fingerprint" => "97:86:f4:15:68:0c:7b:a7:e5:8f:f0:bd:1f:27:65:ad"
    }
  }
  response
end

#create_os_interface(server_id, options = {}) ⇒ Object



33
34
35
36
37
38
# File 'lib/fog/openstack/compute/requests/create_os_interface.rb', line 33

def create_os_interface(server_id, options={})
  Excon::Response.new(
    :body   => {'interfaceAttachment' => data[:os_interfaces].first},
    :status => 200
  )
end

#create_security_group(name, description) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/create_security_group.rb', line 23

def create_security_group(name, description)
  Fog::OpenStack::Identity.new(:openstack_auth_url => credentials[:openstack_auth_url], :openstack_identity_api_version => 'v2.0')
  tenant_id = Fog::OpenStack::Identity::V2::Mock.data[current_tenant][:tenants].keys.first
  security_group_id = Fog::Mock.random_numbers(2).to_i + 1
  data[:security_groups][security_group_id.to_s] = {
    'tenant_id'   => tenant_id,
    'rules'       => [],
    'id'          => security_group_id,
    'name'        => name,
    'description' => description
  }

  response = Excon::Response.new
  response.status = 200
  response.headers = {
    'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
    'Content-Type'         => 'application/json',
    'Content-Length'       => Fog::Mock.random_numbers(3).to_s,
    'Date'                 => Date.new
  }
  response.body = {
    'security_group' => data[:security_groups][security_group_id.to_s]
  }
  response
end

#create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id = nil) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/create_security_group_rule.rb', line 27

def create_security_group_rule(parent_group_id, ip_protocol, from_port, to_port, cidr, group_id = nil)
  parent_group_id = parent_group_id.to_i
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    'X-Compute-Request-Id' => "req-#{Fog::Mock.random_hex(32)}",
    'Content-Type'         => 'application/json',
    'Content-Length'       => Fog::Mock.random_numbers(3).to_s,
    'Date'                 => Date.new
  }
  rule = {
    'id'              => Fog::Mock.random_numbers(2).to_i,
    'from_port'       => from_port,
    'group'           => group_id || {},
    'ip_protocol'     => ip_protocol,
    'to_port'         => to_port,
    'parent_group_id' => parent_group_id,
    'ip_range'        => {
      'cidr' => cidr
    }
  }
  data[:security_groups][parent_group_id.to_s]['rules'].push(rule)
  response.body = {
    'security_group_rule' => rule
  }
  response
end

#create_server(name, image_ref, flavor_ref, options = {}) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/create_server.rb', line 92

def create_server(name, image_ref, flavor_ref, options = {})
  response = Excon::Response.new
  response.status = 202

  server_id = Fog::Mock.random_numbers(6).to_s
  identity = Fog::OpenStack::Identity.new(:openstack_auth_url => credentials[:openstack_auth_url], :openstack_identity_api_version => 'v2.0')
  user = identity.users.find do |u|
    u.name == @openstack_username
  end

  user_id = if user
              user.id
            else
              response = identity.create_user(@openstack_username,
                                              'password',
                                              "#{@openstack_username}@example.com")
              response.body["user"]["id"]
            end

  mock_data = {
    'addresses'    => {"Private" => [{"addr" => Fog::Mock.random_ip}]},
    'flavor'       => {"id" => flavor_ref, "links" => [{"href" => "http://nova1:8774/admin/flavors/1", "rel" => "bookmark"}]},
    'id'           => server_id,
    'image'        => {"id" => image_ref, "links" => [{"href" => "http://nova1:8774/admin/images/#{image_ref}", "rel" => "bookmark"}]},
    'links'        => [{"href" => "http://nova1:8774/v1.1/admin/servers/5", "rel" => "self"}, {"href" => "http://nova1:8774/admin/servers/5", "rel" => "bookmark"}],
    'hostId'       => "123456789ABCDEF01234567890ABCDEF",
    'metadata'     => options['metadata'] || {},
    'name'         => name || "server_#{rand(999)}",
    'accessIPv4'   => options['accessIPv4'] || "",
    'accessIPv6'   => options['accessIPv6'] || "",
    'progress'     => 0,
    'status'       => 'BUILD',
    'created'      => '2012-09-27T00:04:18Z',
    'updated'      => '2012-09-27T00:04:27Z',
    'user_id'      => user_id,
    'config_drive' => options['config_drive'] || '',
  }

  nics = options['nics']

  if nics
    nics.each do |_nic|
      mock_data["addresses"].merge!(
        "Public" => [{'addr' => Fog::Mock.random_ip}]
      )
    end
  end

  response_data = if options['return_reservation_id'] == 'True'
                    {'reservation_id' => "r-#{Fog::Mock.random_numbers(6)}"}
                  else
                    {
                      'adminPass' => 'password',
                      'id'        => server_id,
                      'links'     => mock_data['links'],
                    }
                  end

  if block_devices = options["block_device_mapping_v2"]
    block_devices.each { |bd| volumes.get(bd[:uuid]).attach(server_id, bd[:device_name]) }
  elsif block_device = options["block_device_mapping"]
    volumes.get(block_device[:volume_id]).attach(server_id, block_device[:device_name])
  end

  data[:last_modified][:servers][server_id] = Time.now
  data[:servers][server_id] = mock_data
  security_groups = options['security_groups']
  if security_groups
    groups = Array(security_groups).map do |sg|
      if sg.kind_of?(Fog::OpenStack::Compute::SecurityGroup)
        sg.name
      else
        sg
      end
    end

    data[:server_security_group_map][server_id] = groups
    response_data['security_groups'] = groups
  end

  if options['os:scheduler_hints'] && options['os:scheduler_hints']['group']
    group = data[:server_groups][options['os:scheduler_hints']['group']]
    group[:members] << server_id if group
  end

  response.body = if options['return_reservation_id'] == 'True'
                    response_data
                  else
                    {'server' => response_data}
                  end
  response
end

#create_server_group(name, policy) ⇒ Object



22
23
24
25
26
27
# File 'lib/fog/openstack/compute/requests/create_server_group.rb', line 22

def create_server_group(name, policy)
  Fog::OpenStack::Compute::ServerGroup.validate_server_group_policy policy
  id = SecureRandom.uuid
  data[:server_groups][id] = {:name => name, :policies => [policy], :members => []}
  get_server_group id
end

#create_snapshot(volume_id, name, description, _force = false) ⇒ Object



25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/openstack/compute/requests/create_snapshot.rb', line 25

def create_snapshot(volume_id, name, description, _force = false)
  volume_response = get_volume_details(volume_id)
  volume = volume_response.data[:body]['volume']
  if volume.nil?
    raise Fog::OpenStack::Compute::NotFound
  else
    response = Excon::Response.new
    data = {
      "status"      => "availble",
      "name"        => name,
      "created_at"  => Time.now,
      "description" => description,
      "volume_id"   => volume_id,
      "id"          => Fog::Mock.random_numbers(2),
      "size"        => volume['size']
    }

    self.data[:snapshots][data['id']] = data
    response.body = {"snapshot" => data}
    response.status = 202
    response
  end
end

#create_volume(name, description, size, options = {}) ⇒ Object



38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/fog/openstack/compute/requests/create_volume.rb', line 38

def create_volume(name, description, size, options = {})
  response = Excon::Response.new
  response.status = 202
  data = {'id' => Fog::Mock.random_numbers(2),
          'displayName' => name,
          'displayDescription' => description,
          'size' => size,
          'status' => 'creating',
          'snapshotId' => options[:snapshot_id],
          'volumeType' => options[:volume_type] || 'None',
          'availabilityZone' => options[:availability_zone] || 'nova',
          'createdAt' => Time.now.strftime('%FT%T.%6N'),
          'attachments' => [], 'metadata' => options[:metadata] || {}}
  self.data[:volumes][data['id']] = data
  response.body = {'volume' => data}
  response
end

#dataObject



364
365
366
# File 'lib/fog/openstack/compute.rb', line 364

def data
  self.class.data["#{@openstack_username}-#{@current_tenant}"]
end

#delete_aggregate(_uuid) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/delete_aggregate.rb', line 15

def delete_aggregate(_uuid)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#delete_flavor(_flavor_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/delete_flavor.rb', line 15

def delete_flavor(_flavor_id)
  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#delete_flavor_metadata(_flavor_ref, _key) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/delete_flavor_metadata.rb', line 15

def (_flavor_ref, _key)
  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 = nil
  response
end

#delete_image(image_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/openstack/compute/requests/delete_image.rb', line 15

def delete_image(image_id)
  response = Excon::Response.new
  image = list_images_detail.body['images'].find { |im| im['id'] == image_id }
  if image
    if image['status'] == 'SAVING'
      response.status = 409
      raise(Excon::Errors.status_error({:expects => 202}, response))
    else
      data[:last_modified][:images].delete(image_id)
      data[:images].delete(image_id)
      response.status = 202
    end
    response
  else
    response.status = 400
    raise(Excon::Errors.status_error({:expects => 202}, response))
  end
end

#delete_key_pair(_key_name) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/get_key_pair.rb', line 15

def delete_key_pair(key_name)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-c373a42c-2825-4e60-8d34-99416ea850be",
    "Content-Type"         => "application/json",
    "Content-Length"       => "1289",
    "Date"                 => Date.new
  }
  response.body = {
    "keypair" => {
      "public_key"  => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCdAZLjljntJbLVVkNHjWFSoKen2nZbk39ZfqhZJOMdeFdz"\
                       "02GWBS45rcuboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7j4hVJac3yISGms+Xtu4c"\
                       "Ev6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQ== vagrant@nova\n",
      "private_key" => "-----BEGIN RSA PRIVATE KEY-----\nMIICXgIBAAKBgQDCdAZLjljn1tJbLVVkNHjWFSoKen2nZbk39Zfq"\
                       "hZJOMdeFdz02\nGWBS45rcuHboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FQG1QZNtLPsx7\nj4hVJ"\
                       "ac3yISGms+Xtu4cEv6j5sFDzAgTQbWez0Z1+9qOq9ngdaoW+YClfQIDAQAB\nAoGBALBoT9m1vuQ82EONQf2R"\
                       "ONqHAsfUzi/SMhEZRgOlv9AemXZkcWyl4uPvxmtd\nEcreiTystAtCHjw7lhCExXthipevUjtIAAt+b3pMn6O"\
                       "yjad3IRvde6atMdjrje43\n/nftYtuXYyJTsvwEvLYqSioLQ0Nn/XDKhOpcM5tejDHOH35lAkEA+H4r7y9X52"\
                       "1u\nIABVAezBWaT/wvdMjx5cwfyYEQjnI1bxfRIqkgoY5gDDBdVbT75UTsHHbHLORQcw\nRjRvS2zgewJBAMh"\
                       "T6eyMonJvHHvC5RcchcY+dWkscIKoOzeyUKMb+7tERQa9/UN2\njYb+jdM0VyL0ruLFwYtl2m34gfmhcXgIvG"\
                       "cCQGzKMEnjHEUBr7jq7EyPbobkqeSd\niDMQQ+PZxmmO0EK0ib0L+v881HG926PuKK/cz+Q7Cif8iznFT+ksg"\
                       "50t6YkCQQC9\nwfcAskqieSuS9A9LcCIrojhXctf0e+T0Ij2N89DlF4sHEuqXf/IZ4IB5gsfTfdE3\nUDnAkK"\
                       "9yogaEbu/r0uKbAkEAy5kl71bIqvKTKsY2mES9ziVxfftl/9UIi5LI+QHb\nmC/c6cTrGVCM71fi2GMxGgBeE"\
                       "ea4+7xwoWTL4CxA00kmTg==\n-----END RSA PRIVATE KEY-----\n",
      "user_id"     => "admin",
      "name"        => key_name,
      "fingerprint" => "97:86:f4:15:68:0c:7b:a7:e5:8f:f0:bd:1f:27:65:ad"
    }
  }
  response
end

#delete_meta(collection_name, parent_id, _key) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/compute/requests/delete_meta.rb', line 15

def delete_meta(collection_name, parent_id, _key)
  if collection_name == "images"
    unless list_images_detail.body['images'].find { |image| image['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  if collection_name == "servers"
    unless list_servers_detail.body['servers'].find { |server| server['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  response = Excon::Response.new
  response.status = 204
  response
end

#delete_metadata(_collection_name, _parent_id, _key) ⇒ Object



15
16
17
18
19
# File 'lib/fog/openstack/compute/requests/delete_metadata.rb', line 15

def (_collection_name, _parent_id, _key)
  response = Excon::Response.new
  response.status = 204
  response
end

#delete_os_interface(server_id, port_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/delete_os_interface.rb', line 18

def delete_os_interface(server_id, port_id)
  true
end

#delete_security_group(security_group_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/openstack/compute/requests/delete_security_group.rb', line 15

def delete_security_group(security_group_id)
  data[:security_groups].delete security_group_id.to_s

  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {}
  response
end

#delete_security_group_rule(security_group_rule_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/openstack/compute/requests/delete_security_group_rule.rb', line 15

def delete_security_group_rule(security_group_rule_id)
  security_group = data[:security_groups].values.find { |sg| sg["rules"].find { |sgr| sgr["id"].to_s == security_group_rule_id.to_s } }
  security_group["rules"].reject! { |sgr| sgr["id"] == security_group_rule_id }
  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {}
  response
end

#delete_server(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/openstack/compute/requests/delete_server.rb', line 15

def delete_server(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    if server['status'] == 'BUILD'
      response.status = 409
      raise(Excon::Errors.status_error({:expects => 204}, response))
    else
      data[:last_modified][:servers].delete(server_id)
      data[:servers].delete(server_id)
      response.status = 204
      server_groups = data[:server_groups]
      if server_groups
        group_id, = server_groups.find { |_id, grp| grp[:members].include?(server_id) }
        server_groups[group_id][:members] -= [server_id] if group_id
      end
    end
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#delete_server_group(group_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/delete_server_group.rb', line 15

def delete_server_group(group_id)
  response = Excon::Response.new
  response.status = data[:server_groups].delete(group_id) ? 204 : 404
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#delete_service(_host, _binary, _optional_params = nil) ⇒ Object



19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/openstack/compute/requests/delete_service.rb', line 19

def delete_service(_host, _binary, _optional_params = nil)
  response = Excon::Response.new
  response.status = 204
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#delete_snapshot(snapshot_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/delete_snapshot.rb', line 15

def delete_snapshot(snapshot_id)
  response = Excon::Response.new
  response.status = 204
  if list_snapshots_detail.body['snapshots'].find { |snap| snap['id'] == snapshot_id }
    data[:snapshots].delete(snapshot_id)
  else
    raise Fog::OpenStack::Compute::NotFound
  end
  response
end

#delete_volume(volume_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/delete_volume.rb', line 15

def delete_volume(volume_id)
  response = Excon::Response.new
  if list_volumes.body['volumes'].map { |v| v['id'] }.include? volume_id
    data[:volumes].delete(volume_id)
    response.status = 204
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#detach_volume(server_id, attachment_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/detach_volume.rb', line 15

def detach_volume(server_id, attachment_id)
  response = Excon::Response.new
  if data[:volumes][attachment_id] &&
     data[:volumes][attachment_id]['attachments'].reject! { |attachment| attachment['serverId'] == server_id }
    data[:volumes][attachment_id]['status'] = 'available'
    response.status = 202
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#disable_service(_host, _binary, _optional_params = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/disable_service.rb', line 22

def disable_service(_host, _binary, _optional_params = nil)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "service" => {
      "host"   => "host1",
      "binary" => "nova-compute",
      "status" => "disabled"
    }
  }
  response
end

#disable_service_log_reason(_host, _binary, _disabled_reason, _optional_params = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/disable_service_log_reason.rb', line 22

def disable_service_log_reason(_host, _binary, _disabled_reason, _optional_params = nil)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "service" => {
      "host"            => "host1",
      "binary"          => "nova-compute",
      "status"          => "disabled",
      "disabled_reason" => "test2"
    }
  }
  response
end

#disassociate_address(_server_id, _ip_address) ⇒ Object



12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/openstack/compute/requests/disassociate_address.rb', line 12

def disassociate_address(_server_id, _ip_address)
  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html, charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#enable_service(_host, _binary, _optional_params = nil) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/enable_service.rb', line 22

def enable_service(_host, _binary, _optional_params = nil)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "service" => {
      "host"   => "host1",
      "binary" => "nova-compute",
      "status" => "enabled"
    }
  }
  response
end

#evacuate_server(_server_id, _host, _on_shared_storage, _admin_password = nil) ⇒ Object



22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/evacuate_server.rb', line 22

def evacuate_server(_server_id, _host, _on_shared_storage, _admin_password = nil)
  response        = Excon::Response.new
  response.status = 202
  response
end

#get_address(_address_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/get_address.rb', line 15

def get_address(_address_id)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
    "Content-Type"         => "application/json",
    "Content-Length"       => "105",
    "Date"                 => Date.new
  }
  response.body = {
    "floating_ip" => {
      "instance_id" => nil,
      "ip"          => "192.168.27.129",
      "fixed_ip"    => nil,
      "id"          => 1,
      "pool"        => "nova"
    }
  }
  response
end

#get_aggregate(_uuid) ⇒ Object



15
16
17
18
19
20
21
# File 'lib/fog/openstack/compute/requests/get_aggregate.rb', line 15

def get_aggregate(_uuid)
  response = Excon::Response.new
  response.status = 2040
  response.body = {'aggregate' => data[:aggregates].first.merge("hosts" => [])}

  response
end

#get_console_output(_server_id, _log_length) ⇒ Object



16
17
18
19
20
# File 'lib/fog/openstack/compute/requests/get_console_output.rb', line 16

def get_console_output(_server_id, _log_length)
  response = Excon::Response.new
  response.status = 200
  response
end

#get_flavor_details(flavor_ref) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/get_flavor_details.rb', line 15

def get_flavor_details(flavor_ref)
  response = Excon::Response.new
  flavor = {
    '1' => {'id' => '1', 'name' => '256 server', 'ram' => 256, 'disk' => 10, 'swap' => '1', 'vcpus' => 1, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '2' => {'id' => '2', 'name' => '512 server', 'ram' => 512, 'disk' => 20, 'swap' => '1', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '3' => {'id' => '3', 'name' => '1GB server', 'ram' => 1024, 'disk' => 40, 'swap' => '2', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '4' => {'id' => '4', 'name' => '2GB server', 'ram' => 2048, 'disk' => 80, 'swap' => '4', 'vcpus' => 4, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '5' => {'id' => '5', 'name' => '4GB server', 'ram' => 4096, 'disk' => 160, 'swap' => '8', 'vcpus' => 8, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '6' => {'id' => '6', 'name' => '8GB server', 'ram' => 8192, 'disk' => 320, 'swap' => '16', 'vcpus' => 16, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
    '7' => {'id' => '7', 'name' => '15.5GB server', 'ram' => 15872, 'disk' => 620, 'swap' => '32', 'vcpus' => 32, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []}
  }[flavor_ref]
  if flavor
    response.status = 200
    response.body = {
      'flavor' => flavor
    }
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#get_flavor_metadata(_flavor_ref) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/get_flavor_metadata.rb', line 15

def (_flavor_ref)
  response = Excon::Response.new
  response.status = 200
  response.body = {"extra_specs" => {
    "cpu_arch" => "x86_64"
  }}
  response
end

#get_host_details(_host) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/get_host_details.rb', line 15

def get_host_details(_host)
  response = Excon::Response.new
  response.status = 200
  response.body = {"host" => [
    {"resource" => {
      "project"   => "(total)",
      "memory_mb" => 64427,
      "host"      => "cn28.la-1-3.morphcloud.net",
      "cpu"       => 12,
      "disk_gb"   => 1608
    }},
    {"resource" => {
      "project"   => "(used_now)",
      "memory_mb" => 1753,
      "host"      => "cn28.la-1-3.morphcloud.net",
      "cpu"       => 3,
      "disk_gb"   => 33
    }},
    {"resource" => {
      "project"   => "(used_max)",
      "memory_mb" => 7168,
      "host"      => "cn28.la-1-3.morphcloud.net",
      "cpu"       => 3,
      "disk_gb"   => 45
    }},
    {"resource" => {
      "project"   => "bf8301f5164f4790889a1bc2bfb16d99",
      "memory_mb" => 5120,
      "host"      => "cn28.la-1-3.morphcloud.net",
      "cpu"       => 2,
      "disk_gb"   => 35
    }},
    {"resource" => {
      "project"   => "3bb4d0301c5f47d5b4d96a361fcf96f4",
      "memory_mb" => 2048,
      "host"      => "cn28.la-1-3.morphcloud.net",
      "cpu"       => 1,
      "disk_gb"   => 10
    }}
  ]}
  response
end

#get_hypervisor(hypervisor_id) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/get_hypervisor.rb', line 15

def get_hypervisor(hypervisor_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "hypervisor" => {
      "cpu_info"             => {
        "arch"     => "x86_64",
        "model"    => "Nehalem",
        "vendor"   => "Intel",
        "features" => [
          "pge",
          "clflush"
        ],
        "topology" => {
          "cores"   => 1,
          "threads" => 1,
          "sockets" => 4
        }
      },
      "current_workload"     => 0,
      "status"               => "enabled",
      "state"                => "up",
      "disk_available_least" => 0,
      "host_ip"              => "1.1.1.1",
      "free_disk_gb"         => 1028,
      "free_ram_mb"          => 7680,
      "hypervisor_hostname"  => "fake-mini",
      "hypervisor_type"      => "fake",
      "hypervisor_version"   => 1000,
      "id"                   => hypervisor_id,
      "local_gb"             => 1028,
      "local_gb_used"        => 0,
      "memory_mb"            => 8192,
      "memory_mb_used"       => 512,
      "running_vms"          => 0,
      "service"              => {
        "host"            => "host1",
        "id"              => 7,
        "disabled_reason" => null
      },
      "vcpus"                => 1,
      "vcpus_used"           => 0
    }
  }
  response
end

#get_hypervisor_statistics(_tenant_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/get_hypervisor_statistics.rb', line 15

def get_hypervisor_statistics(_tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "hypervisor_statistics" => {
      "count"                => 1,
      "current_workload"     => 0,
      "disk_available_least" => 0,
      "free_disk_gb"         => 1028,
      "free_ram_mb"          => 7680,
      "local_gb"             => 1028,
      "local_gb_used"        => 0,
      "memory_mb"            => 8192,
      "memory_mb_used"       => 512,
      "running_vms"          => 0,
      "vcpus"                => 1,
      "vcpus_used"           => 0
    }
  }
  response
end

#get_image_details(image_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/get_image_details.rb', line 15

def get_image_details(image_id)
  response = Excon::Response.new
  image = list_images_detail.body['images'].find { |im| im['id'] == image_id }
  if image
    response.status = [200, 203][rand(2)]
    response.body = {'image' => image}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#get_limits(_options = {}) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/get_limits.rb', line 18

def get_limits(_options = {})
  rate_limits = [
    {'regex' => '.*',
     'limit' => [
       {'next-available' => '2012-11-22T16:13:44Z',
        'unit'           => 'MINUTE',
        'verb'           => 'POST',
        'remaining'      => 9,
        'value'          => 10},
       {'next-available' => '2012-11-23T00:46:14Z',
        'unit'           => 'MINUTE',
        'verb'           => 'PUT',
        'remaining'      => 10,
        'value'          => 10},
       {'next-available' => '2012-11-22T16:14:30Z',
        'unit'           => 'MINUTE',
        'verb'           => 'DELETE',
        'remaining'      => 99,
        'value'          => 100}
     ],
     'uri'   => '*'},
    {'regex' => '^/servers',
     'limit' => [
       {'next-available' => '2012-11-23T00:46:14Z',
        'unit'           => 'DAY',
        'verb'           => 'POST',
        'remaining'      => 50,
        'value'          => 50}
     ],
     'uri'   => '*/servers'},
    {'regex' => '.*changes-since.*',
     'limit' => [
       {'next-available' => '2012-11-23T00:46:14Z',
        'unit'           => 'MINUTE',
        'verb'           => 'GET',
        'remaining'      => 3,
        'value'          => 3}
     ],
     'uri'   => '*changes-since*'}
  ]

  absolute_limits = {
    # Max
    'maxServerMeta'           => 128,
    'maxTotalInstances'       => 10,
    'maxPersonality'          => 5,
    'maxImageMeta'            => 128,
    'maxPersonalitySize'      => 10240,
    'maxSecurityGroupRules'   => 20,
    'maxTotalKeypairs'        => 100,
    'maxSecurityGroups'       => 10,
    'maxTotalCores'           => 20,
    'maxTotalFloatingIps'     => 10,
    'maxTotalRAMSize'         => 51200,

    # Used
    'totalCoresUsed'          => -1,
    'totalRAMUsed'            => -2048,
    'totalInstancesUsed'      => -1,
    'totalSecurityGroupsUsed' => 0,
    'totalFloatingIpsUsed'    => 0
  }

  Excon::Response.new(
    :status => 200,
    :body   => {
      'limits' => {
        'rate'     => rate_limits,
        'absolute' => absolute_limits
      }
    }
  )
end

#get_metadata(_collection_name, _parent_id, _key) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/compute/requests/get_metadata.rb', line 15

def (_collection_name, _parent_id, _key)
  response = Excon::Response.new
  response.status = 200
  response.body = {'meta' => {}}
  response
end

#get_os_interface(server_id, port_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/compute/requests/get_os_interface.rb', line 15

def get_os_interface(server_id,port_id)
  Excon::Response.new(
    :body   => {'interfaceAttachment' => data[:os_interfaces].first},
    :status => 200
  )
end

#get_quota(tenant_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/get_quota.rb', line 15

def get_quota(tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'quota_set' => (data[:quota_updated] || data[:quota]).merge('id' => tenant_id)
  }
  response
end

#get_quota_defaults(tenant_id) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/get_quota_defaults.rb', line 15

def get_quota_defaults(tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'quota_set' => data[:quota].merge('id' => tenant_id)
  }
  response
end

#get_security_group(security_group_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/get_security_group.rb', line 15

def get_security_group(security_group_id)
  security_group = data[:security_groups][security_group_id.to_s]
  response = Excon::Response.new
  if security_group
    response.status = 200
    response.headers = {
      "X-Compute-Request-Id" => "req-63a90344-7c4d-42e2-936c-fd748bced1b3",
      "Content-Type"         => "application/json",
      "Content-Length"       => "167",
      "Date"                 => Date.new
    }
    response.body = {
      "security_group" => security_group
    }
  else
    raise Fog::OpenStack::Compute::NotFound, "Security group #{security_group_id} does not exist"
  end
  response
end

#get_security_group_rule(security_group_rule_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/get_security_group_rule.rb', line 15

def get_security_group_rule(security_group_rule_id)
  security_group_rule = nil
  data[:security_groups].find { |_id, sg| security_group_rule = sg["rules"].find { |sgr| sgr["id"].to_s == security_group_rule_id.to_s } }
  response = Excon::Response.new
  if security_group_rule
    response.status = 200
    response.headers = {
      "X-Compute-Request-Id" => "req-63a90344-7c4d-42e2-936c-fd748bced1b3",
      "Content-Type"         => "application/json",
      "Content-Length"       => "167",
      "Date"                 => Date.new
    }
    response.body = {
      "security_group_rule" => security_group_rule
    }
  else
    raise Fog::OpenStack::Compute::NotFound, "Security group rule #{security_group_rule_id} does not exist"
  end
  response
end

#get_server_details(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/get_server_details.rb', line 15

def get_server_details(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    response.status = [200, 203][rand(2)]
    response.body = {'server' => server}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#get_server_group(group_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/get_server_group.rb', line 15

def get_server_group(group_id)
  grp = data[:server_groups][group_id]
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {'server_group' => {
    'id'         => group_id,
    'name'       => grp[:name],
    'policies'   => grp[:policies],
    'members'    => grp[:members],
    'metadata'   => {},
    'project_id' => 'test-project',
    'user_id'    => 'test-user'
  }}
  response
end

#get_server_password(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/get_server_password.rb', line 15

def get_server_password(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    response.status = [200, 203][rand(2)]
    response.body = {'server' => server}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#get_server_volumes(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/compute/requests/get_server_volumes.rb', line 15

def get_server_volumes(server_id)
  response = Excon::Response.new
  response.status = 200
  data = self.data[:volumes].values.select do |vol|
    vol['attachments'].find { |attachment| attachment["serverId"] == server_id }
  end
  response.body = {'volumeAttachments' => data.map! { |vol| vol['attachments'] }.flatten(1)}
  response
end

#get_snapshot_details(snapshot_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/get_snapshot_details.rb', line 15

def get_snapshot_details(snapshot_id)
  response = Excon::Response.new
  if snapshot = list_snapshots_detail.body['snapshots'].find do |snap|
    snap['id'] == snapshot_id
  end
    response.status = 200
    response.body = {'snapshot' => snapshot}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#get_usage(tenant_id, date_start, date_end) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/get_usage.rb', line 19

def get_usage(tenant_id, date_start, date_end)
  response        = Excon::Response.new
  response.status = 200
  response.body   = {"tenant_usage" =>
                                       {"total_memory_mb_usage" => 0.0,
                                        "total_vcpus_usage"     => 0.0,
                                        "total_hours"           => 0.0,
                                        "tenant_id"             => tenant_id,
                                        "stop"                  => date_start,
                                        "start"                 => date_end,
                                        "total_local_gb_usage"  => 0.0,
                                        "server_usages"         => [{
                                          "hours"      => 0.0,
                                          "uptime"     => 69180,
                                          "local_gb"   => 0,
                                          "ended_at"   => nil,
                                          "name"       => "test server",
                                          "tenant_id"  => tenant_id,
                                          "vcpus"      => 1,
                                          "memory_mb"  => 512,
                                          "state"      => "active",
                                          "flavor"     => "m1.tiny",
                                          "started_at" => "2012-03-05 09:11:44"
                                        }]}}
  response
end

#get_vnc_console(_server_id, _console_type) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/fog/openstack/compute/requests/get_vnc_console.rb', line 35

def get_vnc_console(_server_id, _console_type)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "console" => {
      "url"  => "http://192.168.27.100:6080/vnc_auto.html?token=c3606020-d1b7-445d-a88f-f7af48dd6a20",
      "type" => "novnc"
    }
  }
  response
end

#get_volume_details(volume_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/openstack/compute/requests/get_volume_details.rb', line 15

def get_volume_details(volume_id)
  response = Excon::Response.new
  if data = self.data[:volumes][volume_id]
    if data['status'] == 'creating' \
       && Time.now - Time.parse(data['createdAt']) >= Fog::Mock.delay
      data['status'] = 'available'
    end
    response.status = 200
    response.body = {'volume' => data}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#list_address_poolsObject



15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/list_address_pools.rb', line 15

def list_address_pools
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'floating_ip_pools' => [
      {'name' => 'nova'}
    ]
  }
  response
end

#list_addresses(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/list_addresses.rb', line 15

def list_addresses(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    response.status = [200, 203][rand(2)]
    response.body = {'addresses' => server['addresses']}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#list_aggregates(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/list_aggregates.rb', line 16

def list_aggregates(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'aggregates' => [{
    "availability_zone" => "nova",
    "created_at"        => "2012-11-16T06:22:23.032493",
    "deleted"           => false,
    "deleted_at"        => nil,
    "metadata"          => {
      "availability_zone" => "nova"
    },
    "id"                => 1,
    "name"              => "name",
    "updated_at"        => nil
  }]}

  response
end

#list_all_addresses(_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/fog/openstack/compute/requests/list_all_addresses.rb', line 16

def list_all_addresses(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-d4a21158-a86c-44a6-983a-e25645907f26",
    "Content-Type"         => "application/json",
    "Content-Length"       => "378",
    "Date"                 => Date.new
  }
  response.body = {
    "floating_ips" => [
      {
        "instance_id" => nil,
        "ip"          => "192.168.27.129",
        "fixed_ip"    => nil,
        "id"          => 1,
        "pool"        => "nova"
      },
      {
        "instance_id" => nil,
        "ip"          => "192.168.27.130",
        "fixed_ip"    => nil,
        "id"          => 2,
        "pool"        => "nova"
      },
      {
        "instance_id" => nil,
        "ip"          => "192.168.27.131",
        "fixed_ip"    => nil,
        "id"          => 3,
        "pool"        => "nova"
      },
      {
        "instance_id" => nil,
        "ip"          => "192.168.27.132",
        "fixed_ip"    => nil,
        "id"          => 4,
        "pool"        => "nova"
      }
    ]
  }
  response
end

#list_endpointsObject



18
19
# File 'lib/fog/openstack/compute/requests/list_availability_zones.rb', line 18

def list_endpoints
end

#list_flavors(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/compute/requests/list_flavors.rb', line 16

def list_flavors(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'flavors' => [
      {'name' => '256 server', 'id' => '1', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '512 server', 'id' => '2', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '1GB server', 'id' => '3', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '2GB server', 'id' => '4', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '4GB server', 'id' => '5', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '8GB server', 'id' => '6', 'links' => ['https://itdoesntmatterwhatshere.heh']},
      {'name' => '15.5GB server', 'id' => '7', 'links' => ['https://itdoesntmatterwhatshere.heh']}
    ]
  }
  response
end

#list_flavors_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/compute/requests/list_flavors_detail.rb', line 16

def list_flavors_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
    'flavors' => [
      {'id' => '1', 'name' => '256 server', 'ram' => 256, 'disk' => 10, 'swap' => '1', 'vcpus' => 1, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '2', 'name' => '512 server', 'ram' => 512, 'disk' => 20, 'swap' => '1', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '3', 'name' => '1GB server', 'ram' => 1024, 'disk' => 40, 'swap' => '2', 'vcpus' => 2, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '4', 'name' => '2GB server', 'ram' => 2048, 'disk' => 80, 'swap' => '4', 'vcpus' => 4, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '5', 'name' => '4GB server', 'ram' => 4096, 'disk' => 160, 'swap' => '8', 'vcpus' => 8, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '6', 'name' => '8GB server', 'ram' => 8192, 'disk' => 320, 'swap' => '16', 'vcpus' => 16, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []},
      {'id' => '7', 'name' => '15.5GB server', 'ram' => 15872, 'disk' => 620, 'swap' => '32', 'vcpus' => 32, 'OS-FLV-EXT-DATA:ephemeral' => 1, 'links' => []}
    ]
  }
  response
end

#list_hosts(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/compute/requests/list_hosts.rb', line 16

def list_hosts(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {"hosts" => [
    {"host_name" => "host.test.net", "service" => "compute", "zone" => "az1"}
  ]}
  response
end

#list_hypervisor_servers(hypervisor_id, _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/compute/requests/list_hypervisor_servers.rb', line 16

def list_hypervisor_servers(hypervisor_id, _options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'hypervisors' => [
    {
      "hypervisor_hostname" => "fake-mini",
      "id"                  => hypervisor_id,
      "state"               => "up",
      "status"              => "enabled",
      "servers"             => [
        {
          "name" => "test_server1",
          "uuid" => "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa"
        },
        {
          "name" => "test_server2",
          "uuid" => "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb"
        }
      ]
    }
  ]}
  response
end

#list_hypervisors(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/compute/requests/list_hypervisors.rb', line 16

def list_hypervisors(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {'hypervisors' => [
    {"hypervisor_hostname" => "fake-mini", "id" => 2, "state" => "up", "status" => "enabled"}
  ]}
  response
end

#list_hypervisors_detail(_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
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
# File 'lib/fog/openstack/compute/requests/list_hypervisors_detail.rb', line 16

def list_hypervisors_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "hypervisors"       => [{
      "cpu_info"             => {
        "arch"     => "x86_64",
        "model"    => "Nehalem",
        "vendor"   => "Intel",
        "features" => [
          "pge",
          "clflush"
        ],
        "topology" => {
          "cores"   => 1,
          "threads" => 1,
          "sockets" => 4
        }
      },
      "current_workload"     => 0,
      "status"               => "enabled",
      "state"                => "up",
      "disk_available_least" => 0,
      "host_ip"              => "1.1.1.1",
      "free_disk_gb"         => 1028,
      "free_ram_mb"          => 7680,
      "hypervisor_hostname"  => "fake-mini",
      "hypervisor_type"      => "fake",
      "hypervisor_version"   => 1000,
      "id"                   => 2,
      "local_gb"             => 1028,
      "local_gb_used"        => 0,
      "memory_mb"            => 8192,
      "memory_mb_used"       => 512,
      "running_vms"          => 0,
      "service"              => {
        "host"            => "host1",
        "id"              => 7,
        "disabled_reason" => null
      },
      "vcpus"                => 1,
      "vcpus_used"           => 0
    }],
    "hypervisors_links" => [
      {
        "href" => "http://openstack.example.com/v2.1/6f70656e737461636b20342065766572/hypervisors/detail?limit=1&marker=2",
        "rel"  => "next"
      }
    ]
  }
  response
end

#list_imagesObject



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/list_images.rb', line 15

def list_images
  response = Excon::Response.new
  data = list_images_detail.body['images']
  images = []
  data.each do |image|
    images << image.reject { |key, _value| !['id', 'name', 'links'].include?(key) }
  end
  response.status = [200, 203][rand(2)]
  response.body = {'images' => images}
  response
end

#list_images_detail(_filters = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/openstack/compute/requests/list_images_detail.rb', line 16

def list_images_detail(_filters = {})
  response = Excon::Response.new

  images = data[:images].values
  images.each do |image|
    case image['status']
    when 'SAVING'
      if Time.now - data[:last_modified][:images][image['id']] >= Fog::Mock.delay
        image['status'] = 'ACTIVE'
      end
    end
  end

  response.status = [200, 203][rand(2)]
  response.body = {'images' => images.map { |image| image.reject { |key, _value| !['id', 'name', 'links', 'minRam', 'minDisk', 'metadata', 'status', 'updated'].include?(key) } }}
  response
end

#list_key_pairs(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/list_key_pairs.rb', line 16

def list_key_pairs(_options = {})
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "X-Compute-Request-Id" => "req-c373a42c-2825-4e60-8d34-99416ea850be",
    "Content-Type"         => "application/json",
    "Content-Length"       => "360",
    "Date"                 => Date.new
  }
  response.body = {
    "keypairs" => [{
      "keypair" => {
        "public_key"  => "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAAAgQDCdAZLjln1tJbLVVkNHjWFSoKen2nZbk39ZfqhZJOMdeFdz02GWBS4rcuHboeGg/gozKRwsLu4N6NLPlYtbK/NapJIvgO/djBp+FG1QZNtLPsx7j4hVJac3yISGms+Xtu4cEv6j5sFDzAgTQbWz0Z1+9qOq9ngdaoW+YClfQ== vagrant@nova\n",
        "name"        => "test_key",
        "fingerprint" => "97:86:f4:15:68:0c:7b:a7:e5:8f:f0:bd:1f:27:65:ad"
      }
    }]
  }
  response
end

#list_metadata(_collection_name, _parent_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/compute/requests/list_metadata.rb', line 15

def (_collection_name, _parent_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {}
  response
end

#list_os_interfaces(server_id) ⇒ Object



15
16
17
18
19
20
# File 'lib/fog/openstack/compute/requests/list_os_interfaces.rb', line 15

def list_os_interfaces(server_id)
  Excon::Response.new(
    :body   => {'interfaceAttachments' => data[:os_interfaces]},
    :status => 200
  )
end

#list_private_addresses(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/list_private_addresses.rb', line 15

def list_private_addresses(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    response.status = [200, 203][rand(2)]
    response.body = {'private' => server['addresses']['private']}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#list_public_addresses(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/list_public_addresses.rb', line 15

def list_public_addresses(server_id)
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    response.status = [200, 203][rand(2)]
    response.body = {'public' => server['addresses']['public']}
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end

#list_security_groups(options = {}) ⇒ Object



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
# File 'lib/fog/openstack/compute/requests/list_security_groups.rb', line 32

def list_security_groups(options = {})
  server_id = if options.kind_of?(Hash)
                options.delete(:server_id)
              else
                options
              end

  security_groups = data[:security_groups].values

  groups = if server_id
             server_group_names =
               Array(data[:server_security_group_map][server_id])

             server_group_names.map do |name|
               security_groups.find do |sg|
                 sg['name'] == name
               end
             end.compact
           else
             security_groups
           end

  Excon::Response.new(
    :body    => {'security_groups' => groups},
    :headers => {
      "X-Compute-Request-Id" => "req-#{Fog::Mock.random_base64(36)}",
      "Content-Type"         => "application/json",
      "Date"                 => Date.new
    },
    :status  => 200
  )
end

#list_server_groups(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
# File 'lib/fog/openstack/compute/requests/list_server_groups.rb', line 16

def list_server_groups(_options = {})
  groups = data[:server_groups].map do |id, group|
    group.merge('id' => id, 'project_id' => 'test-project', 'user_id' => 'test-user')
  end
  Excon::Response.new(
    :body   => {'server_groups' => groups},
    :status => 200
  )
end

#list_servers(_options = {}) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/openstack/compute/requests/list_servers.rb', line 22

def list_servers(_options = {})
  response = Excon::Response.new
  data = list_servers_detail.body['servers']
  servers = []
  data.each do |server|
    servers << server.reject { |key, _value| !['id', 'name', 'links'].include?(key) }
  end
  response.status = [200, 203][rand(2)]
  response.body = {'servers' => servers}
  response
end

#list_servers_detail(_filters = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'lib/fog/openstack/compute/requests/list_servers_detail.rb', line 23

def list_servers_detail(_filters = {})
  response = Excon::Response.new

  servers = data[:servers].values
  servers.each do |server|
    case server['status']
    when 'BUILD'
      if Time.now - data[:last_modified][:servers][server['id']] > Fog::Mock.delay * 2
        server['status'] = 'ACTIVE'
      end
    end
  end

  response.status = [200, 203][rand(2)]
  response.body = {'servers' => servers}
  response
end

#list_services(_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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/openstack/compute/requests/list_services.rb', line 16

def list_services(_parameters = nil)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "services" => [{
      "id"              => 1,
      "binary"          => "nova-scheduler",
      "host"            => "host1",
      "state"           => "up",
      "status"          => "disabled",
      "updated_at"      => "2012-10-29T13:42:02.000000",
      "zone"            => "internal",
      "disabled_reason" => "test2"
    },
                   {
                     "id"              => 2,
                     "binary"          => "nova-compute",
                     "host"            => "host1",
                     "state"           => "up",
                     "status"          => "disabled",
                     "updated_at"      => "2012-10-29T13:42:05.000000",
                     "zone"            => "nova",
                     "disabled_reason" => "test2"
                   },
                   {
                     "id"              => 3,
                     "binary"          => "nova-scheduler",
                     "host"            => "host2",
                     "state"           => "down",
                     "status"          => "enabled",
                     "updated_at"      => "2012-09-19T06:55:34.000000",
                     "zone"            => "internal",
                     "disabled_reason" => "nil"
                   },
                   {
                     "id"              => 4,
                     "binary"          => "nova-compute",
                     "host"            => "host2",
                     "state"           => "down",
                     "status"          => "disabled",
                     "updated_at"      => "2012-09-18T08:03:38.000000",
                     "zone"            => "nova",
                     "disabled_reason" => "test2"
                   }]
  }
  response
end

#list_snapshots(_options = true) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/fog/openstack/compute/requests/list_snapshots.rb', line 30

def list_snapshots(_options = true)
  response = Excon::Response.new
  response.status = 200
  snapshots = data[:snapshots].values
  response.body = {'snapshots' => snapshots}
  response
end

#list_snapshots_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/list_snapshots_detail.rb', line 16

def list_snapshots_detail(_options = {})
  response = Excon::Response.new
  response.status = 200
  snapshots = data[:snapshots].values
  response.body = {'snapshots' => snapshots}
  response
end

#list_tenants_with_flavor_access(flavor_ref) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/list_tenants_with_flavor_access.rb', line 15

def list_tenants_with_flavor_access(flavor_ref)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "flavor_access" => [{"tenant_id" => Fog::Mock.random_hex(33), "flavor_id" => flavor_ref.to_s}]
  }
  response
end

#list_usages(_date_start = nil, _date_end = nil, _detailed = false) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/list_usages.rb', line 21

def list_usages(_date_start = nil, _date_end = nil, _detailed = false)
  response        = Excon::Response.new
  response.status = 200
  response.body   = {"tenant_usages" => [{
    "total_memory_mb_usage" => 0.00036124444444444445,
    "total_vcpus_usage"     => 7.055555555555556e-07,
    "start"                 => "2012-03-06 05:05:56.349001",
    "tenant_id"             => "b97c8abba0c44a0987c63b858a4823e5",
    "stop"                  => "2012-03-06 05:05:56.349255",
    "total_hours"           => 7.055555555555556e-07,
    "total_local_gb_usage"  => 0.0
  }]}
  response
end

#list_volume_attachments(server_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/fog/openstack/compute/requests/list_volume_attachments.rb', line 15

def list_volume_attachments(server_id)
  Excon::Response.new(
    :body   => {
      :volumeAttachments => [{
        :device   => '/dev/vdd',
        :serverId => server_id,
        :id       => '24011ca7-9937-41e4-b19b-141307d1b656',
        :volumeId => '24011ca7-9937-41e4-b19b-141307d1b656'
      }]
    },
    :status => 200
  )
end

#list_volumes(_options = true) ⇒ Object



30
31
32
33
34
35
# File 'lib/fog/openstack/compute/requests/list_volumes.rb', line 30

def list_volumes(_options = true)
  Excon::Response.new(
    :body   => {'volumes' => data[:volumes].values},
    :status => 200
  )
end

#list_volumes_detail(_options = {}) ⇒ Object



16
17
18
19
20
21
# File 'lib/fog/openstack/compute/requests/list_volumes_detail.rb', line 16

def list_volumes_detail(_options = {})
  Excon::Response.new(
    :body   => {'volumes' => data[:volumes].values},
    :status => 200
  )
end

#list_zones(_options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/openstack/compute/requests/list_zones.rb', line 16

def list_zones(_options = {})
  Excon::Response.new(
    :body   => {"availabilityZoneInfo" => [
      {
        "zoneState" => {
          "available" => true
        },
        "hosts"     => nil,
        "zoneName"  => "nova"
      }
    ]},
    :status => 200
  )
end

#list_zones_detailed(_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
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
# File 'lib/fog/openstack/compute/requests/list_zones_detailed.rb', line 16

def list_zones_detailed(_options = {})
  Excon::Response.new(
    :body   => {
      "availabilityZoneInfo" => [
        {
          "zoneState" => {
            "available" => true
          },
          "hosts"     => {
            "instack.localdomain" => {
              "nova-conductor"   => {
                "available"  => true,
                "active"     => true,
                "updated_at" => "2015-07-22T07:40:08.000000"
              },
              "nova-scheduler"   => {
                "available"  => true,
                "active"     => true,
                "updated_at" => "2015-07-22T07:40:04.000000"
              },
              "nova-consoleauth" => {
                "available"  => true,
                "active"     => true,
                "updated_at" => "2015-07-22T07:40:09.000000"
              }
            }
          },
          "zoneName"  => "internal"
        },
        {
          "zoneState" => {
            "available" => true
          },
          "hosts"     => {
            "instack.localdomain" => {
              "nova-compute" => {
                "available"  => true,
                "active"     => true,
                "updated_at" => "2015-07-22T07:40:04.000000"
              }
            }
          },
          "zoneName"  => "nova"
        }
      ]
    },
    :status => 200
  )
end

#live_migrate_server(_server_id, _host, _block_migration, _disk_over_commit) ⇒ Object



18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/live_migrate_server.rb', line 18

def live_migrate_server(_server_id, _host, _block_migration, _disk_over_commit)
  response = Excon::Response.new
  response.status = 202
  response
end

#migrate_server(_server_id) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/migrate_server.rb', line 12

def migrate_server(_server_id)
  response = Excon::Response.new
  response.status = 202
  response
end

#pause_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/pause_server.rb', line 18

def pause_server(_server_id)
  true
end

#reboot_server(_server_id, _type = 'SOFT') ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/reboot_server.rb', line 12

def reboot_server(_server_id, _type = 'SOFT')
  response = Excon::Response.new
  response.status = 202
  response
end

#rebuild_server(server_id, _image_ref, _name, _admin_pass = nil, _metadata = nil, _personality = nil) ⇒ Object



26
27
28
29
30
# File 'lib/fog/openstack/compute/requests/rebuild_server.rb', line 26

def rebuild_server(server_id, _image_ref, _name, _admin_pass = nil,  = nil, _personality = nil)
  response = get_server_details(server_id)
  response.body['server']['status'] = "REBUILD"
  response
end

#release_address(_address_id) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/release_address.rb', line 15

def release_address(_address_id)
  response = Excon::Response.new
  response.status = 202
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {}
  response
end

#remote_consoles(_server_id, _protocol, _type) ⇒ Object



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/openstack/compute/requests/remote_consoles.rb', line 39

def remote_consoles(_server_id, _protocol, _type)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "remote_console" => {
      "url"      => "http://192.168.27.100:6080/vnc_auto.html?token=e629bcbf-6f9e-4276-9ea1-d6eb0e618da5",
      "type"     => "novnc",
      "protocol" => "vnc"
    }
  }
  response
end

#remove_aggregate_host(_uuid, _host_uuid) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/remove_aggregate_host.rb', line 17

def remove_aggregate_host(_uuid, _host_uuid)
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#remove_fixed_ip(_server_id, _address) ⇒ Object



23
24
25
# File 'lib/fog/openstack/compute/requests/remove_fixed_ip.rb', line 23

def remove_fixed_ip(_server_id, _address)
  true
end

#remove_flavor_access(_flavor_ref, _tenant_id) ⇒ Object



18
19
20
21
22
23
24
25
# File 'lib/fog/openstack/compute/requests/remove_flavor_access.rb', line 18

def remove_flavor_access(_flavor_ref, _tenant_id)
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "flavor_access" => []
  }
  response
end

#remove_security_group(_server_id, _group_name) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/remove_security_group.rb', line 12

def remove_security_group(_server_id, _group_name)
  response = Excon::Response.new
  response.status = 200
  response
end

#rescue_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/rescue_server.rb', line 18

def rescue_server(_server_id)
  true
end

#reset_dataObject



368
369
370
# File 'lib/fog/openstack/compute.rb', line 368

def reset_data
  self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
end

#reset_server_state(server_id, status) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/reset_server_state.rb', line 12

def reset_server_state(server_id, status)
  response = get_server_details(server_id)
  response.body['server']['status'] = status.upcase
  response
end

#resize_server(_server_id, _flavor_ref) ⇒ Object



12
13
14
15
16
# File 'lib/fog/openstack/compute/requests/resize_server.rb', line 12

def resize_server(_server_id, _flavor_ref)
  response = Excon::Response.new
  response.status = 202
  response
end

#resume_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/resume_server.rb', line 18

def resume_server(_server_id)
  true
end

#revert_resize_server(server_id) ⇒ Object



12
13
14
15
16
17
18
19
20
21
22
# File 'lib/fog/openstack/compute/requests/revert_resize_server.rb', line 12

def revert_resize_server(server_id)
  response = Excon::Response.new
  response.status = 202

  data[:servers][server_id]['flavorId'] = data[:servers][server_id]['old_flavorId']
  data[:servers][server_id].delete('old_flavorId')
  data[:last_modified][:servers][server_id] = Time.now
  data[:servers][server_id]['status'] = 'ACTIVE'

  response
end

#server_actions(server_id) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/server_actions.rb', line 21

def server_actions(server_id)
  response = Excon::Response.new
  response.status = 200
  response.body = [{
    'instance_uuid' => server_id,
    'user_id'       => '7067d67a2b23435ca2366588680b66c3',
    'start_time'    => Time.now.iso8601,
    'request_id'    => "req-#{server_id}",
    'action'        => 'stop',
    'message'       => nil,
    'project_id'    => '9d5d0b877cf449fdae078659cfa12e86'
  }]
  response
end

#server_diagnostics(server_id) ⇒ Object



20
21
# File 'lib/fog/openstack/compute/requests/server_diagnostics.rb', line 20

def server_diagnostics(server_id)
end

#set_metadata(collection_name, parent_id, metadata = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/set_metadata.rb', line 16

def (collection_name, parent_id,  = {})
  if collection_name == "images"
    unless list_images_detail.body['images'].find { |image| image['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  if collection_name == "servers"
    unless list_servers_detail.body['servers'].find { |server| server['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  response = Excon::Response.new
  response.body = {"metadata" => }
  response.status = 200
  response
end

#set_tenant(_tenant) ⇒ Object



13
14
15
# File 'lib/fog/openstack/compute/requests/set_tenant.rb', line 13

def set_tenant(_tenant)
  true
end

#shelve_offload_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/shelve_offload_server.rb', line 18

def shelve_offload_server(_server_id)
  true
end

#shelve_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/shelve_server.rb', line 18

def shelve_server(_server_id)
  true
end

#start_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/start_server.rb', line 18

def start_server(_server_id)
  true
end

#stop_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/stop_server.rb', line 18

def stop_server(_server_id)
  true
end

#suspend_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/suspend_server.rb', line 18

def suspend_server(_server_id)
  true
end

#unpause_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/unpause_server.rb', line 18

def unpause_server(_server_id)
  true
end

#unshelve_server(_server_id) ⇒ Object



18
19
20
# File 'lib/fog/openstack/compute/requests/unshelve_server.rb', line 18

def unshelve_server(_server_id)
  true
end

#update_aggregate(_uuid, _options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/fog/openstack/compute/requests/update_aggregate.rb', line 23

def update_aggregate(_uuid, _options = {})
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response.body = {'aggregate' => data[:aggregates].first}
  response
end

#update_aggregate_metadata(_uuid, _metadata = {}) ⇒ Object



17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/openstack/compute/requests/update_aggregate_metadata.rb', line 17

def (_uuid,  = {})
  response = Excon::Response.new
  response.status = 200
  response.headers = {
    "Content-Type"   => "text/html; charset=UTF-8",
    "Content-Length" => "0",
    "Date"           => Date.new
  }
  response
end

#update_flavor_metadata(_flavor_ref, key, value) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/fog/openstack/compute/requests/update_flavor_metadata.rb', line 18

def (_flavor_ref, key, value)
  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 = {key => value}
  response
end

#update_meta(collection_name, parent_id, key, value) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/update_meta.rb', line 16

def update_meta(collection_name, parent_id, key, value)
  if collection_name == "images"
    unless list_images_detail.body['images'].find { |image| image['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  if collection_name == "servers"
    unless list_servers_detail.body['servers'].find { |server| server['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  # FIXME: join w/ existing metadata here
  response = Excon::Response.new
  response.body = {"metadata" => {key => value}}
  response.status = 200
  response
end

#update_metadata(collection_name, parent_id, metadata = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/fog/openstack/compute/requests/update_metadata.rb', line 16

def (collection_name, parent_id,  = {})
  if collection_name == "images"
    unless list_images_detail.body['images'].find { |image| image['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  if collection_name == "servers"
    unless list_servers_detail.body['servers'].find { |server| server['id'] == parent_id }
      raise Fog::OpenStack::Compute::NotFound
    end
  end

  # FIXME: join w/ existing metadata here
  response = Excon::Response.new
  response.body = {"metadata" => }
  response.status = 200
  response
end

#update_quota(_tenant_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
# File 'lib/fog/openstack/compute/requests/update_quota.rb', line 16

def update_quota(_tenant_id, options = {})
  data[:quota_updated] = data[:quota].merge options

  response = Excon::Response.new
  response.status = 200
  response.body = {'quota_set' => data[:quota_updated]}
  response
end

#update_server(server_id, options = {}) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/openstack/compute/requests/update_server.rb', line 16

def update_server(server_id, options = {})
  response = Excon::Response.new
  server = list_servers_detail.body['servers'].find { |srv| srv['id'] == server_id }
  if server
    if options['name']
      server['name'] = options['name']
    end
    response.status = 200
    response
  else
    raise Fog::OpenStack::Compute::NotFound
  end
end