Class: Fog::Network::SakuraCloud::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/sakuracloud/requests/network/create_router.rb,
lib/fog/sakuracloud/network.rb,
lib/fog/sakuracloud/requests/network/list_routers.rb,
lib/fog/sakuracloud/requests/network/create_switch.rb,
lib/fog/sakuracloud/requests/network/delete_router.rb,
lib/fog/sakuracloud/requests/network/delete_switch.rb,
lib/fog/sakuracloud/requests/network/list_switches.rb,
lib/fog/sakuracloud/requests/network/list_interfaces.rb,
lib/fog/sakuracloud/requests/network/delete_interface.rb,
lib/fog/sakuracloud/requests/network/collect_monitor_router.rb,
lib/fog/sakuracloud/requests/network/change_router_bandwidth.rb,
lib/fog/sakuracloud/requests/network/regist_interface_to_server.rb,
lib/fog/sakuracloud/requests/network/connect_interface_to_switch.rb

Overview

Real

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



63
64
65
66
# File 'lib/fog/sakuracloud/network.rb', line 63

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

Class Method Details

.dataObject



51
52
53
54
55
56
57
# File 'lib/fog/sakuracloud/network.rb', line 51

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

.resetObject



59
60
61
# File 'lib/fog/sakuracloud/network.rb', line 59

def self.reset
  @data = nil
end

Instance Method Details

#change_router_bandwidth(id, bandwidthmbps) ⇒ Object



27
28
29
30
31
32
33
34
35
36
# File 'lib/fog/sakuracloud/requests/network/change_router_bandwidth.rb', line 27

def change_router_bandwidth( id, bandwidthmbps )
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "Internet"=>{"ID"=>"112701091977"},
    "Success"=>true,
    "is_ok"=>true
  }
  response
end

#collect_monitor_router(id) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/fog/sakuracloud/requests/network/collect_monitor_router.rb', line 24

def collect_monitor_router( id )
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "Data"=>{
      "2015-12-16T18:00:00+09:00"=>{
        "In"=>500000,
        "Out"=>70000000
      }
    },
    "is_ok"=>true
  }
  response
end

#create_router(options) ⇒ Object



31
32
33
34
35
36
37
# File 'lib/fog/sakuracloud/requests/network/create_router.rb', line 31

def create_router(options)
  response = Excon::Response.new
  response.status = 202
  response.body = {
  }
  response
end

#create_switch(options) ⇒ Object



27
28
29
30
31
32
33
# File 'lib/fog/sakuracloud/requests/network/create_switch.rb', line 27

def create_switch(options)
  response = Excon::Response.new
  response.status = 201
  response.body = {
  }
  response
end

#dataObject



68
69
70
71
# File 'lib/fog/sakuracloud/network.rb', line 68

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

#delete_interface(id) ⇒ Object



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

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

#delete_router(id) ⇒ Object



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

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

#delete_switch(id) ⇒ Object



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

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

#list_interfaces(options = {}) ⇒ Object



29
30
31
32
33
34
35
# File 'lib/fog/sakuracloud/requests/network/list_interfaces.rb', line 29

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

#list_routers(options = {}) ⇒ Object



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

def list_routers(options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "Internet"=>[
      {"Index"=>0,
       "ID"=>"112600707538",
       "Switch"=>{
         "ID"=>"112600707539",
         "Name"=>"router2"
       }
    }
    ],
    "is_ok"=>true
  }
  response
end

#list_switches(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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# File 'lib/fog/sakuracloud/requests/network/list_switches.rb', line 19

def list_switches(options = {})
  response = Excon::Response.new
  response.status = 200
  response.body = {
    "Switches"=>
    [{"Index"=>0,
      "ID"=>"112600703732",
      "Name"=>"foobar1",
      "Description"=>"",
      "ServerCount"=>0,
      "ApplianceCount"=>0,
      "HybridConnection"=>nil,
      "ServiceClass"=>"cloud/switch/default",
      "CreatedAt"=>"2014-09-05T16:35:41+09:00",
      "Subnets"=>
    [{"ID"=>nil,
      "NetworkAddress"=>nil,
      "NetworkMaskLen"=>nil,
      "DefaultRoute"=>nil,
      "NextHop"=>nil,
      "StaticRoute"=>nil,
      "ServiceClass"=>nil,
      "IPAddresses"=>{"Min"=>nil, "Max"=>nil},
      "Internet"=>{"ID"=>nil, "Name"=>nil, "BandWidthMbps"=>nil, "ServiceClass"=>nil}}],
    "IPv6Nets"=>[],
    "Internet"=>nil,
    "Bridge"=>nil},
    {"Index"=>1,
     "ID"=>"112600703734",
     "Name"=>"foobar2",
     "Description"=>"",
     "ServerCount"=>1,
     "ApplianceCount"=>0,
     "HybridConnection"=>nil,
     "ServiceClass"=>"cloud/switch/default",
     "CreatedAt"=>"2014-09-05T16:36:13+09:00",
     "Subnets"=>
    [{"ID"=>1036,
      "NetworkAddress"=>"133.242.241.240",
      "NetworkMaskLen"=>28,
      "DefaultRoute"=>"133.242.241.241",
      "NextHop"=>nil,
      "StaticRoute"=>nil,
      "ServiceClass"=>"cloud/global-ipaddress-v4/28",
      "IPAddresses"=>{"Min"=>"133.242.241.244", "Max"=>"133.242.241.254"},
      "Internet"=>{"ID"=>"112600703733", "Name"=>"hogehoge2", "BandWidthMbps"=>100, "ServiceClass"=>"cloud/internet/router/100m"}}],
    "IPv6Nets"=>[],
    "Internet"=>{"ID"=>"112600703733", "Name"=>"hogehoge2", "BandWidthMbps"=>100, "Scope"=>"user", "ServiceClass"=>"cloud/internet/router/100m"},
    "Bridge"=>nil}]
  }
  response
end

#regist_interface_to_server(id, switch_id) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/fog/sakuracloud/requests/network/regist_interface_to_server.rb', line 30

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

#reset_dataObject



73
74
75
76
# File 'lib/fog/sakuracloud/network.rb', line 73

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