fog-oraclecloud 0.1.13 → 0.1.14
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/fog-oracle.gemspec +3 -2
- data/lib/fog/oraclecloud/compute.rb +28 -0
- data/lib/fog/oraclecloud/models/compute/ip_network.rb +51 -0
- data/lib/fog/oraclecloud/models/compute/ip_networks.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/ip_reservation.rb +54 -0
- data/lib/fog/oraclecloud/models/compute/ip_reservations.rb +22 -0
- data/lib/fog/oraclecloud/models/compute/storage_attachment.rb +41 -0
- data/lib/fog/oraclecloud/models/compute/storage_attachments.rb +22 -0
- data/lib/fog/oraclecloud/models/java/access_rule.rb +63 -0
- data/lib/fog/oraclecloud/models/java/access_rules.rb +32 -0
- data/lib/fog/oraclecloud/models/monitoring/metrics_report.rb +12 -0
- data/lib/fog/oraclecloud/models/monitoring/metrics_reports.rb +24 -0
- data/lib/fog/oraclecloud/monitoring.rb +104 -0
- data/lib/fog/oraclecloud/requests/compute/create_ip_network.rb +46 -0
- data/lib/fog/oraclecloud/requests/compute/create_ip_reservation.rb +48 -0
- data/lib/fog/oraclecloud/requests/compute/create_storage_attachment.rb +55 -0
- data/lib/fog/oraclecloud/requests/compute/delete_ip_network.rb +29 -0
- data/lib/fog/oraclecloud/requests/compute/delete_ip_reservation.rb +29 -0
- data/lib/fog/oraclecloud/requests/compute/get_ip_network.rb +36 -0
- data/lib/fog/oraclecloud/requests/compute/get_ip_reservation.rb +36 -0
- data/lib/fog/oraclecloud/requests/compute/get_storage_attachment.rb +36 -0
- data/lib/fog/oraclecloud/requests/compute/list_ip_networks.rb +28 -0
- data/lib/fog/oraclecloud/requests/compute/list_ip_reservations.rb +28 -0
- data/lib/fog/oraclecloud/requests/compute/list_storage_attachments.rb +28 -0
- data/lib/fog/oraclecloud/requests/compute/update_ip_reservation.rb +39 -0
- data/lib/fog/oraclecloud/requests/java/create_access_rule.rb +27 -0
- data/lib/fog/oraclecloud/requests/java/delete_access_rule.rb +35 -0
- data/lib/fog/oraclecloud/requests/java/enable_access_rule.rb +33 -0
- data/lib/fog/oraclecloud/requests/java/list_access_rules.rb +30 -0
- data/lib/fog/oraclecloud/requests/monitoring/list_metrics_reports.rb +29 -0
- data/lib/fog/oraclecloud/version.rb +1 -1
- data/lib/fog/oraclecloud.rb +2 -0
- data/tests/requests/compute/auto-storage_tests.rb +32 -0
- data/tests/requests/compute/ip_network_tests.rb +42 -0
- data/tests/requests/compute/ip_tests.rb +58 -0
- data/tests/requests/compute/storage_attachments_tests.rb +42 -0
- data/tests/requests/monitoring_tests.rb +11 -0
- metadata +57 -10
@@ -0,0 +1,104 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Monitoring < Fog::Service
|
4
|
+
requires :oracle_username, :oracle_password, :oracle_domain
|
5
|
+
recognizes :oracle_region
|
6
|
+
|
7
|
+
model_path 'fog/oraclecloud/models/monitoring'
|
8
|
+
model :metrics_report
|
9
|
+
collection :metrics_reports
|
10
|
+
|
11
|
+
|
12
|
+
request_path 'fog/oraclecloud/requests/monitoring'
|
13
|
+
request :list_metrics_reports
|
14
|
+
|
15
|
+
|
16
|
+
class Real
|
17
|
+
|
18
|
+
def initialize(options={})
|
19
|
+
@username = options[:oracle_username]
|
20
|
+
@password = options[:oracle_password]
|
21
|
+
@identity_domain = options[:oracle_domain]
|
22
|
+
region = options[:oracle_region].nil? ? 'us' : options[:oracle_region]
|
23
|
+
url = "https://monitoring.#{region}.oraclecloud.com"
|
24
|
+
Excon.ssl_verify_peer = false
|
25
|
+
@connection = Fog::XML::Connection.new(url)
|
26
|
+
end
|
27
|
+
|
28
|
+
def username
|
29
|
+
@username
|
30
|
+
end
|
31
|
+
|
32
|
+
def password
|
33
|
+
@password
|
34
|
+
end
|
35
|
+
|
36
|
+
|
37
|
+
def auth_header
|
38
|
+
auth_header ||= 'Basic ' + Base64.encode64("#{@username}:#{@password}").gsub("\n",'')
|
39
|
+
end
|
40
|
+
|
41
|
+
def request(params, parse_json = true, &block)
|
42
|
+
pp @connection
|
43
|
+
begin
|
44
|
+
response = @connection.request(params.merge!({
|
45
|
+
:headers => {
|
46
|
+
'Authorization' => auth_header,
|
47
|
+
'X-ID-TENANT-NAME' => @identity_domain,
|
48
|
+
'Content-Type' => 'application/json',
|
49
|
+
#'Accept' => 'application/json'
|
50
|
+
}.merge!(params[:headers] || {})
|
51
|
+
}), &block)
|
52
|
+
rescue Excon::Errors::HTTPStatusError => error
|
53
|
+
raise case error
|
54
|
+
when Excon::Errors::NotFound
|
55
|
+
Fog::OracleCloud::Java::NotFound.slurp(error)
|
56
|
+
else
|
57
|
+
error
|
58
|
+
end
|
59
|
+
end
|
60
|
+
if !response.body.empty? && parse_json
|
61
|
+
# The Oracle Cloud doesn't return the Content-Type header as application/json, rather as application/vnd.com.oracle.oracloud.provisioning.Pod+json
|
62
|
+
# Should add check here to validate, but not sure if this might change in future
|
63
|
+
response.body = Fog::JSON.decode(response.body)
|
64
|
+
end
|
65
|
+
response
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class Mock
|
70
|
+
def initialize(options={})
|
71
|
+
@username = options[:oracle_username]
|
72
|
+
@password = options[:oracle_password]
|
73
|
+
@identity_domain = options[:oracle_domain]
|
74
|
+
end
|
75
|
+
|
76
|
+
def username
|
77
|
+
@username
|
78
|
+
end
|
79
|
+
|
80
|
+
def password
|
81
|
+
@password
|
82
|
+
end
|
83
|
+
|
84
|
+
def region_url
|
85
|
+
@region_url
|
86
|
+
end
|
87
|
+
|
88
|
+
def self.data
|
89
|
+
@data ||= {
|
90
|
+
|
91
|
+
}
|
92
|
+
end
|
93
|
+
|
94
|
+
def self.reset
|
95
|
+
@data = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def data
|
99
|
+
self.class.data
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_ip_network (params)
|
6
|
+
if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
|
7
|
+
# They haven't provided a well formed name, add their name in
|
8
|
+
params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
|
9
|
+
end
|
10
|
+
|
11
|
+
params = params.reject {|key, value| value.nil?}
|
12
|
+
request(
|
13
|
+
:method => 'POST',
|
14
|
+
:expects => 201,
|
15
|
+
:path => "/network/v1/ipnetwork/",
|
16
|
+
:body => Fog::JSON.encode(params),
|
17
|
+
:headers => {
|
18
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
def create_ip_network (params)
|
26
|
+
response = Excon::Response.new
|
27
|
+
name = params[:name]
|
28
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
29
|
+
|
30
|
+
self.data[:ip_networks][name] = {
|
31
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
32
|
+
'uri' => "#{@api_endpoint}network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/#{name}",
|
33
|
+
'description' => nil,
|
34
|
+
'tags' => nil,
|
35
|
+
'ipAddressPrefix' => params[:ipAddressPrefix],
|
36
|
+
'ipNetworkExchange' => params[:ipNetworkExchange],
|
37
|
+
'publicNaptEnabledFlag' => false
|
38
|
+
}
|
39
|
+
response.status = 201
|
40
|
+
response.body = self.data[:ip_networks][name]
|
41
|
+
response
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def create_ip_reservation (params)
|
6
|
+
if !params[:name].nil? && !params[:name].start_with?("/Compute-") then
|
7
|
+
# They haven't provided a well formed name, add their name in
|
8
|
+
params[:name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:name]}"
|
9
|
+
end
|
10
|
+
|
11
|
+
params = params.reject {|key, value| value.nil?}
|
12
|
+
request(
|
13
|
+
:method => 'POST',
|
14
|
+
:expects => 201,
|
15
|
+
:path => "/ip/reservation/",
|
16
|
+
:body => Fog::JSON.encode(params),
|
17
|
+
:headers => {
|
18
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
class Mock
|
25
|
+
def create_ip_reservation (params)
|
26
|
+
response = Excon::Response.new
|
27
|
+
name = params[:name]
|
28
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
29
|
+
|
30
|
+
self.data[:ip_reservations][name] = {
|
31
|
+
'name' => "/Compute-#{@identity_domain}/#{@username}/#{name}",
|
32
|
+
'account' => "/Compute-#{@identity_domain}/#{@username}",
|
33
|
+
'used' => false,
|
34
|
+
'tags' => params[:tags] || [],
|
35
|
+
'ip' => '123.123.123.56',
|
36
|
+
'uri' => "#{@api_endpoint}ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
|
37
|
+
'quota' => nil,
|
38
|
+
'parentpool' => params[:parentpool],
|
39
|
+
'permanent' => params[:permanent]
|
40
|
+
}
|
41
|
+
response.status = 201
|
42
|
+
response.body = self.data[:ip_reservations][name]
|
43
|
+
response
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
require 'securerandom'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OracleCloud
|
6
|
+
class Real
|
7
|
+
def create_storage_attachment (params)
|
8
|
+
if !params[:instance_name].start_with?("/Compute-") then
|
9
|
+
# They haven't provided a well formed name, add their name in
|
10
|
+
params[:instance_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:instance_name]}"
|
11
|
+
end
|
12
|
+
if !params[:storage_volume_name].start_with?("/Compute-") then
|
13
|
+
# They haven't provided a well formed name, add their name in
|
14
|
+
params[:storage_volume_name] = "/Compute-#{@identity_domain}/#{@username}/#{params[:storage_volume_name]}"
|
15
|
+
end
|
16
|
+
|
17
|
+
params = params.reject {|key, value| value.nil?}
|
18
|
+
request(
|
19
|
+
:method => 'POST',
|
20
|
+
:expects => 201,
|
21
|
+
:path => "/network/v1/ipnetwork/",
|
22
|
+
:body => Fog::JSON.encode(params),
|
23
|
+
:headers => {
|
24
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
25
|
+
}
|
26
|
+
)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class Mock
|
31
|
+
def create_storage_attachment (params)
|
32
|
+
response = Excon::Response.new
|
33
|
+
|
34
|
+
guid = SecureRandom.uuid
|
35
|
+
name = "#{params[:instance_name]}/#{guid}"
|
36
|
+
|
37
|
+
self.data[:storage_attachments][name] = {
|
38
|
+
'index' => params[:index],
|
39
|
+
'account' => nil,
|
40
|
+
'storage_volume_name' => params[:storage_volume_name],
|
41
|
+
'hypervisor' => nil,
|
42
|
+
'uri' => "#{@api_endpoint}/storage/attachment/#{name}",
|
43
|
+
'instance_name' => params[:instance_name],
|
44
|
+
'state' => 'attaching',
|
45
|
+
'readonly' => false,
|
46
|
+
'name' => name
|
47
|
+
}
|
48
|
+
response.status = 201
|
49
|
+
response.body = self.data[:storage_attachments][name]
|
50
|
+
response
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def delete_ip_network (name)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
request(
|
8
|
+
:method => 'DELETE',
|
9
|
+
:expects => 204,
|
10
|
+
:path => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
:headers => {
|
12
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
13
|
+
}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def delete_ip_network(name)
|
20
|
+
response = Excon::Response.new
|
21
|
+
clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
22
|
+
self.data[:ip_networks].delete(clean_name)
|
23
|
+
response.status = 204
|
24
|
+
response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def delete_ip_reservation (name)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
request(
|
8
|
+
:method => 'DELETE',
|
9
|
+
:expects => 204,
|
10
|
+
:path => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
:headers => {
|
12
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
13
|
+
}
|
14
|
+
)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
class Mock
|
19
|
+
def delete_ip_reservation(name)
|
20
|
+
response = Excon::Response.new
|
21
|
+
clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
22
|
+
self.data[:ip_reservations].delete(clean_name)
|
23
|
+
response.status = 204
|
24
|
+
response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def get_ip_reservation(name)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
:headers => {
|
12
|
+
'Content-Type' => 'application/oracle-compute-v3+json',
|
13
|
+
'Accept' => 'application/oracle-compute-v3+json'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
def get_ip_network(name)
|
22
|
+
response = Excon::Response.new
|
23
|
+
clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
24
|
+
|
25
|
+
if ip = self.data[:ip_networks][clean_name]
|
26
|
+
response.status = 200
|
27
|
+
response.body = ip
|
28
|
+
response
|
29
|
+
else;
|
30
|
+
raise Fog::Compute::OracleCloud::NotFound.new("IP Network #{name} does not exist");
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def get_ip_reservation(name)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
:headers => {
|
12
|
+
'Content-Type' => 'application/oracle-compute-v3+json',
|
13
|
+
'Accept' => 'application/oracle-compute-v3+json'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
def get_ip_reservation(name)
|
22
|
+
response = Excon::Response.new
|
23
|
+
clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
24
|
+
|
25
|
+
if ip = self.data[:ip_reservations][clean_name]
|
26
|
+
response.status = 200
|
27
|
+
response.body = ip
|
28
|
+
response
|
29
|
+
else;
|
30
|
+
raise Fog::Compute::OracleCloud::NotFound.new("IP Reservation #{name} does not exist");
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def get_storage_attachment(name)
|
6
|
+
name.sub! "/Compute-#{@identity_domain}/#{@username}/", ''
|
7
|
+
response = request(
|
8
|
+
:expects => 200,
|
9
|
+
:method => 'GET',
|
10
|
+
:path => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/#{name}",
|
11
|
+
:headers => {
|
12
|
+
'Content-Type' => 'application/oracle-compute-v3+json',
|
13
|
+
'Accept' => 'application/oracle-compute-v3+json'
|
14
|
+
}
|
15
|
+
)
|
16
|
+
response
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
def get_storage_attachment(name)
|
22
|
+
response = Excon::Response.new
|
23
|
+
clean_name = name.sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
24
|
+
|
25
|
+
if sa = self.data[:storage_attachments][clean_name]
|
26
|
+
response.status = 200
|
27
|
+
response.body = sa
|
28
|
+
response
|
29
|
+
else;
|
30
|
+
raise Fog::Compute::OracleCloud::NotFound.new("Storage Attachment #{name} does not exist");
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def list_ip_networks
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/network/v1/ipnetwork/Compute-#{@identity_domain}/#{@username}/"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_ip_networks
|
17
|
+
response = Excon::Response.new
|
18
|
+
|
19
|
+
ips = self.data[:ip_networks].values
|
20
|
+
response.body = {
|
21
|
+
'result' => ips
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|