Class: Fog::Compute::OracleCloud::Real

Inherits:
Object
  • Object
show all
Defined in:
lib/fog/oraclecloud/compute.rb,
lib/fog/oraclecloud/requests/compute/get_image.rb,
lib/fog/oraclecloud/requests/compute/get_ssh_key.rb,
lib/fog/oraclecloud/requests/compute/list_images.rb,
lib/fog/oraclecloud/requests/compute/create_image.rb,
lib/fog/oraclecloud/requests/compute/delete_image.rb,
lib/fog/oraclecloud/requests/compute/get_instance.rb,
lib/fog/oraclecloud/requests/compute/list_volumes.rb,
lib/fog/oraclecloud/requests/compute/update_image.rb,
lib/fog/oraclecloud/requests/compute/create_volume.rb,
lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb,
lib/fog/oraclecloud/requests/compute/create_ssh_key.rb,
lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb,
lib/fog/oraclecloud/requests/compute/get_image_list.rb,
lib/fog/oraclecloud/requests/compute/list_instances.rb,
lib/fog/oraclecloud/requests/compute/update_ssh_key.rb,
lib/fog/oraclecloud/requests/compute/create_instance.rb,
lib/fog/oraclecloud/requests/compute/delete_instance.rb,
lib/fog/oraclecloud/requests/compute/list_image_lists.rb,
lib/fog/oraclecloud/requests/compute/create_image_list.rb,
lib/fog/oraclecloud/requests/compute/delete_image_list.rb,
lib/fog/oraclecloud/requests/compute/get_orchestration.rb,
lib/fog/oraclecloud/requests/compute/get_security_rule.rb,
lib/fog/oraclecloud/requests/compute/update_image_list.rb,
lib/fog/oraclecloud/requests/compute/stop_orchestration.rb,
lib/fog/oraclecloud/requests/compute/list_orchestrations.rb,
lib/fog/oraclecloud/requests/compute/list_security_lists.rb,
lib/fog/oraclecloud/requests/compute/list_security_rules.rb,
lib/fog/oraclecloud/requests/compute/start_orchestration.rb,
lib/fog/oraclecloud/requests/compute/create_orchestration.rb,
lib/fog/oraclecloud/requests/compute/create_security_rule.rb,
lib/fog/oraclecloud/requests/compute/delete_orchestration.rb,
lib/fog/oraclecloud/requests/compute/delete_security_rule.rb,
lib/fog/oraclecloud/requests/compute/update_orchestration.rb,
lib/fog/oraclecloud/requests/compute/get_security_application.rb,
lib/fog/oraclecloud/requests/compute/list_security_applications.rb,
lib/fog/oraclecloud/requests/compute/create_security_application.rb,
lib/fog/oraclecloud/requests/compute/delete_security_application.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



84
85
86
87
88
89
90
91
92
93
94
# File 'lib/fog/oraclecloud/compute.rb', line 84

def initialize(options={})
	@username = options[:oracle_username]
	@password = options[:oracle_password]
	@identity_domain   = options[:oracle_domain]
	@api_endpoint   = options[:oracle_compute_api]

   @connection = Fog::XML::Connection.new(@api_endpoint)

   # Get authentication token
   authenticate
end

Instance Method Details

#authenticateObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# File 'lib/fog/oraclecloud/compute.rb', line 96

def authenticate()
	begin
     response = @connection.request({
     	:expects  => 204,
   	  :method   => 'POST',
     	:path     => "/authenticate/",
     	:headers  => {
     		'Content-Type'	=> 'application/oracle-compute-v3+json'
     	},
     	:body			=> Fog::JSON.encode({
     		'user' 		=> "/Compute-#{@identity_domain}/#{@username}",
     		'password'=> @password
     	})
     })
   rescue Excon::Errors::HTTPStatusError => error
     error
   end
   if response.nil? || !response.headers['Set-Cookie'] then
   	raise Error.new('Could not authenticate to Compute Cloud Service. Check your athentication details in your config')
   end
   @auth_cookie = response.headers['Set-Cookie']
end

#create_image(account, name, no_upload, file, sizes) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/fog/oraclecloud/requests/compute/create_image.rb', line 5

def create_image (, name, no_upload, file, sizes)
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
     'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'account'					    => ,
     'no_upload'					  => no_upload,
     'file'                => file,
     'sizes'               => sizes
   }
   body_data = body_data.reject {|key, value| value.nil?}

   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/oraclecloud/requests/compute/create_image_list.rb', line 5

def create_image_list (name, description, options={})
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
     'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'description'					=> description,
     'default'					   	=> options[:default]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_instance(name, shape, imagelist, label, sshkeys) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/fog/oraclecloud/requests/compute/create_instance.rb', line 5

