cloudstack_client 0.9.7 → 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +11 -11
- data/bin/cloudstack_client +5 -0
- data/cloudstack_client.gemspec +2 -0
- data/config/4.2.json +1 -0
- data/lib/cloudstack_client/api.rb +29 -0
- data/lib/cloudstack_client/cli.rb +107 -0
- data/lib/cloudstack_client/client.rb +34 -127
- data/lib/cloudstack_client/connection.rb +131 -0
- data/lib/cloudstack_client/error.rb +9 -0
- data/lib/cloudstack_client/version.rb +1 -1
- data/lib/cloudstack_client.rb +0 -1
- metadata +38 -34
- data/lib/cloudstack_client/commands/account.rb +0 -38
- data/lib/cloudstack_client/commands/affinity_group.rb +0 -39
- data/lib/cloudstack_client/commands/capacity.rb +0 -30
- data/lib/cloudstack_client/commands/cluster.rb +0 -19
- data/lib/cloudstack_client/commands/configuration.rb +0 -42
- data/lib/cloudstack_client/commands/disk_offering.rb +0 -49
- data/lib/cloudstack_client/commands/domain.rb +0 -22
- data/lib/cloudstack_client/commands/host.rb +0 -28
- data/lib/cloudstack_client/commands/ip_address.rb +0 -83
- data/lib/cloudstack_client/commands/iso.rb +0 -76
- data/lib/cloudstack_client/commands/job.rb +0 -29
- data/lib/cloudstack_client/commands/load_balancer_rule.rb +0 -61
- data/lib/cloudstack_client/commands/network.rb +0 -130
- data/lib/cloudstack_client/commands/pod.rb +0 -20
- data/lib/cloudstack_client/commands/port_forwarding_rule.rb +0 -49
- data/lib/cloudstack_client/commands/project.rb +0 -32
- data/lib/cloudstack_client/commands/region.rb +0 -19
- data/lib/cloudstack_client/commands/resource_limit.rb +0 -125
- data/lib/cloudstack_client/commands/router.rb +0 -100
- data/lib/cloudstack_client/commands/server.rb +0 -350
- data/lib/cloudstack_client/commands/service_offering.rb +0 -98
- data/lib/cloudstack_client/commands/snapshot.rb +0 -51
- data/lib/cloudstack_client/commands/ssh_key_pair.rb +0 -137
- data/lib/cloudstack_client/commands/storage_pool.rb +0 -31
- data/lib/cloudstack_client/commands/system_vm.rb +0 -82
- data/lib/cloudstack_client/commands/template.rb +0 -60
- data/lib/cloudstack_client/commands/user.rb +0 -32
- data/lib/cloudstack_client/commands/volume.rb +0 -54
- data/lib/cloudstack_client/commands/zone.rb +0 -57
- data/lib/connection_helper.rb +0 -12
@@ -1,51 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Snapshot
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists snapshots.
|
7
|
-
|
8
|
-
def list_snapshots(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listSnapshots',
|
11
|
-
'isrecursive' => 'true'
|
12
|
-
}
|
13
|
-
params['name'] = args[:name] if args[:name]
|
14
|
-
|
15
|
-
if args[:zone]
|
16
|
-
zone = get_zone(args[:zone])
|
17
|
-
unless zone
|
18
|
-
puts "Error: Zone #{args[:zone]} not found"
|
19
|
-
exit 1
|
20
|
-
end
|
21
|
-
params['zoneid'] = zone['id']
|
22
|
-
end
|
23
|
-
|
24
|
-
if args[:project]
|
25
|
-
project = get_project(args[:project])
|
26
|
-
unless project
|
27
|
-
puts "Error: project #{args[:project]} not found."
|
28
|
-
exit 1
|
29
|
-
end
|
30
|
-
params['projectid'] = project['id']
|
31
|
-
end
|
32
|
-
|
33
|
-
if args[:account]
|
34
|
-
account = list_accounts({name: args[:account]}).first
|
35
|
-
unless account
|
36
|
-
puts "Error: Account #{args[:account]} not found."
|
37
|
-
exit 1
|
38
|
-
end
|
39
|
-
params['domainid'] = account["domainid"]
|
40
|
-
params['account'] = args[:account]
|
41
|
-
end
|
42
|
-
|
43
|
-
params['listall'] = args[:listall] if args[:listall]
|
44
|
-
|
45
|
-
json = send_request(params)
|
46
|
-
json['snapshot'] || []
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|
50
|
-
|
51
|
-
end
|
@@ -1,137 +0,0 @@
|
|
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
|
-
|
68
|
-
json = send_request(params)['keypair']
|
69
|
-
end
|
70
|
-
|
71
|
-
##
|
72
|
-
# Register ssh key pairs.
|
73
|
-
#
|
74
|
-
|
75
|
-
def register_ssh_key_pair(name, publickey, args = {})
|
76
|
-
params = {
|
77
|
-
'command' => 'registerSSHKeyPair',
|
78
|
-
'name' => name,
|
79
|
-
'publickey' => publickey
|
80
|
-
}
|
81
|
-
if args[:project]
|
82
|
-
project = get_project(args[:project])
|
83
|
-
unless project
|
84
|
-
puts "Error: project #{args[:project]} not found."
|
85
|
-
exit 1
|
86
|
-
end
|
87
|
-
params['projectid'] = project['id']
|
88
|
-
end
|
89
|
-
|
90
|
-
if args[:account]
|
91
|
-
account = list_accounts({name: args[:account]}).first
|
92
|
-
unless account
|
93
|
-
puts "Error: Account #{args[:account]} not found."
|
94
|
-
exit 1
|
95
|
-
end
|
96
|
-
params['domainid'] = account["domainid"]
|
97
|
-
params['account'] = args[:account]
|
98
|
-
end
|
99
|
-
|
100
|
-
json = send_request(params)['keypair']
|
101
|
-
end
|
102
|
-
|
103
|
-
##
|
104
|
-
# Delete ssh key pairs.
|
105
|
-
#
|
106
|
-
|
107
|
-
def delete_ssh_key_pair(name, args = {})
|
108
|
-
params = {
|
109
|
-
'command' => 'deleteSSHKeyPair',
|
110
|
-
'name' => name
|
111
|
-
}
|
112
|
-
|
113
|
-
if args[:project]
|
114
|
-
project = get_project(args[:project])
|
115
|
-
unless project
|
116
|
-
puts "Error: project #{args[:project]} not found."
|
117
|
-
exit 1
|
118
|
-
end
|
119
|
-
params['projectid'] = project['id']
|
120
|
-
end
|
121
|
-
|
122
|
-
if args[:account]
|
123
|
-
account = list_accounts({name: args[:account]}).first
|
124
|
-
unless account
|
125
|
-
puts "Error: Account #{args[:account]} not found."
|
126
|
-
exit 1
|
127
|
-
end
|
128
|
-
params['domainid'] = account["domainid"]
|
129
|
-
params['account'] = args[:account]
|
130
|
-
end
|
131
|
-
|
132
|
-
json = send_request(params)
|
133
|
-
end
|
134
|
-
|
135
|
-
end
|
136
|
-
|
137
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module StoragePool
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists all storage pools.
|
7
|
-
|
8
|
-
def list_storage_pools(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listStoragePools',
|
11
|
-
}
|
12
|
-
|
13
|
-
if args[:zone]
|
14
|
-
zone = get_zone(args[:zone])
|
15
|
-
unless zone
|
16
|
-
puts "Error: Zone #{args[:zone]} not found"
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
params['zoneid'] = zone['id']
|
20
|
-
end
|
21
|
-
|
22
|
-
params['keyword'] = args[:keyword] if args[:keyword]
|
23
|
-
params['name'] = args[:name] if args[:name]
|
24
|
-
|
25
|
-
json = send_request(params)
|
26
|
-
json['storagepool'] || []
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
30
|
-
|
31
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module SystemVm
|
4
|
-
|
5
|
-
##
|
6
|
-
# List system virtual machines.
|
7
|
-
|
8
|
-
def list_system_vms(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listSystemVms'
|
11
|
-
}
|
12
|
-
|
13
|
-
if args[:zone]
|
14
|
-
zone = get_zone(args[:zone])
|
15
|
-
unless zone
|
16
|
-
puts "Error: zone #{args[:project]} not found."
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
params['zoneid'] = zone['id']
|
20
|
-
end
|
21
|
-
|
22
|
-
params['state'] = args[:state] if args[:state]
|
23
|
-
params['podid'] = args[:podid] if args[:podid]
|
24
|
-
params['systemvmtype'] = args[:type] if args[:type]
|
25
|
-
params['storageid'] = args[:storage_id] if args[:storage_id]
|
26
|
-
|
27
|
-
json = send_request(params)
|
28
|
-
json['systemvm'] || []
|
29
|
-
end
|
30
|
-
|
31
|
-
##
|
32
|
-
# Stop system VM.
|
33
|
-
#
|
34
|
-
|
35
|
-
def stop_system_vm(id, args = {})
|
36
|
-
params = {
|
37
|
-
'command' => 'stopSystemVm',
|
38
|
-
'id' => id
|
39
|
-
}
|
40
|
-
params['forced'] = true if args[:forced]
|
41
|
-
args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
|
42
|
-
end
|
43
|
-
|
44
|
-
##
|
45
|
-
# Start system VM.
|
46
|
-
#
|
47
|
-
|
48
|
-
def start_system_vm(id, args = {})
|
49
|
-
params = {
|
50
|
-
'command' => 'startSystemVm',
|
51
|
-
'id' => id
|
52
|
-
}
|
53
|
-
args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
|
54
|
-
end
|
55
|
-
|
56
|
-
##
|
57
|
-
# Reboot sytem VM.
|
58
|
-
#
|
59
|
-
|
60
|
-
def reboot_system_vm(id, args = {})
|
61
|
-
params = {
|
62
|
-
'command' => 'rebootSystemVm',
|
63
|
-
'id' => id
|
64
|
-
}
|
65
|
-
args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
|
66
|
-
end
|
67
|
-
|
68
|
-
##
|
69
|
-
# Destroy sytem VM.
|
70
|
-
#
|
71
|
-
|
72
|
-
def destroy_system_vm(id, args = {})
|
73
|
-
params = {
|
74
|
-
'command' => 'destroySystemVm',
|
75
|
-
'id' => id
|
76
|
-
}
|
77
|
-
args[:sync] ? send_request(params) : send_async_request(params)['systemvm']
|
78
|
-
end
|
79
|
-
|
80
|
-
end # module
|
81
|
-
|
82
|
-
end
|
@@ -1,60 +0,0 @@
|
|
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
|
@@ -1,32 +0,0 @@
|
|
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
|
@@ -1,54 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Volume
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists all volumes.
|
7
|
-
|
8
|
-
def list_volumes(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listVolumes',
|
11
|
-
'listall' => true,
|
12
|
-
}
|
13
|
-
|
14
|
-
if args[:zone]
|
15
|
-
zone = get_zone(args[:zone])
|
16
|
-
unless zone
|
17
|
-
puts "Error: Zone #{args[:zone]} not found"
|
18
|
-
exit 1
|
19
|
-
end
|
20
|
-
params['zoneid'] = zone['id']
|
21
|
-
end
|
22
|
-
|
23
|
-
if args[:account]
|
24
|
-
if account = list_accounts(name: args[:account]).first
|
25
|
-
params['domainid'] = account["domainid"]
|
26
|
-
params['account'] = args[:account]
|
27
|
-
end
|
28
|
-
end
|
29
|
-
|
30
|
-
if args[:project]
|
31
|
-
project = get_project(args[:project])
|
32
|
-
unless project
|
33
|
-
puts "Error: project #{args[:project]} not found."
|
34
|
-
exit 1
|
35
|
-
end
|
36
|
-
params['projectid'] = project['id']
|
37
|
-
end
|
38
|
-
|
39
|
-
params['projectid'] = args[:project_id] if args[:project_id]
|
40
|
-
params['type'] = args[:type] if args[:type]
|
41
|
-
params['keyword'] = args[:keyword] if args[:keyword]
|
42
|
-
params['name'] = args[:name] if args[:name]
|
43
|
-
params['virtualmachineid'] = args[:virtual_machine_id] if args[:virtual_machine_id]
|
44
|
-
params['tags'] = args[:tags] if args[:tags]
|
45
|
-
params['podid'] = args[:pod_id] if args[:pod_id]
|
46
|
-
params['isrecursive'] = args[:is_recursive] if args[:is_recursive]
|
47
|
-
|
48
|
-
json = send_request(params)
|
49
|
-
json['volume'] || []
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
53
|
-
|
54
|
-
end
|
@@ -1,57 +0,0 @@
|
|
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
|
data/lib/connection_helper.rb
DELETED