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,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def list_ip_reservations
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/ip/reservation/Compute-#{@identity_domain}/#{@username}/"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_ip_reservations
|
17
|
+
response = Excon::Response.new
|
18
|
+
|
19
|
+
ips = self.data[:ip_reservations].values
|
20
|
+
response.body = {
|
21
|
+
'result' => ips
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
module Fog
|
2
|
+
module Compute
|
3
|
+
class OracleCloud
|
4
|
+
class Real
|
5
|
+
def list_storage_attachments
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/storage/attachment/Compute-#{@identity_domain}/#{@username}/"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_storage_attachments
|
17
|
+
response = Excon::Response.new
|
18
|
+
|
19
|
+
sas = self.data[:storage_attachments].values
|
20
|
+
response.body = {
|
21
|
+
'result' => sas
|
22
|
+
}
|
23
|
+
response
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'active_support/hash_with_indifferent_access'
|
2
|
+
|
3
|
+
module Fog
|
4
|
+
module Compute
|
5
|
+
class OracleCloud
|
6
|
+
class Real
|
7
|
+
def update_ip_reservation (params)
|
8
|
+
params = params.reject {|key, value| value.nil?}
|
9
|
+
request(
|
10
|
+
:method => 'PUT',
|
11
|
+
:expects => 200,
|
12
|
+
:path => "/ip/reservation#{params[:name]}",
|
13
|
+
:body => Fog::JSON.encode(params),
|
14
|
+
:headers => {
|
15
|
+
'Content-Type' => 'application/oracle-compute-v3+json'
|
16
|
+
}
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def update_ip_reservation (params)
|
23
|
+
response = Excon::Response.new
|
24
|
+
clean_name = params[:name].sub "/Compute-#{@identity_domain}/#{@username}/", ''
|
25
|
+
|
26
|
+
ip = self.data[:ip_reservations][clean_name].merge!(params.stringify_keys)
|
27
|
+
if !ip['permanent'] && !ip['used'] then
|
28
|
+
# An unused IP reservation that is no longer permanent will be deleted
|
29
|
+
self.data[:ip_reservations].delete(clean_name)
|
30
|
+
end
|
31
|
+
|
32
|
+
response.status = 200
|
33
|
+
response.body = ip
|
34
|
+
response
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def create_access_rule(service_name, params)
|
7
|
+
request(
|
8
|
+
:method => 'POST',
|
9
|
+
:expects => 202,
|
10
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/jaas/instances/#{service_name}/accessrules",
|
11
|
+
:body => Fog::JSON.encode(params)
|
12
|
+
)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class Mock
|
16
|
+
def create_access_rule(service_name, params)
|
17
|
+
response = Excon::Response.new
|
18
|
+
params.delete(:service_name)
|
19
|
+
self.data[:access_rules][service_name] << params.collect{|k,v| [k.to_s, v]}.to_h
|
20
|
+
|
21
|
+
response.status = 202
|
22
|
+
response
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def delete_access_rule(service_name, rule_name)
|
7
|
+
body_data = {
|
8
|
+
'operation'=> 'delete'
|
9
|
+
}
|
10
|
+
|
11
|
+
request(
|
12
|
+
:method => 'PUT',
|
13
|
+
:expects => 202,
|
14
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/jaas/instances/#{service_name}/accessrules/#{rule_name}",
|
15
|
+
:body => Fog::JSON.encode(body_data)
|
16
|
+
)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
class Mock
|
21
|
+
def delete_access_rule(service_name, rule_name)
|
22
|
+
response = Excon::Response.new
|
23
|
+
rule = self.data[:access_rules][service_name].detect { |r| r['ruleName'] === rule_name }
|
24
|
+
rule['status'] = 'disabled'
|
25
|
+
self.data[:access_rules][service_name].delete_if { |r| r['ruleName'] === rule_name }
|
26
|
+
response.body = {
|
27
|
+
'rule' => rule
|
28
|
+
}
|
29
|
+
response.status = 202
|
30
|
+
response
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
|
6
|
+
def enable_access_rule(service_name, rule_name)
|
7
|
+
body_data = {
|
8
|
+
'operation'=> 'update',
|
9
|
+
'status' => 'enabled'
|
10
|
+
}
|
11
|
+
|
12
|
+
request(
|
13
|
+
:method => 'PUT',
|
14
|
+
:expects => 200,
|
15
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/jaas/instances/#{service_name}/accessrules/#{rule_name}",
|
16
|
+
:body => Fog::JSON.encode(body_data)
|
17
|
+
)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class Mock
|
22
|
+
def enable_access_rule(service_name, rule_name)
|
23
|
+
response = Excon::Response.new
|
24
|
+
rule = self.data[:access_rules][service_name].detect { |r| r['ruleName'] === rule_name }
|
25
|
+
rule['status'] = 'enabled'
|
26
|
+
response.body = rule
|
27
|
+
response.status = 200
|
28
|
+
response
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Java
|
4
|
+
class Real
|
5
|
+
def list_access_rules(service_name)
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/paas/api/v1.1/instancemgmt/#{@identity_domain}/services/jaas/instances/#{service_name}/accessrules"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_access_rules(service_name)
|
17
|
+
response = Excon::Response.new
|
18
|
+
|
19
|
+
rules = self.data[:access_rules][service_name]
|
20
|
+
|
21
|
+
response.body = {
|
22
|
+
'accessRules' => rules
|
23
|
+
}
|
24
|
+
|
25
|
+
response
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
module Fog
|
2
|
+
module OracleCloud
|
3
|
+
class Monitoring
|
4
|
+
class Real
|
5
|
+
def list_metrics_reports
|
6
|
+
response = request(
|
7
|
+
:expects => 200,
|
8
|
+
:method => 'GET',
|
9
|
+
:path => "/monitoring/monitoring/#{@identity_domain}/.customer/api/v1/metricReports"
|
10
|
+
)
|
11
|
+
response
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
class Mock
|
16
|
+
def list_instances
|
17
|
+
response = Excon::Response.new
|
18
|
+
|
19
|
+
#instances = self.data[:instances].values
|
20
|
+
|
21
|
+
response.body = {
|
22
|
+
'items' => []
|
23
|
+
}
|
24
|
+
response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
data/lib/fog/oraclecloud.rb
CHANGED
@@ -19,11 +19,13 @@ module Fog
|
|
19
19
|
autoload :Java, File.expand_path('../oraclecloud/java', __FILE__)
|
20
20
|
autoload :Database, File.expand_path('../oraclecloud/database', __FILE__)
|
21
21
|
autoload :SOA, File.expand_path('../oraclecloud/soa', __FILE__)
|
22
|
+
autoload :Monitoring, File.expand_path('../oraclecloud/monitoring', __FILE__)
|
22
23
|
|
23
24
|
service(:compute, 'Compute')
|
24
25
|
service(:storage, 'Storage')
|
25
26
|
service(:java, 'Java')
|
26
27
|
service(:database, 'Database')
|
27
28
|
service(:soa, 'SOA')
|
29
|
+
service(:monitoring, 'Monitoring')
|
28
30
|
end
|
29
31
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
Shindo.tests('Fog::Compute[oraclecloud] | auto-storage', 'compute') do
|
4
|
+
tests("#attach-storage", "create") do
|
5
|
+
begin
|
6
|
+
sshkey = Fog::Compute[:oraclecloud].ssh_keys.get('Test123Key')
|
7
|
+
rescue Fog::Compute::OracleCloud::NotFound
|
8
|
+
sshkey = Fog::Compute[:oraclecloud].ssh_keys.create(
|
9
|
+
:name => 'TestSSHKey2',
|
10
|
+
:enabled => false,
|
11
|
+
:key => 'ssh-rsa AAAAB3NzaC1yc2EAAAABJQAAAQEAkNNQ4ri2oUW46mBO/4CHMGCOALciumwGvFEMDLGNnlDbUSqU4IRrqgj+znLClfb29Oer0devdarM6DilsZVgZ2YbI5ZD5vICR/O9J0c28dArwbtFeIjcV2TCWyj5xKEXF1r+OrJMexHQa0fW1URGrU8QODpJNC/9eCVGcEXddL31xTZYpjoVOCVx66kNa6lSHEVV3T4zaCby9Oe5QI4gZe1+xyxHPNEW5wogwS3dlKSyL2CfBP0aUKOmJ5Nrl8+y0GqJQXdGjZ9FIknmwWueRW/6qPQvZocjOZ8YiPZgAP0RNy6lL+u8mnAazj/mrEdmB5QUzpDAllIr5Tn/xaddZQ=='
|
12
|
+
)
|
13
|
+
end
|
14
|
+
|
15
|
+
new_instance = Fog::Compute[:oraclecloud].instances.create(
|
16
|
+
:name=>'Test123',
|
17
|
+
:shape=>'oc3',
|
18
|
+
:imagelist=>'/oracle/public/oel_6.4_2GB_v1',
|
19
|
+
:label=>'dev-vm',
|
20
|
+
:sshkeys=>[sshkey.name]
|
21
|
+
)
|
22
|
+
|
23
|
+
test "can create an instance" do
|
24
|
+
new_instance.is_a? Fog::Compute::OracleCloud::Instance
|
25
|
+
end
|
26
|
+
new_instance.wait_for { ready? }
|
27
|
+
|
28
|
+
test "is built" do
|
29
|
+
new_instance.state == 'running'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
Shindo.tests('Fog::Compute[oraclecloud] | compute requests', 'compute') do
|
4
|
+
ip_name = "ipnet#{Random.rand(100)}"
|
5
|
+
tests("#ip-network-create", "create") do
|
6
|
+
new_ip = Fog::Compute[:oraclecloud].ip_networks.create(
|
7
|
+
:ip_address_prefix=>"192.168.0.0/16",
|
8
|
+
:name => ip_name
|
9
|
+
)
|
10
|
+
test "can create an ip network" do
|
11
|
+
new_ip.is_a? Fog::Compute::OracleCloud::IpNetwork
|
12
|
+
new_ip.name == ip_name
|
13
|
+
new_ip.ip_address_prefix == '192.168.0.0/16'
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
tests("#ip_networks-read") do
|
18
|
+
ips = Fog::Compute[:oraclecloud].ip_networks.all
|
19
|
+
test "returns ip networks" do
|
20
|
+
ips.is_a? Array
|
21
|
+
end
|
22
|
+
|
23
|
+
if ips.size >= 1
|
24
|
+
test "list returns a valid ip network" do
|
25
|
+
ips.first.is_a? Fog::Compute::OracleCloud::IpNetwork
|
26
|
+
ips.first.name.is_a? String
|
27
|
+
end
|
28
|
+
test "gets a single ip network" do
|
29
|
+
ip = Fog::Compute[:oraclecloud].ip_networks.get(ips.first.name)
|
30
|
+
ip.is_a? Fog::Compute::OracleCloud::IpNetwork
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
tests("#ip-reservations-delete", "create") do
|
36
|
+
ip = Fog::Compute[:oraclecloud].ip_networks.get(ip_name)
|
37
|
+
ip.destroy
|
38
|
+
tests("should delete ip network").raises(Fog::Compute::OracleCloud::NotFound) do
|
39
|
+
check = Fog::Compute[:oraclecloud].ip_networks.get(ip_name)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
Shindo.tests('Fog::Compute[oraclecloud] | compute requests', 'compute') do
|
4
|
+
ip_name = "Test_IP_Reservation_#{Random.rand(100)}"
|
5
|
+
tests("#ip-reservations-create", "create") do
|
6
|
+
new_ip = Fog::Compute[:oraclecloud].ip_reservations.create(
|
7
|
+
:name=>ip_name
|
8
|
+
)
|
9
|
+
test "can create an ip reservation" do
|
10
|
+
new_ip.is_a? Fog::Compute::OracleCloud::IpReservation
|
11
|
+
new_ip.name == ip_name
|
12
|
+
new_ip.permanent == true
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
test "can update tags" do
|
17
|
+
new_ip.tags = ['test']
|
18
|
+
new_ip.save
|
19
|
+
check = Fog::Compute[:oraclecloud].ip_reservations.get(ip_name)
|
20
|
+
check.tags == ['test']
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
tests("#ip_reservations-read") do
|
26
|
+
ips = Fog::Compute[:oraclecloud].ip_reservations.all
|
27
|
+
test "returns ip reservations" do
|
28
|
+
ips.is_a? Array
|
29
|
+
ips.size >= 1
|
30
|
+
ips.first.is_a? Fog::Compute::OracleCloud::IpReservation
|
31
|
+
ips.first.name.is_a? String
|
32
|
+
end
|
33
|
+
|
34
|
+
test "gets a single ip reservation" do
|
35
|
+
ip = Fog::Compute[:oraclecloud].ip_reservations.get(ips.first.name)
|
36
|
+
ip.is_a? Fog::Compute::OracleCloud::IpReservation
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
tests("#ip-reservations-delete", "create") do
|
41
|
+
new_ip = Fog::Compute[:oraclecloud].ip_reservations.get(ip_name)
|
42
|
+
|
43
|
+
tests("can update permanent").raises(Fog::Compute::OracleCloud::NotFound) do
|
44
|
+
new_ip.permanent = false
|
45
|
+
new_ip.save
|
46
|
+
# This will actually delete the reservation as it's not attached to an instance
|
47
|
+
rule = Fog::Compute[:oraclecloud].ip_reservations.get(ip_name)
|
48
|
+
end
|
49
|
+
# Create another, since it will be removed in the previous test
|
50
|
+
ip = Fog::Compute[:oraclecloud].ip_reservations.create(
|
51
|
+
:name=>ip_name
|
52
|
+
)
|
53
|
+
ip.destroy
|
54
|
+
tests("should delete ip reservation").raises(Fog::Compute::OracleCloud::NotFound) do
|
55
|
+
rule = Fog::Compute[:oraclecloud].ip_reservations.get(ip_name)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
require 'pp'
|
2
|
+
|
3
|
+
Shindo.tests('Fog::Compute[oraclecloud] | storage attachments', 'compute') do
|
4
|
+
|
5
|
+
tests("#storage-attachment-create", "create") do
|
6
|
+
new_sa = Fog::Compute[:oraclecloud].storage_attachments.create(
|
7
|
+
:index => 1,
|
8
|
+
:instance_name => 'dsfsf',
|
9
|
+
:storage_volume_name => 'dfsf'
|
10
|
+
)
|
11
|
+
test "can create a storage attachment" do
|
12
|
+
new_sa.is_a? Fog::Compute::OracleCloud::StorageAttachment
|
13
|
+
pp new_sa
|
14
|
+
#new_ip.ip_address_prefix == '192.168.0.0/16'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
tests("#storage-attachment-read") do
|
19
|
+
sas = Fog::Compute[:oraclecloud].storage_attachments.all
|
20
|
+
test "returns storage attachmentds" do
|
21
|
+
sas.is_a? Array
|
22
|
+
end
|
23
|
+
if sas.size >= 1
|
24
|
+
test "list returns a valid storage attachment" do
|
25
|
+
sas.first.is_a? Fog::Compute::OracleCloud::StorageAttachment
|
26
|
+
sas.first.name.is_a? String
|
27
|
+
end
|
28
|
+
test "gets a single storage attachment" do
|
29
|
+
sa = Fog::Compute[:oraclecloud].storage_attachments.get(sas.first.name)
|
30
|
+
sa.is_a? Fog::Compute::OracleCloud::StorageAttachment
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
#tests("#storage-attachment-delete", "create") do
|
36
|
+
# ip = Fog::Compute[:oraclecloud].ip_networks.get(ip_name)
|
37
|
+
# ip.destroy
|
38
|
+
# tests("should delete ip network").raises(Fog::Compute::OracleCloud::NotFound) do
|
39
|
+
# check = Fog::Compute[:oraclecloud].ip_networks.get(ip_name)
|
40
|
+
# end
|
41
|
+
#end
|
42
|
+
end
|