Class: Fog::Volume::SakuraCloud::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/sakuracloud/requests/volume/attach_disk.rb,
lib/fog/sakuracloud/volume.rb,
lib/fog/sakuracloud/requests/volume/list_disks.rb,
lib/fog/sakuracloud/requests/volume/list_plans.rb,
lib/fog/sakuracloud/requests/volume/create_disk.rb,
lib/fog/sakuracloud/requests/volume/delete_disk.rb,
lib/fog/sakuracloud/requests/volume/list_archives.rb,
lib/fog/sakuracloud/requests/volume/configure_disk.rb

Overview

Real

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



71
72
73
74
# File 'lib/fog/sakuracloud/volume.rb', line 71

def initialize(options={})
  @sakuracloud_api_token        = options[:sakuracloud_api_token]
  @sakuracloud_api_token_secret = options[:sakuracloud_api_token_secret]
end

Class Method Details

.dataObject



57
58
59
60
61
62
63
64
65
# File 'lib/fog/sakuracloud/volume.rb', line 57

def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :disks => [],
      :plans => [],
      :archives => []
    }
  end
end

.resetObject



67
68
69
# File 'lib/fog/sakuracloud/volume.rb', line 67

def self.reset
  @data = nil
end

Instance Method Details

#attach_disk(disk_id, server_id) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/fog/sakuracloud/requests/volume/attach_disk.rb', line 20

def attach_disk( disk_id, server_id )
  response = Excon::Response.new
  response.status = 200
  response.body = {
  }
  response
end

#configure_disk(disk_id, sshkey_id) ⇒ Object



25
26
27
28
29
30
31
# File 'lib/fog/sakuracloud/requests/volume/configure_disk.rb', line 25

def configure_disk( disk_id, sshkey_id )
  response = Excon::Response.new
  response.status = 200
  response.body = {
  }
  response
end

#create_disk(name, plan, sourcearchive) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/fog/sakuracloud/requests/volume/create_disk.rb', line 33

def create_disk( name, plan, sourcearchive )
  response = Excon::Response.new
  response.status = 202
  response.body = {
  }
  response
end

#dataObject



76
77
78
79
# File 'lib/fog/sakuracloud/volume.rb', line 76

def data
  self.class.data[@sakuracloud_api_token]
  self.class.data[@sakuracloud_api_token_secret]
end

#delete_disk(id) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/fog/sakuracloud/requests/volume/delete_disk.rb', line 20

def delete_disk( id )
  response = Excon::Response.new
  response.status = 200
  response.body = {
  }
  response
end

#list_archives(options = {}) ⇒ 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
# File 'lib/fog/sakuracloud/requests/volume/list_archives.rb', line 19

def list_archives(options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
  "Archives" =>
    [
    {"Index"=>0,
      "ID"=>112500514887,
      "Name"=>"CentOS 5.10 64bit (基本セット)",
      "Availability"=>"available",
      "SizeMB"=>20480,
      "Plan"=>{"ID"=>2, "StorageClass"=>"iscsi1204", "Name"=>"標準プラン"}
    },
    {"Index"=>1,
      "ID"=>112500571575,
      "Name"=>"CentOS 6.5 64bit (基本セット)",
      "Availability"=>"available",
      "SizeMB"=>102400,
      "Plan"=>{"ID"=>2, "StorageClass"=>"iscsi1204", "Name"=>"標準プラン"}
    }
    ]
  }
  response
end

#list_disks(options = {}) ⇒ 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
45
46
# File 'lib/fog/sakuracloud/requests/volume/list_disks.rb', line 19

def list_disks(options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
  "Disks" =>
    [
    {"Index" => 0,
      "ID" =>112600053890,
      "Name" =>"foober1",
      "Connection" => "virtio",
      "Availability"=>"available",
      "SizeMB"=>20480,
      "Plan"=> {},
      "SourceDisk" => nil,
      "SourceArchive" => {}},
    {"Index" => 1,
      "ID" =>112600053891,
      "Name" =>"foober2",
      "Connection"  => "virtio",
      "Availability"=>"available",
      "SizeMB"=>20480,
      "Plan"=> {},
      "SourceDisk" => nil,
      "SourceArchive" => {}}
    ]
  }
  response
end

#list_plans(options = {}) ⇒ Object



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/sakuracloud/requests/volume/list_plans.rb', line 19

def list_plans(options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
  "DiskPlans" =>
    [
    {"Index"=>0,
      "ID"=>4,
      "Name"=>"SSDプラン",
      "Availability"=>"available"},
    {"Index"=>1,
      "ID"=>2,
      "Name"=>"標準プラン",
      "Availability"=>"available"}
    ]
  }
  response
end

#reset_dataObject



81
82
83
84
# File 'lib/fog/sakuracloud/volume.rb', line 81

def reset_data
  self.class.data.delete(@sakuracloud_api_token)
  self.class.data.delete(@sakuracloud_api_token_secret)
end