cloudstack_client 0.2.10
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +3 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +21 -0
- data/README.md +26 -0
- data/cloudstack_client.gemspec +24 -0
- data/lib/cloudstack_client.rb +2 -0
- data/lib/cloudstack_client/client.rb +136 -0
- data/lib/cloudstack_client/commands/account.rb +22 -0
- data/lib/cloudstack_client/commands/capacity.rb +19 -0
- data/lib/cloudstack_client/commands/cluster.rb +19 -0
- data/lib/cloudstack_client/commands/disk_offering.rb +49 -0
- data/lib/cloudstack_client/commands/domain.rb +22 -0
- data/lib/cloudstack_client/commands/host.rb +28 -0
- data/lib/cloudstack_client/commands/ip_address.rb +82 -0
- data/lib/cloudstack_client/commands/iso.rb +64 -0
- data/lib/cloudstack_client/commands/job.rb +29 -0
- data/lib/cloudstack_client/commands/load_balancer_rule.rb +61 -0
- data/lib/cloudstack_client/commands/network.rb +128 -0
- data/lib/cloudstack_client/commands/pod.rb +19 -0
- data/lib/cloudstack_client/commands/port_forwarding_rule.rb +49 -0
- data/lib/cloudstack_client/commands/project.rb +32 -0
- data/lib/cloudstack_client/commands/router.rb +89 -0
- data/lib/cloudstack_client/commands/server.rb +311 -0
- data/lib/cloudstack_client/commands/service_offering.rb +98 -0
- data/lib/cloudstack_client/commands/snapshot.rb +40 -0
- data/lib/cloudstack_client/commands/ssh_key_pair.rb +106 -0
- data/lib/cloudstack_client/commands/template.rb +60 -0
- data/lib/cloudstack_client/commands/user.rb +32 -0
- data/lib/cloudstack_client/commands/volume.rb +20 -0
- data/lib/cloudstack_client/commands/zone.rb +57 -0
- data/lib/cloudstack_client/version.rb +3 -0
- data/lib/connection_helper.rb +12 -0
- metadata +106 -0
@@ -0,0 +1,106 @@
|
|
1
|
+
module CloudstackClient
|
2
|
+
|
3
|
+
module SshKeyPair
|
4
|
+
|
5
|
+
##
|
6
|
+
# Lists ssh key pairs.
|
7
|
+
#
|
8
|
+
|
9
|
+
def list_ssh_key_pairs(args = {})
|
10
|
+
params = {
|
11
|
+
'command' => 'listSSHKeyPairs',
|
12
|
+
'isrecursive' => true
|
13
|
+
}
|
14
|
+
params['listall'] = true if args[:listall]
|
15
|
+
params['name'] = args[:name] if args[:name]
|
16
|
+
|
17
|
+
if args[:project]
|
18
|
+
project = get_project(args[:project])
|
19
|
+
unless project
|
20
|
+
puts "Error: project #{args[:project]} not found."
|
21
|
+
exit 1
|
22
|
+
end
|
23
|
+
params['projectid'] = project['id']
|
24
|
+
end
|
25
|
+
|
26
|
+
if args[:account]
|
27
|
+
account = list_accounts({name: args[:account]}).first
|
28
|
+
unless account
|
29
|
+
puts "Error: Account #{args[:account]} not found."
|
30
|
+
exit 1
|
31
|
+
end
|
32
|
+
params['domainid'] = account["domainid"]
|
33
|
+
params['account'] = args[:account]
|
34
|
+
end
|
35
|
+
|
36
|
+
json = send_request(params)
|
37
|
+
json['sshkeypair'] || []
|
38
|
+
end
|
39
|
+
|
40
|
+
##
|
41
|
+
# Create ssh key pairs.
|
42
|
+
#
|
43
|
+
|
44
|
+
def create_ssh_key_pair(name, args = {})
|
45
|
+
params = {
|
46
|
+
'command' => 'createSSHKeyPair',
|
47
|
+
'name' => name
|
48
|
+
}
|
49
|
+
if args[:project]
|
50
|
+
project = get_project(args[:project])
|
51
|
+
unless project
|
52
|
+
puts "Error: project #{args[:project]} not found."
|
53
|
+
exit 1
|
54
|
+
end
|
55
|
+
params['projectid'] = project['id']
|
56
|
+
end
|
57
|
+
|
58
|
+
if args[:account]
|
59
|
+
account = list_accounts({name: args[:account]}).first
|
60
|
+
unless account
|
61
|
+
puts "Error: Account #{args[:account]} not found."
|
62
|
+
exit 1
|
63
|
+
end
|
64
|
+
params['domainid'] = account["domainid"]
|
65
|
+
params['account'] = args[:account]
|
66
|
+
end
|
67
|
+
params['publickey'] = args[:public_key] if args[:public_key]
|
68
|
+
|
69
|
+
json = send_request(params)['keypair']
|
70
|
+
end
|
71
|
+
|
72
|
+
##
|
73
|
+
# Delete ssh key pairs.
|
74
|
+
#
|
75
|
+
|
76
|
+
def delete_ssh_key_pair(name, args = {})
|
77
|
+
params = {
|
78
|
+
'command' => 'deleteSSHKeyPair',
|
79
|
+
'name' => name
|
80
|
+
}
|
81
|
+
|
82
|
+
if args[:project]
|
83
|
+
project = get_project(args[:project])
|
84
|
+
unless project
|
85
|
+
puts "Error: project #{args[:project]} not found."
|
86
|
+
exit 1
|
87
|
+
end
|
88
|
+
params['projectid'] = project['id']
|
89
|
+
end
|
90
|
+
|
91
|
+
if args[:account]
|
92
|
+
account = list_accounts({name: args[:account]}).first
|
93
|
+
unless account
|
94
|
+
puts "Error: Account #{args[:account]} not found."
|
95
|
+
exit 1
|
96
|
+
end
|
97
|
+
params['domainid'] = account["domainid"]
|
98
|
+
params['account'] = args[:account]
|
99
|
+
end
|
100
|
+
|
101
|
+
json = send_request(params)
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
module CloudstackClient
|
2
|
+
|
3
|
+
module Template
|
4
|
+
|
5
|
+
##
|
6
|
+
# Finds the template with the specified name.
|
7
|
+
|
8
|
+
def get_template(name)
|
9
|
+
|
10
|
+
# TODO: use name parameter
|
11
|
+
# listTemplates in CloudStack 2.2 doesn't seem to work
|
12
|
+
# when the name parameter is specified. When this is fixed,
|
13
|
+
# the name parameter should be added to the request.
|
14
|
+
params = {
|
15
|
+
'command' => 'listTemplates',
|
16
|
+
'templateFilter' => 'executable'
|
17
|
+
}
|
18
|
+
json = send_request(params)
|
19
|
+
|
20
|
+
templates = json['template']
|
21
|
+
if !templates then
|
22
|
+
return nil
|
23
|
+
end
|
24
|
+
|
25
|
+
templates.each { |t|
|
26
|
+
if t['name'] == name then
|
27
|
+
return t
|
28
|
+
end
|
29
|
+
}
|
30
|
+
|
31
|
+
nil
|
32
|
+
end
|
33
|
+
|
34
|
+
##
|
35
|
+
# Lists all templates that match the specified filter.
|
36
|
+
#
|
37
|
+
# Allowable filter values are:
|
38
|
+
#
|
39
|
+
# * featured - templates that are featured and are public
|
40
|
+
# * self - templates that have been registered/created by the owner
|
41
|
+
# * self-executable - templates that have been registered/created by the owner that can be used to deploy a new VM
|
42
|
+
# * executable - all templates that can be used to deploy a new VM
|
43
|
+
# * community - templates that are public
|
44
|
+
|
45
|
+
def list_templates(args = {})
|
46
|
+
filter = args[:filter] || 'featured'
|
47
|
+
params = {
|
48
|
+
'command' => 'listTemplates',
|
49
|
+
'templateFilter' => filter
|
50
|
+
}
|
51
|
+
params['projectid'] = args[:project_id] if args[:project_id]
|
52
|
+
params['zoneid'] = args[:zone_id] if args[:zone_id]
|
53
|
+
|
54
|
+
json = send_request(params)
|
55
|
+
json['template'] || []
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
module CloudstackClient
|
2
|
+
|
3
|
+
module User
|
4
|
+
|
5
|
+
##
|
6
|
+
# Lists users.
|
7
|
+
#
|
8
|
+
|
9
|
+
def list_users(args = {})
|
10
|
+
params = {
|
11
|
+
'command' => 'listUsers',
|
12
|
+
'isrecursive' => true
|
13
|
+
}
|
14
|
+
params['listall'] = true if args[:listall]
|
15
|
+
|
16
|
+
if args[:account]
|
17
|
+
account = list_accounts({name: args[:account]}).first
|
18
|
+
unless account
|
19
|
+
puts "Error: Account #{args[:account]} not found."
|
20
|
+
exit 1
|
21
|
+
end
|
22
|
+
params['domainid'] = account["domainid"]
|
23
|
+
params['account'] = args[:account]
|
24
|
+
end
|
25
|
+
|
26
|
+
json = send_request(params)
|
27
|
+
json['user'] || []
|
28
|
+
end
|
29
|
+
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
module CloudstackClient
|
2
|
+
|
3
|
+
module Volume
|
4
|
+
|
5
|
+
##
|
6
|
+
# Lists all volumes.
|
7
|
+
|
8
|
+
def list_volumes(project_id = nil)
|
9
|
+
params = {
|
10
|
+
'command' => 'listVolumes',
|
11
|
+
'listall' => true,
|
12
|
+
}
|
13
|
+
params['projectid'] = project_id if project_id
|
14
|
+
json = send_request(params)
|
15
|
+
json['volume'] || []
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module CloudstackClient
|
2
|
+
|
3
|
+
module Zone
|
4
|
+
|
5
|
+
##
|
6
|
+
# Finds the zone with the specified name.
|
7
|
+
|
8
|
+
def get_zone(name)
|
9
|
+
params = {
|
10
|
+
'command' => 'listZones',
|
11
|
+
'available' => 'true'
|
12
|
+
}
|
13
|
+
json = send_request(params)
|
14
|
+
|
15
|
+
networks = json['zone']
|
16
|
+
return nil unless networks
|
17
|
+
|
18
|
+
networks.each { |z|
|
19
|
+
if z['name'] == name then
|
20
|
+
return z
|
21
|
+
end
|
22
|
+
}
|
23
|
+
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
|
27
|
+
##
|
28
|
+
# Finds the default zone for your account.
|
29
|
+
|
30
|
+
def get_default_zone
|
31
|
+
params = {
|
32
|
+
'command' => 'listZones',
|
33
|
+
'available' => 'true'
|
34
|
+
}
|
35
|
+
json = send_request(params)
|
36
|
+
|
37
|
+
zones = json['zone']
|
38
|
+
return nil unless zones
|
39
|
+
|
40
|
+
zones.first
|
41
|
+
end
|
42
|
+
|
43
|
+
##
|
44
|
+
# Lists all available zones.
|
45
|
+
|
46
|
+
def list_zones
|
47
|
+
params = {
|
48
|
+
'command' => 'listZones',
|
49
|
+
'available' => 'true'
|
50
|
+
}
|
51
|
+
json = send_request(params)
|
52
|
+
json['zone'] || []
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
56
|
+
|
57
|
+
end
|
metadata
ADDED
@@ -0,0 +1,106 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cloudstack_client
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.2.10
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Nik Wolfgramm
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-11-08 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rdoc
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :development
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rake
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ~>
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 10.0.4
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ~>
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 10.0.4
|
41
|
+
description: A ruby CloudStack API client
|
42
|
+
email:
|
43
|
+
- nik.wolfgramm@gmail.com
|
44
|
+
executables: []
|
45
|
+
extensions: []
|
46
|
+
extra_rdoc_files: []
|
47
|
+
files:
|
48
|
+
- .gitignore
|
49
|
+
- Gemfile
|
50
|
+
- LICENSE.txt
|
51
|
+
- README.md
|
52
|
+
- cloudstack_client.gemspec
|
53
|
+
- lib/cloudstack_client.rb
|
54
|
+
- lib/cloudstack_client/client.rb
|
55
|
+
- lib/cloudstack_client/commands/account.rb
|
56
|
+
- lib/cloudstack_client/commands/capacity.rb
|
57
|
+
- lib/cloudstack_client/commands/cluster.rb
|
58
|
+
- lib/cloudstack_client/commands/disk_offering.rb
|
59
|
+
- lib/cloudstack_client/commands/domain.rb
|
60
|
+
- lib/cloudstack_client/commands/host.rb
|
61
|
+
- lib/cloudstack_client/commands/ip_address.rb
|
62
|
+
- lib/cloudstack_client/commands/iso.rb
|
63
|
+
- lib/cloudstack_client/commands/job.rb
|
64
|
+
- lib/cloudstack_client/commands/load_balancer_rule.rb
|
65
|
+
- lib/cloudstack_client/commands/network.rb
|
66
|
+
- lib/cloudstack_client/commands/pod.rb
|
67
|
+
- lib/cloudstack_client/commands/port_forwarding_rule.rb
|
68
|
+
- lib/cloudstack_client/commands/project.rb
|
69
|
+
- lib/cloudstack_client/commands/router.rb
|
70
|
+
- lib/cloudstack_client/commands/server.rb
|
71
|
+
- lib/cloudstack_client/commands/service_offering.rb
|
72
|
+
- lib/cloudstack_client/commands/snapshot.rb
|
73
|
+
- lib/cloudstack_client/commands/ssh_key_pair.rb
|
74
|
+
- lib/cloudstack_client/commands/template.rb
|
75
|
+
- lib/cloudstack_client/commands/user.rb
|
76
|
+
- lib/cloudstack_client/commands/volume.rb
|
77
|
+
- lib/cloudstack_client/commands/zone.rb
|
78
|
+
- lib/cloudstack_client/version.rb
|
79
|
+
- lib/connection_helper.rb
|
80
|
+
homepage: https://bitbucket.org/swisstxt/cloudstack_client
|
81
|
+
licenses:
|
82
|
+
- MIT
|
83
|
+
metadata: {}
|
84
|
+
post_install_message:
|
85
|
+
rdoc_options:
|
86
|
+
- --line-numbers
|
87
|
+
- --inline-source
|
88
|
+
require_paths:
|
89
|
+
- lib
|
90
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
requirements:
|
92
|
+
- - '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 1.9.3
|
95
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - '>='
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
requirements: []
|
101
|
+
rubyforge_project:
|
102
|
+
rubygems_version: 2.0.3
|
103
|
+
signing_key:
|
104
|
+
specification_version: 4
|
105
|
+
summary: A ruby CloudStack API client
|
106
|
+
test_files: []
|