cloudstack-cli 0.3.11 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/Gemfile.lock +3 -1
- data/bin/cs +1 -2
- data/cloudstack-cli.gemspec +1 -0
- data/lib/{cloudstack_cli.rb → cloudstack-cli.rb} +2 -0
- data/lib/cloudstack-cli/commands/router.rb +3 -1
- data/lib/cloudstack-cli/version.rb +1 -1
- metadata +24 -44
- data/lib/cloudstack-client/client.rb +0 -136
- data/lib/cloudstack-client/commands/account.rb +0 -22
- data/lib/cloudstack-client/commands/capacity.rb +0 -19
- data/lib/cloudstack-client/commands/cluster.rb +0 -19
- 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 -82
- data/lib/cloudstack-client/commands/iso.rb +0 -64
- 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 -128
- data/lib/cloudstack-client/commands/pod.rb +0 -19
- 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/router.rb +0 -89
- data/lib/cloudstack-client/commands/server.rb +0 -311
- data/lib/cloudstack-client/commands/service_offering.rb +0 -98
- data/lib/cloudstack-client/commands/snapshot.rb +0 -40
- data/lib/cloudstack-client/commands/ssh_key_pair.rb +0 -106
- 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 -20
- data/lib/cloudstack-client/commands/zone.rb +0 -57
- data/lib/cloudstack-client/version.rb +0 -3
- data/lib/cloudstack_client.rb +0 -2
@@ -1,22 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Domain
|
4
|
-
|
5
|
-
##
|
6
|
-
# List domains.
|
7
|
-
|
8
|
-
def list_domains(name = nil)
|
9
|
-
params = {
|
10
|
-
'command' => 'listDomains',
|
11
|
-
'listall' => 'true',
|
12
|
-
'isrecursive' => 'true'
|
13
|
-
}
|
14
|
-
params['name'] = name if name
|
15
|
-
|
16
|
-
json = send_request(params)
|
17
|
-
json['domain'] || []
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
|
22
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Host
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists hosts.
|
7
|
-
|
8
|
-
def list_hosts(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listHosts'
|
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
|
-
json = send_request(params)
|
23
|
-
json['host'] || []
|
24
|
-
end
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module IpAddress
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists the public ip addresses.
|
7
|
-
|
8
|
-
def list_public_ip_addresses(args = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listPublicIpAddresses',
|
11
|
-
'isrecursive' => true
|
12
|
-
}
|
13
|
-
if args[:project]
|
14
|
-
project = get_project(args[:project])
|
15
|
-
unless project
|
16
|
-
puts "Error: project #{args[:project]} not found."
|
17
|
-
exit 1
|
18
|
-
end
|
19
|
-
params['projectid'] = project['id']
|
20
|
-
end
|
21
|
-
if args[:account]
|
22
|
-
account = list_accounts({name: args[:account]}).first
|
23
|
-
unless account
|
24
|
-
puts "Error: Account #{args[:account]} not found."
|
25
|
-
exit 1
|
26
|
-
end
|
27
|
-
params['domainid'] = account["domainid"]
|
28
|
-
params['account'] = args[:account]
|
29
|
-
end
|
30
|
-
params['listall'] = args[:listall] if args[:listall]
|
31
|
-
|
32
|
-
json = send_request(params)
|
33
|
-
json['publicipaddress'] || []
|
34
|
-
end
|
35
|
-
|
36
|
-
##
|
37
|
-
# Finds the public ip address for a given ip address string.
|
38
|
-
|
39
|
-
def get_public_ip_address(ip_address, project_id = nil)
|
40
|
-
params = {
|
41
|
-
'command' => 'listPublicIpAddresses',
|
42
|
-
'ipaddress' => ip_address
|
43
|
-
}
|
44
|
-
params['projectid'] = project_id if project_id
|
45
|
-
json = send_request(params)
|
46
|
-
ip_address = json['publicipaddress']
|
47
|
-
|
48
|
-
return nil unless ip_address
|
49
|
-
ip_address.first
|
50
|
-
end
|
51
|
-
|
52
|
-
|
53
|
-
##
|
54
|
-
# Acquires and associates a public IP to an account.
|
55
|
-
|
56
|
-
def associate_ip_address(network_id)
|
57
|
-
params = {
|
58
|
-
'command' => 'associateIpAddress',
|
59
|
-
'networkid' => network_id
|
60
|
-
}
|
61
|
-
|
62
|
-
json = send_async_request(params)
|
63
|
-
json['ipaddress']
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Disassociates an ip address from the account.
|
68
|
-
#
|
69
|
-
# Returns true if successful, false otherwise.
|
70
|
-
|
71
|
-
def disassociate_ip_address(id)
|
72
|
-
params = {
|
73
|
-
'command' => 'disassociateIpAddress',
|
74
|
-
'id' => id
|
75
|
-
}
|
76
|
-
json = send_async_request(params)
|
77
|
-
json['success']
|
78
|
-
end
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
end
|
@@ -1,64 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Iso
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists all isos that match the specified filter.
|
7
|
-
#
|
8
|
-
# Allowable filter values are:
|
9
|
-
#
|
10
|
-
# * featured - isos that are featured and are public
|
11
|
-
# * self - isos that have been registered/created by the owner
|
12
|
-
# * self-executable - isos that have been registered/created by the owner that can be used to deploy a new VM
|
13
|
-
# * executable - all isos that can be used to deploy a new VM
|
14
|
-
# * community - isos that are public
|
15
|
-
|
16
|
-
def list_isos(args = {})
|
17
|
-
filter = args[:filter] || 'featured'
|
18
|
-
params = {
|
19
|
-
'command' => 'listIsos',
|
20
|
-
'isofilter' => filter
|
21
|
-
}
|
22
|
-
params['projectid'] = args[:project_id] if args[:project_id]
|
23
|
-
params['zoneid'] = args[:zone_id] if args[:zone_id]
|
24
|
-
if args[:listall]
|
25
|
-
params['listall'] = true
|
26
|
-
params['isrecursive'] = true
|
27
|
-
end
|
28
|
-
|
29
|
-
json = send_request(params)
|
30
|
-
json['iso'] || []
|
31
|
-
end
|
32
|
-
|
33
|
-
##
|
34
|
-
# Finds the template with the specified name.
|
35
|
-
|
36
|
-
def get_iso(name)
|
37
|
-
|
38
|
-
# TODO: use name parameter
|
39
|
-
# listIsos in CloudStack 2.2 doesn't seem to work
|
40
|
-
# when the name parameter is specified. When this is fixed,
|
41
|
-
# the name parameter should be added to the request.
|
42
|
-
params = {
|
43
|
-
'command' => 'listIsos',
|
44
|
-
'isoFilter' => 'executable'
|
45
|
-
}
|
46
|
-
json = send_request(params)
|
47
|
-
|
48
|
-
isos = json['iso']
|
49
|
-
if !isos then
|
50
|
-
return nil
|
51
|
-
end
|
52
|
-
|
53
|
-
isos.each { |t|
|
54
|
-
if t['name'] == name then
|
55
|
-
return t
|
56
|
-
end
|
57
|
-
}
|
58
|
-
|
59
|
-
nil
|
60
|
-
end
|
61
|
-
|
62
|
-
end
|
63
|
-
|
64
|
-
end
|
@@ -1,29 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Job
|
4
|
-
|
5
|
-
##
|
6
|
-
# Retrieves the current status of asynchronous job.
|
7
|
-
|
8
|
-
def query_job(id)
|
9
|
-
params = {
|
10
|
-
'command' => 'queryAsyncJobResult',
|
11
|
-
'jobid' => id,
|
12
|
-
}
|
13
|
-
send_request(params)
|
14
|
-
end
|
15
|
-
|
16
|
-
##
|
17
|
-
# Lists all pending asynchronous jobs for the account.
|
18
|
-
|
19
|
-
def list_jobs(opts = {})
|
20
|
-
params = {
|
21
|
-
'command' => 'listAsyncJobs'
|
22
|
-
}
|
23
|
-
params['listall'] = true if opts[:listall]
|
24
|
-
send_request(params)['asyncjobs']
|
25
|
-
end
|
26
|
-
|
27
|
-
end
|
28
|
-
|
29
|
-
end
|
@@ -1,61 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module LoadBalancerRule
|
4
|
-
|
5
|
-
##
|
6
|
-
# List loadbalancer rules
|
7
|
-
|
8
|
-
def list_load_balancer_rules(options = {})
|
9
|
-
params = {
|
10
|
-
'command' => 'listLoadBalancerRules',
|
11
|
-
}
|
12
|
-
params['name'] = options[:name] if options[:name]
|
13
|
-
|
14
|
-
if options[:project_name]
|
15
|
-
project = get_project(options[:project_name])
|
16
|
-
params['projectid'] = project['id']
|
17
|
-
end
|
18
|
-
|
19
|
-
json = send_request(params)
|
20
|
-
json['loadbalancerrule'] || []
|
21
|
-
end
|
22
|
-
|
23
|
-
##
|
24
|
-
# Creates a load balancing rule.
|
25
|
-
|
26
|
-
def create_load_balancer_rule(name, publicip, private_port, public_port, options = {})
|
27
|
-
params = {
|
28
|
-
'command' => 'createLoadBalancerRule',
|
29
|
-
'name' => name,
|
30
|
-
'privateport' => private_port,
|
31
|
-
'publicport' => public_port,
|
32
|
-
'publicipid' => get_public_ip_address(publicip)['id']
|
33
|
-
}
|
34
|
-
params['algorithm'] = options[:algorithm] || 'roundrobin'
|
35
|
-
params['openfirewall'] = options[:openfirewall] || true
|
36
|
-
|
37
|
-
json = send_async_request(params)
|
38
|
-
json['LoadBalancerRule']
|
39
|
-
end
|
40
|
-
|
41
|
-
##
|
42
|
-
# Assigns virtual machine or a list of virtual machines to a load balancer rule.
|
43
|
-
|
44
|
-
def assign_to_load_balancer_rule(name, vm_names)
|
45
|
-
id = list_load_balancer_rules(name).first['id']
|
46
|
-
|
47
|
-
vm_ids = vm_names.map do |vm|
|
48
|
-
get_server(vm)['id']
|
49
|
-
end
|
50
|
-
|
51
|
-
params = {
|
52
|
-
'command' => 'assignToLoadBalancerRule',
|
53
|
-
'id' => id,
|
54
|
-
'virtualmachineids' => vm_ids.join(',')
|
55
|
-
}
|
56
|
-
json = send_async_request(params)
|
57
|
-
end
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
end
|
@@ -1,128 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module Network
|
4
|
-
|
5
|
-
##
|
6
|
-
# Finds the network with the specified name.
|
7
|
-
|
8
|
-
def networkid_to_name(id, project_id=nil)
|
9
|
-
params = {
|
10
|
-
'command' => 'listNetworks',
|
11
|
-
'id' => id
|
12
|
-
}
|
13
|
-
params['projectid'] = project_id if project_id
|
14
|
-
json = send_request(params)
|
15
|
-
|
16
|
-
json['network'] ? json['network'].first['name'] : nil
|
17
|
-
end
|
18
|
-
|
19
|
-
##
|
20
|
-
# Finds the network with the specified name.
|
21
|
-
|
22
|
-
def get_network(name, project_id = nil)
|
23
|
-
params = {
|
24
|
-
'command' => 'listNetworks',
|
25
|
-
'listall' => true
|
26
|
-
}
|
27
|
-
params['projectid'] = project_id if project_id
|
28
|
-
json = send_request(params)
|
29
|
-
|
30
|
-
networks = json['network']
|
31
|
-
return nil unless networks
|
32
|
-
|
33
|
-
networks.each { |n|
|
34
|
-
if n['name'] == name then
|
35
|
-
return n
|
36
|
-
end
|
37
|
-
}
|
38
|
-
nil
|
39
|
-
end
|
40
|
-
|
41
|
-
##
|
42
|
-
# Finds the default network.
|
43
|
-
|
44
|
-
def get_default_network(zone = nil)
|
45
|
-
params = {
|
46
|
-
'command' => 'listNetworks',
|
47
|
-
'isDefault' => true
|
48
|
-
}
|
49
|
-
if zone
|
50
|
-
params['zoneid'] = get_zone(zone)['id']
|
51
|
-
end
|
52
|
-
json = send_request(params)
|
53
|
-
|
54
|
-
networks = json['network']
|
55
|
-
return nil if !networks || networks.empty?
|
56
|
-
return networks.first if networks.length == 1
|
57
|
-
|
58
|
-
networks.each { |n|
|
59
|
-
if n['type'] == 'Direct' then
|
60
|
-
return n
|
61
|
-
end
|
62
|
-
}
|
63
|
-
nil
|
64
|
-
end
|
65
|
-
|
66
|
-
##
|
67
|
-
# Lists all available networks.
|
68
|
-
|
69
|
-
def list_networks(args = {})
|
70
|
-
params = {
|
71
|
-
'command' => 'listNetworks',
|
72
|
-
'listall' => true,
|
73
|
-
}
|
74
|
-
params['projectid'] = args[:project_id] if args[:project_id]
|
75
|
-
params['zoneid'] = args[:zone_id] if args[:zone_id]
|
76
|
-
params['isDefault'] = true if args[:isdefault]
|
77
|
-
if args[:account]
|
78
|
-
domain = list_accounts(name: args[:account])
|
79
|
-
if domain.size > 0
|
80
|
-
params['account'] = args[:account]
|
81
|
-
params['domainid'] = domain.first["domainid"]
|
82
|
-
else
|
83
|
-
puts "Account #{args[:account]} not found."
|
84
|
-
end
|
85
|
-
end
|
86
|
-
json = send_request(params)
|
87
|
-
json['network'] || []
|
88
|
-
end
|
89
|
-
|
90
|
-
##
|
91
|
-
# Delete network.
|
92
|
-
|
93
|
-
def delete_network(id)
|
94
|
-
params = {
|
95
|
-
'command' => 'deleteNetwork',
|
96
|
-
'id' => id,
|
97
|
-
}
|
98
|
-
p json = send_async_request(params)
|
99
|
-
json['network']
|
100
|
-
end
|
101
|
-
|
102
|
-
##
|
103
|
-
# Restart network.
|
104
|
-
|
105
|
-
def restart_network(id, cleanup = false)
|
106
|
-
params = {
|
107
|
-
'command' => 'restartNetwork',
|
108
|
-
'id' => id,
|
109
|
-
'cleanup' => cleanup,
|
110
|
-
}
|
111
|
-
p json = send_async_request(params)
|
112
|
-
json['network']
|
113
|
-
end
|
114
|
-
|
115
|
-
##
|
116
|
-
# Lists all physical networks.
|
117
|
-
|
118
|
-
def list_physical_networks
|
119
|
-
params = {
|
120
|
-
'command' => 'listPhysicalNetworks',
|
121
|
-
}
|
122
|
-
json = send_request(params)
|
123
|
-
json['physicalnetwork'] || []
|
124
|
-
end
|
125
|
-
|
126
|
-
end
|
127
|
-
|
128
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
module CloudstackClient
|
2
|
-
|
3
|
-
module PortForwardingRule
|
4
|
-
|
5
|
-
##
|
6
|
-
# Lists all port forwarding rules.
|
7
|
-
|
8
|
-
def list_port_forwarding_rules(ip_address_id=nil, project_id)
|
9
|
-
params = {
|
10
|
-
'command' => 'listPortForwardingRules',
|
11
|
-
'listall' => true,
|
12
|
-
'isrecursive' => true
|
13
|
-
}
|
14
|
-
params['ipAddressId'] = ip_address_id if ip_address_id
|
15
|
-
params['projectid'] = project_id if project_id
|
16
|
-
json = send_request(params)
|
17
|
-
json['portforwardingrule'] || []
|
18
|
-
end
|
19
|
-
|
20
|
-
##
|
21
|
-
# Gets the SSH port forwarding rule for the specified server.
|
22
|
-
|
23
|
-
def get_ssh_port_forwarding_rule(server, cached_rules=nil)
|
24
|
-
rules = cached_rules || list_port_forwarding_rules || []
|
25
|
-
rules.find_all { |r|
|
26
|
-
r['virtualmachineid'] == server['id'] &&
|
27
|
-
r['privateport'] == '22'&&
|
28
|
-
r['publicport'] == '22'
|
29
|
-
}.first
|
30
|
-
end
|
31
|
-
|
32
|
-
##
|
33
|
-
# Creates a port forwarding rule.
|
34
|
-
|
35
|
-
def create_port_forwarding_rule(ip_address_id, private_port, protocol, public_port, virtual_machine_id, async = true)
|
36
|
-
params = {
|
37
|
-
'command' => 'createPortForwardingRule',
|
38
|
-
'ipAddressId' => ip_address_id,
|
39
|
-
'privatePort' => private_port,
|
40
|
-
'protocol' => protocol,
|
41
|
-
'publicPort' => public_port,
|
42
|
-
'virtualMachineId' => virtual_machine_id
|
43
|
-
}
|
44
|
-
async ? send_async_request(params)['portforwardingrule'] : send_request(params)
|
45
|
-
end
|
46
|
-
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|