Class: Fog::Compute::Fogdocker::Mock

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/fogdocker/compute.rb,
lib/fog/fogdocker/requests/compute/image_all.rb,
lib/fog/fogdocker/requests/compute/image_get.rb,
lib/fog/fogdocker/requests/compute/api_version.rb,
lib/fog/fogdocker/requests/compute/image_create.rb,
lib/fog/fogdocker/requests/compute/image_delete.rb,
lib/fog/fogdocker/requests/compute/image_search.rb,
lib/fog/fogdocker/requests/compute/container_all.rb,
lib/fog/fogdocker/requests/compute/container_get.rb,
lib/fog/fogdocker/requests/compute/container_action.rb,
lib/fog/fogdocker/requests/compute/container_commit.rb,
lib/fog/fogdocker/requests/compute/container_create.rb,
lib/fog/fogdocker/requests/compute/container_delete.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Mock

Returns a new instance of Mock.



31
32
# File 'lib/fog/fogdocker/compute.rb', line 31

def initialize(options={})
end

Instance Method Details

#api_versionObject



10
11
12
# File 'lib/fog/fogdocker/requests/compute/api_version.rb', line 10

def api_version
  {'Version' => '1.6'}
end

#container_action(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


27
28
29
30
31
# File 'lib/fog/fogdocker/requests/compute/container_action.rb', line 27

def container_action(options = {})
  raise ArgumentError, "id is a required parameter" unless options.key? :id
  raise ArgumentError, "action is a required parameter" unless options.key? :action
  response_matcher(options[:action])
end

#container_all(filters = {}) ⇒ Object



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

def container_all(filters = {})
  [
      {'id'         => '2ce79789656e4f7474624be6496dc6d988899af30d556574389a19aade2f9650',
       'image'      => 'mattdm/fedora:f19',
       'command'    => '/bin/bash',
       'created'    => '1389876158',
       'status'     => 'Up 45 hours',
       'state_running' => true,
       'ports'      =>  nil,
       'sizerw'     =>  0,
       'sizerootfs' =>  0,
       'name'       => '123123123',
       'names'      =>  ['/boring_engelbert']
      }
  ]
end

#container_commit(options) ⇒ Object



13
14
15
16
17
18
# File 'lib/fog/fogdocker/requests/compute/container_commit.rb', line 13

def container_commit(options)
  {'id'=>'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef3',
   'repotags' => ['repo/other'],
   'created' => 1389877693,
   'size' => 3265536}
end

#container_create(attrs) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/fog/fogdocker/requests/compute/container_create.rb', line 35

def container_create(attrs)
  {'id'         => '2ce79789656e4f7474624be6496dc6d988899af30d556574389a19aade2f9650',
   'image'      => 'mattdm/fedora:f19',
   'command'    => '/bin/bash',
   'created'    => '1389876158',
   'status'     => 'Up 45 hours',
   'state'      => {'running' => 'true'},
   'ports'      =>  nil,
   'sizerw'     =>  0,
   'sizerootfs' =>  0,
   'name'       => '123123123',
   'names'      =>  ['/boring_engelbert']
  }
end

#container_delete(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
# File 'lib/fog/fogdocker/requests/compute/container_delete.rb', line 14

def container_delete(options = {})
  raise ArgumentError, "instance id is a required parameter" unless options.key? :id
  true
end

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

def container_get(id)
  {'id'                         => '2ce79789656e4f7474624be6496dc6d988899af30d556574389a19aade2f9650',
   'image'                      => 'mattdm/fedora:f19',
   'command'                    => '/bin/bash',
   'created'                    => '1389876158',
   'status'                     => 'Up 45 hours',
   'state_running'              => true,
   'network_settings_ipaddress' => '172.17.0.2',
   'config_memory'              => '1024',
   'config_cpu_sets'            => '0-3',
   'config_cpu_shares'          => '20',
   'config_hostname'            => '21341234',
   'config_attach_stdin'        => true,
   'config_attach_stdout'       => true,
   'config_attach_stderr'       => true,
   'ports'                      => nil,
   'config_tty'                 => true,
   'hostconfig_privileged'      => true,
   'hostconfig_links'           => nil,
   'hostconfig_port_bindings'   => { "29321/tcp" => [{"HostIp"=>"", "HostPort"=>"3001"}],
                                     "39212/tcp" => [{"HostIp"=>"", "HostPort"=>"2030"}]},
   'state_exit_code'            => 0,
   'state_pid'                  => 2932,
   'cpu_shares'                 => 0,
   'volumes'                    => nil,
   'config_exposed_ports'       => { "29321/tcp" => {}, "39212/tcp" => {} },
   'sizerw'                     => 0,
   'sizerootfs'                 => 0,
   'environment_variables'      => ["HOME=/mydir", "SAMPLEENV=samplevalue"],
   'name'                       => '123123123',
   'names'                      =>  ['/boring_engelbert']}
end

#image_all(filters = {}) ⇒ Object



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

def image_all(filters = {})
  [
    {'id'=>'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef2',
     'repotags' => ['repo/one'],
     'created' => 1389877693,
     'size' => 3265536},
    {'id'=>'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef3',
     'repotags' => ['repo/other'],
     'created' => 1389877693,
     'size' => 3265536}
  ]
end

#image_create(attrs) ⇒ Object



11
12
13
# File 'lib/fog/fogdocker/requests/compute/image_create.rb', line 11

def image_create(attrs)
  {'id'=>'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef2'}
end

#image_delete(options = {}) ⇒ Object

Raises:

  • (ArgumentError)


13
14
15
16
# File 'lib/fog/fogdocker/requests/compute/image_delete.rb', line 13

def image_delete(options = {})
  raise ArgumentError, "instance id is a required parameter" unless options.key? :id
  "[{'Deleted':'b15c1423ba157d0f7ac83cba178390c421bb8d536e7e7857580fc10f2d53e1b9'}]"
end

#image_get(id) ⇒ Object



10
11
12
13
14
15
# File 'lib/fog/fogdocker/requests/compute/image_get.rb', line 10

def image_get(id)
  {'id'=>'a6b02c7ca29a22619f7d0e59062323247739bc0cd375d619f305f0b519af4ef3',
   'repotags' => ['repo/other'],
   'created' => 1389877693,
   'size' => 3265536}
end

#image_search(query = {}) ⇒ Object



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

def image_search(query = {})
  [
      {"description" => "",
       "is_official" => false,
       "is_automated" => false,
       "name" => "wma55/u1210sshd",
       "star_count" => 0},
      {"description" => "",
       "is_official" => false,
       "is_automated" => false,
       "name" => "jdswinbank/sshd",
       "star_count" => 0}
  ]
end