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/get_ip_network.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/list_ip_networks.rb,
lib/fog/oraclecloud/requests/compute/create_image_list.rb,
lib/fog/oraclecloud/requests/compute/create_ip_network.rb,
lib/fog/oraclecloud/requests/compute/delete_image_list.rb,
lib/fog/oraclecloud/requests/compute/delete_ip_network.rb,
lib/fog/oraclecloud/requests/compute/get_orchestration.rb,
lib/fog/oraclecloud/requests/compute/get_security_list.rb,
lib/fog/oraclecloud/requests/compute/get_security_rule.rb,
lib/fog/oraclecloud/requests/compute/update_image_list.rb,
lib/fog/oraclecloud/requests/compute/get_ip_association.rb,
lib/fog/oraclecloud/requests/compute/get_ip_reservation.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_list.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_list.rb,
lib/fog/oraclecloud/requests/compute/delete_security_rule.rb,
lib/fog/oraclecloud/requests/compute/get_security_ip_list.rb,
lib/fog/oraclecloud/requests/compute/list_ip_associations.rb,
lib/fog/oraclecloud/requests/compute/list_ip_reservations.rb,
lib/fog/oraclecloud/requests/compute/update_orchestration.rb,
lib/fog/oraclecloud/requests/compute/create_ip_association.rb,
lib/fog/oraclecloud/requests/compute/create_ip_reservation.rb,
lib/fog/oraclecloud/requests/compute/delete_ip_reservation.rb,
lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb,
lib/fog/oraclecloud/requests/compute/get_storage_attachment.rb,
lib/fog/oraclecloud/requests/compute/create_security_ip_list.rb,
lib/fog/oraclecloud/requests/compute/get_security_application.rb,
lib/fog/oraclecloud/requests/compute/list_storage_attachments.rb,
lib/fog/oraclecloud/requests/compute/create_storage_attachment.rb,
lib/fog/oraclecloud/requests/compute/list_security_applications.rb,
lib/fog/oraclecloud/requests/compute/create_security_application.rb,
lib/fog/oraclecloud/requests/compute/create_security_association.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.



127
128
129
130
131
132
133
134
135
136
137
# File 'lib/fog/oraclecloud/compute.rb', line 127

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



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
# File 'lib/fog/oraclecloud/compute.rb', line 139

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_ip_association(params) ⇒ Object



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

def create_ip_association (params)
   params = params.reject {|key, value| value.nil?}
   puts Fog::JSON.encode(params)
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/ip/association/",
     :body     => Fog::JSON.encode(params),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_ip_network(params) ⇒ Object



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

def create_ip_network (params)
   if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
   end            

   params = params.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/network/v1/ipnetwork/",
     :body     => Fog::JSON.encode(params),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )
end

#create_ip_reservation(params) ⇒ Object



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

def create_ip_reservation (params)
   if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
   end            

   params = params.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/ip/reservation/",
     :body     => Fog::JSON.encode(params),
     :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_association(name, seclist, vcable) ⇒ 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_association.rb', line 5

def create_security_association(name, seclist, vcable)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   seclist.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

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

#create_security_ip_list(name, description, secipentries) ⇒ 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_ip_list.rb', line 5

def create_security_ip_list(name, description, secipentries)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

   body_data     = {
     'name'                => "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'description'         => description,
     'secipentries'        => secipentries,
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/seciplist/",
     :body     => Fog::JSON.encode(body_data),
     :headers  => {
       'Content-Type' => 'application/oracle-compute-v3+json'
     }
   )

end

#create_security_list(name, description, policy, outbound_policy) ⇒ 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_list.rb', line 5

def create_security_list(name, description, policy, outbound_policy)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

   body_data     = {
     'name'                => "/Compute-#{@identity_domain}/#{@username}/#{name}",
     'description'         => description,
     'policy'              => policy,
     'outbound_cidr_policy'=> outbound_policy
   }
   body_data = body_data.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/seclist/",
     :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_storage_attachment(params) ⇒ Object



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

def create_storage_attachment (params)
   if !params[:instance_name].start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     params[:instance_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:instance_name]}"
   end 
   if !params[:storage_volume_name].start_with?("/Compute-") then
     # They haven't provided a well formed name, add their name in
     params[:storage_volume_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:storage_volume_name]}"
   end               

   params = params.reject {|key, value| value.nil?}
   request(
     :method   => 'POST',
     :expects  => 201,
     :path     => "/network/v1/ipnetwork/",
     :body     => Fog::JSON.encode(params),
     :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_ip_network(name) ⇒ Object



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

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

#delete_ip_reservation(name) ⇒ Object



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

def delete_ip_reservation (name)
   name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{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_list(name) ⇒ Object



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

def delete_security_list(name)
	# Just in case it's already set
	name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
	request(
     :method   => 'DELETE',
     :expects  => 204,
     :path     => "/seclist/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_ip_association(name) ⇒ Object



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

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

#get_ip_network(name) ⇒ Object



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

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

#get_ip_reservation(name) ⇒ Object



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

def get_ip_reservation(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{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
17
18
19
20
21
22
23
# File 'lib/fog/oraclecloud/requests/compute/get_security_application.rb', line 5

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

#get_security_ip_list(name) ⇒ Object



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

def get_security_ip_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

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

#get_security_list(name) ⇒ Object



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

def get_security_list(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/seclist/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
17
18
# File 'lib/fog/oraclecloud/requests/compute/get_security_rule.rb', line 5

def get_security_rule(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''

 					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

#get_storage_attachment(name) ⇒ Object



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

def get_storage_attachment(name)
  name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
 					response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/#{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_ip_associationsObject



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

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

#list_ip_networksObject



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

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

#list_ip_reservationsObject



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

def list_ip_reservations
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/"
  )
  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_applications(public_list = false) ⇒ Object



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

def list_security_applications(public_list=false)
  path = "/secapplication"
  if public_list then
    path += "/oracle/public/"
  else 
    path += "/Compute-#{@identity_domain}/#{@username}/"
  end
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => path
  )
  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_storage_attachmentsObject



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

def list_storage_attachments
  response = request(
    :expects  => 200,
    :method   => 'GET',
    :path     => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/"
  )
  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



162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# File 'lib/fog/oraclecloud/compute.rb', line 162

def request(params, parse_json = true, &block)
					begin
    Fog::Logger.debug("Sending #{params[:body].to_s} to (#{params[:method]}):#{params[:path]}")
						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_ip_reservation(params) ⇒ Object



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

def update_ip_reservation (params) 
   params[:name].sub! "/Compute-#{@identity_domain}/#{@username}/", ''
   params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
   params = params.reject {|key, value| value.nil?}
   request(
     :method   => 'PUT',
     :expects  => 200,
     :path     => "/ip/reservation#{params[:name]}",
     :body     => Fog::JSON.encode(params),
     :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(uri, 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 (uri, 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