cloudstack_ruby_client 0.0.5 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cloudstack_ruby_client.rb +1 -0
- data/lib/cloudstack_ruby_client/api/accounts_api.rb +59 -0
- data/lib/cloudstack_ruby_client/api/autoscale_api.rb +24 -0
- data/lib/cloudstack_ruby_client/api/config.rb +15 -0
- data/lib/cloudstack_ruby_client/api/configuration_api.rb +14 -0
- data/lib/cloudstack_ruby_client/api/firewall_api.rb +14 -0
- data/lib/cloudstack_ruby_client/api/infra_api.rb +41 -0
- data/lib/cloudstack_ruby_client/api/network_api.rb +113 -0
- data/lib/cloudstack_ruby_client/api/project_api.rb +14 -0
- data/lib/cloudstack_ruby_client/api/securitygroup_api.rb +11 -0
- data/lib/cloudstack_ruby_client/api/serviceoffering_api.rb +15 -0
- data/lib/cloudstack_ruby_client/api/snapshot_api.rb +11 -0
- data/lib/cloudstack_ruby_client/api/storage_api.rb +16 -0
- data/lib/cloudstack_ruby_client/api/systemvm_api.rb +23 -0
- data/lib/cloudstack_ruby_client/api/template_api.rb +32 -0
- data/lib/cloudstack_ruby_client/api/vm_api.rb +29 -0
- data/lib/cloudstack_ruby_client/api/volume_api.rb +13 -0
- data/lib/cloudstack_ruby_client/base_client.rb +23 -19
- data/lib/cloudstack_ruby_client/client.rb +72 -6099
- data/lib/cloudstack_ruby_client/client_helper.rb +67 -0
- data/lib/cloudstack_ruby_client/version.rb +1 -1
- data/test/config.yml +6 -0
- data/test/unit/accounts_test.rb +0 -0
- data/test/unit/infra_test.rb +112 -0
- data/test/unit/vm_test.rb +0 -0
- metadata +27 -4
- data/test/unit/empty_test.rb +0 -9
@@ -0,0 +1,67 @@
|
|
1
|
+
class Module
|
2
|
+
def cmd_processor(*args)
|
3
|
+
args.each do |arg|
|
4
|
+
arga = arg.to_s.split('_')
|
5
|
+
meta_method = %Q{
|
6
|
+
def #{arga[0]+"_"+arga[1]}#{('_'+arga[2]) unless arga[2].nil?}#{('_'+arga[3]) unless arga[3].nil?}#{('_'+arga[4]) unless arga[4].nil?}#{('_'+arga[5]) unless arga[5].nil?}#{('_'+arga[6]) unless arga[6].nil?}(args={});
|
7
|
+
|
8
|
+
command = "#{arga[0]}#{arga[1].capitalize}#{arga[2].capitalize unless arga[2].nil?}#{arga[3].capitalize unless arga[3].nil?}#{arga[4].capitalize unless arga[4].nil?}#{arga[5].capitalize unless arga[5].nil?}#{arga[6].capitalize unless arga[6].nil?}";
|
9
|
+
|
10
|
+
resp_title = "#{arga[0]}#{arga[1]}#{arga[2] unless arga[2].nil?}#{arga[3] unless arga[3].nil?}#{arga[4] unless arga[4].nil?}#{arga[5] unless arga[5].nil?}#{arga[6] unless arga[6].nil?}response";
|
11
|
+
} +
|
12
|
+
|
13
|
+
#
|
14
|
+
# The following code block is dealing with malformed api commands
|
15
|
+
#
|
16
|
+
|
17
|
+
%Q{
|
18
|
+
|
19
|
+
if /getvmpassword/i =~ command;
|
20
|
+
command = 'getVMPassword';
|
21
|
+
end;
|
22
|
+
|
23
|
+
if /(list|create|delete)networkacl.*/i =~ command;
|
24
|
+
command.gsub! /acl/i, 'ACL'
|
25
|
+
end;
|
26
|
+
|
27
|
+
if /.*ssh.*/i =~ command;
|
28
|
+
command.gsub! /ssh/i, 'SSH'
|
29
|
+
end;
|
30
|
+
|
31
|
+
if /(list|create|delete)lbstickinesspolic.*/i =~ command;
|
32
|
+
command.gsub! /lb/i, 'LB'
|
33
|
+
end;
|
34
|
+
|
35
|
+
if /.*vpc.*/i =~ command;
|
36
|
+
command.gsub! /vpc/i, 'VPC'
|
37
|
+
end;
|
38
|
+
|
39
|
+
} +
|
40
|
+
%Q{
|
41
|
+
params = {'command' => command};
|
42
|
+
params.merge! args unless args.empty?;
|
43
|
+
|
44
|
+
response = request params;
|
45
|
+
|
46
|
+
if !response.is_a?(Net::HTTPOK);
|
47
|
+
|
48
|
+
if response.code == "431" &&
|
49
|
+
JSON.parse(response.body)[resp_title]['cserrorcode'] == 9999;
|
50
|
+
|
51
|
+
raise ArgumentError, JSON.parse(response.body)[resp_title]['errortext'];
|
52
|
+
end;
|
53
|
+
|
54
|
+
puts 'Error' + response.code + ':'
|
55
|
+
puts JSON.pretty_generate(JSON.parse(response.body));
|
56
|
+
exit 1;
|
57
|
+
end;
|
58
|
+
|
59
|
+
json = JSON.parse(response.body);
|
60
|
+
json[params['command'].downcase + 'response']
|
61
|
+
end;
|
62
|
+
}
|
63
|
+
|
64
|
+
self.class_eval meta_method
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
data/test/config.yml
ADDED
@@ -0,0 +1,6 @@
|
|
1
|
+
cloudstack:
|
2
|
+
host: '10.1.192.92'
|
3
|
+
port: '8080'
|
4
|
+
admin_port: '8096'
|
5
|
+
api_key: 'Vjx7Onwakz3t711ozmVBYEn279Vx8Cvo1ZCPdSDMflBfQnMyp90K3ZsBP-a8ai6VIUViolHll9uflM4JW561LQ'
|
6
|
+
secret_key: 'cRph9bBFx32dg8yUjtv7srUyaC5eoM9_QimtutcO8b4l4RekQyuoNTUla7jx0D9GgjCfrEnAu_Vvck_4li7Ong'
|
File without changes
|
@@ -0,0 +1,112 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'yaml'
|
3
|
+
require_relative '../../lib/cloudstack_ruby_client'
|
4
|
+
|
5
|
+
class EmptyTest < Test::Unit::TestCase
|
6
|
+
|
7
|
+
def setup
|
8
|
+
config = YAML.load_file("test/config.yml")
|
9
|
+
_host = config['cloudstack']['host']
|
10
|
+
_port = config['cloudstack']['port']
|
11
|
+
_admin_port = config['cloudstack']['admin_port']
|
12
|
+
_api_key = config['cloudstack']['api_key']
|
13
|
+
_secret_key = config['cloudstack']['secret_key']
|
14
|
+
@client = CloudstackRubyClient::Client.new \
|
15
|
+
"http://#{_host}:#{_port}/client/api",
|
16
|
+
"#{_api_key}",
|
17
|
+
"#{_secret_key}"
|
18
|
+
end
|
19
|
+
|
20
|
+
def teardown
|
21
|
+
# Do nothing here!
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
### Zone Test ####
|
26
|
+
|
27
|
+
def test_list_zones
|
28
|
+
@client.list_zones
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_create_zone
|
32
|
+
@client.create_zone
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_update_zone
|
36
|
+
@client.update_zone
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_delete_zone
|
40
|
+
@client.delete_zone
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_dedicate_zone
|
44
|
+
@client.dedicate_zone
|
45
|
+
end
|
46
|
+
|
47
|
+
### Pod Test ###
|
48
|
+
|
49
|
+
def test_list_pods
|
50
|
+
@client.list_pods
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_create_pod
|
54
|
+
@client.create_pod
|
55
|
+
end
|
56
|
+
|
57
|
+
def test_update_pod
|
58
|
+
@client.update_pod
|
59
|
+
end
|
60
|
+
|
61
|
+
def test_delete_pod
|
62
|
+
@client.delete_pod
|
63
|
+
end
|
64
|
+
|
65
|
+
### Cluster Test ###
|
66
|
+
|
67
|
+
def test_list_clusters
|
68
|
+
@client.list_clusters
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_add_cluster
|
72
|
+
@client.add_cluster
|
73
|
+
end
|
74
|
+
|
75
|
+
def test_update_cluster
|
76
|
+
@client.update_cluster
|
77
|
+
end
|
78
|
+
|
79
|
+
def test_delete_cluster
|
80
|
+
@client.delete_cluster
|
81
|
+
end
|
82
|
+
|
83
|
+
def test_dedicate_cluster
|
84
|
+
@client.dedicate_cluster
|
85
|
+
end
|
86
|
+
|
87
|
+
### Host Test ###
|
88
|
+
|
89
|
+
def test_list_hosts
|
90
|
+
@client.list_hosts
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_add_host
|
94
|
+
@client.add_host
|
95
|
+
end
|
96
|
+
|
97
|
+
def test_update_host
|
98
|
+
@client.udpate_host
|
99
|
+
end
|
100
|
+
|
101
|
+
def test_delete_host
|
102
|
+
@client.delete_host
|
103
|
+
end
|
104
|
+
|
105
|
+
def test_reconnect_host
|
106
|
+
@client.reconnect_host
|
107
|
+
end
|
108
|
+
|
109
|
+
def test_dedicate_host
|
110
|
+
@client.dedicate_host
|
111
|
+
end
|
112
|
+
end
|
File without changes
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudstack_ruby_client
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-07
|
12
|
+
date: 2013-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: A Ruby client for CloudStack's API, licensed via the Apache Software
|
15
15
|
License v2.
|
@@ -27,11 +27,31 @@ files:
|
|
27
27
|
- Rakefile
|
28
28
|
- cloudstack_ruby_client.gemspec
|
29
29
|
- lib/cloudstack_ruby_client.rb
|
30
|
+
- lib/cloudstack_ruby_client/api/accounts_api.rb
|
31
|
+
- lib/cloudstack_ruby_client/api/autoscale_api.rb
|
32
|
+
- lib/cloudstack_ruby_client/api/config.rb
|
33
|
+
- lib/cloudstack_ruby_client/api/configuration_api.rb
|
34
|
+
- lib/cloudstack_ruby_client/api/firewall_api.rb
|
35
|
+
- lib/cloudstack_ruby_client/api/infra_api.rb
|
36
|
+
- lib/cloudstack_ruby_client/api/network_api.rb
|
37
|
+
- lib/cloudstack_ruby_client/api/project_api.rb
|
38
|
+
- lib/cloudstack_ruby_client/api/securitygroup_api.rb
|
39
|
+
- lib/cloudstack_ruby_client/api/serviceoffering_api.rb
|
40
|
+
- lib/cloudstack_ruby_client/api/snapshot_api.rb
|
41
|
+
- lib/cloudstack_ruby_client/api/storage_api.rb
|
42
|
+
- lib/cloudstack_ruby_client/api/systemvm_api.rb
|
43
|
+
- lib/cloudstack_ruby_client/api/template_api.rb
|
44
|
+
- lib/cloudstack_ruby_client/api/vm_api.rb
|
45
|
+
- lib/cloudstack_ruby_client/api/volume_api.rb
|
30
46
|
- lib/cloudstack_ruby_client/base_client.rb
|
31
47
|
- lib/cloudstack_ruby_client/client.rb
|
48
|
+
- lib/cloudstack_ruby_client/client_helper.rb
|
32
49
|
- lib/cloudstack_ruby_client/version.rb
|
50
|
+
- test/config.yml
|
33
51
|
- test/integration/client_test.rb
|
34
|
-
- test/unit/
|
52
|
+
- test/unit/accounts_test.rb
|
53
|
+
- test/unit/infra_test.rb
|
54
|
+
- test/unit/vm_test.rb
|
35
55
|
homepage: http://chipchilders.github.io/cloudstack_ruby_client/
|
36
56
|
licenses: []
|
37
57
|
post_install_message:
|
@@ -57,5 +77,8 @@ signing_key:
|
|
57
77
|
specification_version: 3
|
58
78
|
summary: A Ruby client for CloudStack's API.
|
59
79
|
test_files:
|
80
|
+
- test/config.yml
|
60
81
|
- test/integration/client_test.rb
|
61
|
-
- test/unit/
|
82
|
+
- test/unit/accounts_test.rb
|
83
|
+
- test/unit/infra_test.rb
|
84
|
+
- test/unit/vm_test.rb
|