def create_instance (name, shape, imagelist, label, sshkeys)
   # This will create an instance using a Launchplan. Consider using an orchestration plan for more control
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
     'instances'    => [{
       'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
       'shape'					      => shape,
       'imagelist'					  => imagelist,
       'label'               => label,
       'sshkeys'             => sshkeys
     }]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/launchplan/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_orchestration(name, oplans, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
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
# File 'lib/fog/oraclecloud/requests/compute/create_orchestration.rb', line 5

def create_orchestration (name, oplans, options={})

   # Clean up names in case they haven't provided the fully resolved names
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   oplans.map do |oplan|
     oplan['objects'].map do |object|
       if oplan['obj_type'] == 'launchplan' then
         object['instances'].map do |instance|
           if !instance['name'].start_with?("/Compute-") then
             instance['name'] = "/Compute-#{@identity_domain}/#{@username}/#{instance['name']}"
           end
         end
       else
         if !object['name'].start_with?("/Compute-") then
           object['name'] = "/Compute-#{@identity_domain}/#{@username}/#{object['name']}"
         end
       end
     end
   end
   body_data     = {
     'name' 		      => "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'oplans'        => oplans,
     'relationships' => options[:relationships],
     'description'   => options[:description],
     'account'       => options[:account],
     'schedule'      => options[:schedule]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/orchestration/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_security_application(name, protocol, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/oraclecloud/requests/compute/create_security_application.rb', line 5

def create_security_application(name, protocol, options={})
   body_data     = {
     'name'             		=> name,
     'protocol'						=> protocol,
     'dport'								=> options[:dport],
     'icmptype'						=> options[:icmptype],
     'icmpcode'						=> options[:icmpcode],
     'description'					=> options[:description]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/secapplication/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_security_rule(name, src_list, dst_list, application, action, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/oraclecloud/requests/compute/create_security_rule.rb', line 5

def create_security_rule(name, src_list, dst_list, application, action, options={})
   body_data     = {
     'name'             		=> name,
     'src_list'						=> src_list,
     'dst_list'						=> dst_list,
     'application'					=> application,
     'action'					   	=> action,
     'description'         => options[:description],
     'disabled'            => options[:disabled]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/secrule/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_ssh_key(name, enabled, key) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/oraclecloud/requests/compute/create_ssh_key.rb', line 5

def create_ssh_key (name, enabled, key)
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
       'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
       'enabled'					    => enabled,
       'key'					        => key
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/sshkey/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

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



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/fog/oraclecloud/requests/compute/create_volume.rb', line 5

def create_volume(name, size, high_latency = false, options={})
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", '' # Just in case it's already set
   body_data     = {
     'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'size'						    => size,
     'properties'          => []
   }
   body_data['properties'].push(high_latency ? "/oracle/public/storage/latency" : '/oracle/public/storage/default')
   body_data = body_data.reject {|key, value| value.nil?}

   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/storage/volume/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_image(name, version) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/oraclecloud/requests/compute/delete_image.rb', line 5

def delete_image (name, version)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}/entry/#{version}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_image_list(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/oraclecloud/requests/compute/delete_image_list.rb', line 5

def delete_image_list (name)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_instance(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/oraclecloud/requests/compute/delete_instance.rb', line 5

def delete_instance (name)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end         
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/instance#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_orchestration(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/oraclecloud/requests/compute/delete_orchestration.rb', line 5

def delete_orchestration (name)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end         
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/orchestration#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_security_application(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/oraclecloud/requests/compute/delete_security_application.rb', line 5

def delete_security_application(name)
	# Just in case it's already set
	name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
	request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/secapplication/Compute-#{@identity_domain}/#{@username}/#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_security_rule(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/oraclecloud/requests/compute/delete_security_rule.rb', line 5

def delete_security_rule(name)
	# Just in case it's already set
	name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
	request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#delete_ssh_key(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/oraclecloud/requests/compute/delete_ssh_key.rb', line 5

def delete_ssh_key (name)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end         
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/sshkey#{name}",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#get_image(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/oraclecloud/requests/compute/get_image.rb', line 5

def get_image(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/machineimage/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_image_list(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/oraclecloud/requests/compute/get_image_list.rb', line 5

def get_image_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_instance(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/oraclecloud/requests/compute/get_instance.rb', line 5

def get_instance(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/instance#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_orchestration(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/oraclecloud/requests/compute/get_orchestration.rb', line 5

def get_orchestration(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/orchestration#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_security_application(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/oraclecloud/requests/compute/get_security_application.rb', line 5

def get_security_application(name)
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secapplication/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_security_rule(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/oraclecloud/requests/compute/get_security_rule.rb', line 5

def get_security_rule(name)
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#get_ssh_key(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/oraclecloud/requests/compute/get_ssh_key.rb', line 5

def get_ssh_key(name)
  if !name.start_with?("/Compute-") then
    # They haven't provided a well formed name, add their name in
    name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
  end
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/sshkey#{name}",
    :headers  => {
      'Content-Type' => 'application/oracle-compute-v3+json',
      'Accept' => 'application/oracle-compute-v3+json'
    }
  )
  response
end

#list_image_listsObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_image_lists.rb', line 5

def list_image_lists
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#list_imagesObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_images.rb', line 5

def list_images
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/machineimage/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#list_instancesObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_instances.rb', line 5

def list_instances
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/instance/Compute-#{@identity_domain}/"
  )
  response
end

#list_orchestrationsObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_orchestrations.rb', line 5

def list_orchestrations
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/orchestration/Compute-#{@identity_domain}/"
  )
  response
end

#list_security_applicationsObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_security_applications.rb', line 5

def list_security_applications
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secapplication/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#list_security_listsObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_security_lists.rb', line 5

def list_security_lists
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/seclist/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#list_security_rulesObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_security_rules.rb', line 5

def list_security_rules
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/secrule/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#list_ssh_keysObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_ssh_keys.rb', line 5

def list_ssh_keys
  response = request(
    :expects => 200,
    :method  => 'GET',
    :path    => "/sshkey/Compute-#{@identity_domain}/"
  )
  response
end

#list_volumesObject



5
6
7
8
9
10
11
12
# File 'lib/fog/oraclecloud/requests/compute/list_volumes.rb', line 5

def list_volumes
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/volume/Compute-#{@identity_domain}/#{@username}/"
  )
  response
end

#request(params, parse_json = true, &block) ⇒ Object



119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
# File 'lib/fog/oraclecloud/compute.rb', line 119

def request(params, parse_json = true, &block)
					begin
						response = @connection.request(params.merge!({
							:headers  => {
'Cookie' => @auth_cookie
							}.merge!(params[:headers] || {})
						}), &block)
					rescue Excon::Errors::HTTPStatusError => error
						raise case error
						when Excon::Errors::NotFound
							Fog::Compute::OracleCloud::NotFound.slurp(error)
						when Excon::Errors::Conflict
							data = Fog::JSON.decode(error.response.body)
							raise Error.new(data['message'])
						else
							error
						end
					end
					if !response.body.empty? && parse_json
    response.body = Fog::JSON.decode(response.body)
  end
  response
end

#start_orchestration(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/oraclecloud/requests/compute/start_orchestration.rb', line 5

def start_orchestration (name)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end   
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/orchestration#{name}?action=start",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#stop_orchestration(name) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/fog/oraclecloud/requests/compute/stop_orchestration.rb', line 5

def stop_orchestration (name)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end   
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/orchestration#{name}?action=stop",
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#update_image(name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/oraclecloud/requests/compute/update_image.rb', line 5

def update_image (name, options={})
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
     'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'description'					=> options[:description],
     'default'					   	=> options[:default]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#update_image_list(name, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'lib/fog/oraclecloud/requests/compute/update_image_list.rb', line 5

def update_image_list (name, options={})
   # Just in case it's already set
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   body_data     = {
     'name'             		=> "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'description'					=> options[:description],
     'default'					   	=> options[:default]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/imagelist/Compute-#{@identity_domain}/#{@username}/#{name}",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#update_orchestration(name, oplans, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
13
14
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
# File 'lib/fog/oraclecloud/requests/compute/update_orchestration.rb', line 5

def update_orchestration (name, oplans, options={})

   # Clean up names in case they haven't provided the fully resolved names
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end   
   oplans.map do |oplan|
     oplan['objects'].map do |object|
       if oplan['obj_type'] == 'launchplan' then
         object['instances'].map do |instance|
           if !instance['name'].start_with?("/Compute-") then
             instance['name'] = "/Compute-#{@identity_domain}/#{@username}/#{instance['name']}"
           end
         end
       else
         if !object['name'].start_with?("/Compute-") then
           object['name'] = "/Compute-#{@identity_domain}/#{@username}/#{object['name']}"
         end
       end
     end
   end
   body_data     = {
     'name' 		      => name,
     'oplans'        => oplans,
     'relationships' => options[:relationships],
     'description'   => options[:description],
     'account'       => options[:account],
     'schedule'      => options[:schedule]
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/orchestration#{name}",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#update_ssh_key(name, enabled, key) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/fog/oraclecloud/requests/compute/update_ssh_key.rb', line 5

def update_ssh_key (name, enabled, key)
   if !name.start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     name = "/Compute-#{@identity_domain}/#{@username}/#{name}"
   end   
   body_data     = {
     'name'             		=> name,
     'enabled'					    => enabled,
     'key'					        => key
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/sshkey#{name}",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end