vcli 0.2.4 → 0.2.5
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 +4 -4
- data/lib/vcli/cli.rb +103 -0
- data/lib/vcli/cli/create.rb +1 -2
- data/lib/vcli/cli/show.rb +29 -1
- data/lib/vcli/version.rb +5 -1
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b173126518d858853f8fde0e0b9d27fe71d7fe41
|
4
|
+
data.tar.gz: bcd88daf8c29e87f836299cc1515f0d7e1758e4a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fc06acdf59f7578d0619d774d78f311a38aa36412c21aa8d63064b96d02e79589c7db357c6194ff657d90edb914a796668734711cce4b73822f21e3b1956fba7
|
7
|
+
data.tar.gz: 098e735691cfadf26c373b94480124f81f0546052707ae8247a01c8f6154a59a0330a82e72ed77a0af0c6e52f063074887f08ca2a02887da29f261417f895456
|
data/lib/vcli/cli.rb
CHANGED
@@ -76,5 +76,108 @@ module Vcli
|
|
76
76
|
|
77
77
|
desc "delete COMMANDS", "Delete items within the Abiquo VDC"
|
78
78
|
subcommand "delete", Vcli::CLI::Delete
|
79
|
+
|
80
|
+
desc "deploy",
|
81
|
+
"deploy [optional] --vm=<virtualmachine id>
|
82
|
+
[required] --va=<virtualappliance id>
|
83
|
+
[required] --vdc=<vdc id>"
|
84
|
+
method_option :vm, :type => :string
|
85
|
+
method_option :va, :type => :string, :required => true
|
86
|
+
method_option :vdc, :type => :string, :required => true
|
87
|
+
def deploy()
|
88
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
89
|
+
:abiquo_username => Vcli::user,
|
90
|
+
:abiquo_password => Vcli::password)
|
91
|
+
# If --vm parameter passed
|
92
|
+
vdc=options[:vdc].to_s
|
93
|
+
va=options[:va].to_s
|
94
|
+
vm=options[:vm].to_s
|
95
|
+
if vm.length != 0
|
96
|
+
# if Virtual Machine Specified
|
97
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/action/deploy',
|
98
|
+
:type => 'application/vnd.abiquo.acceptedrequest+json')
|
99
|
+
else
|
100
|
+
# If no Virtual Machine specified its a Virtual Appliance
|
101
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/action/deploy')
|
102
|
+
|
103
|
+
end
|
104
|
+
response=abq.post(link,"{}")
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "undeploy",
|
108
|
+
"undeploy [optional] --vm=<virtualmachine id>
|
109
|
+
[required] --va=<virtualappliance id>
|
110
|
+
[required] --vdc=<vdc id>"
|
111
|
+
method_option :vm, :type => :string
|
112
|
+
method_option :va, :type => :string, :required => true
|
113
|
+
method_option :vdc, :type => :string, :required => true
|
114
|
+
method_option :force, :type => :boolean
|
115
|
+
def undeploy()
|
116
|
+
begin
|
117
|
+
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
118
|
+
:abiquo_username => Vcli::user,
|
119
|
+
:abiquo_password => Vcli::password)
|
120
|
+
# If --vm parameter passed
|
121
|
+
vdc=options[:vdc].to_s
|
122
|
+
va=options[:va].to_s
|
123
|
+
vm=options[:vm].to_s
|
124
|
+
force=options[:force]
|
125
|
+
request=Hash.new
|
126
|
+
forcerequest=Hash.new
|
127
|
+
if force
|
128
|
+
forcerequest[:forceUndeploy]=true
|
129
|
+
else
|
130
|
+
forcerequest[:forceUndeploy]=false
|
131
|
+
end
|
132
|
+
|
133
|
+
request[:virtualmachinetask]=forcerequest
|
134
|
+
if vm.length != 0
|
135
|
+
# if Virtual Machine Specified
|
136
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm + '/action/undeploy',
|
137
|
+
:type => 'application/vnd.abiquo.virtualmachinetask+json')
|
138
|
+
else
|
139
|
+
# If no Virtual Machine specified its a Virtual Appliance
|
140
|
+
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/action/undeploy',
|
141
|
+
:type => 'application/vnd.abiquo.virtualmachinetask+json')
|
142
|
+
|
143
|
+
end
|
144
|
+
reqoptions=Hash.new
|
145
|
+
reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
|
146
|
+
response=abq.post(link,request,reqoptions)
|
147
|
+
rescue AbiquoAPIClient::Forbidden
|
148
|
+
puts "Forbidden HTTP 403 Received"
|
149
|
+
rescue AbiquoAPIClient::InvalidCredentials
|
150
|
+
puts "Invalid Credentials - HTTP 401 Received"
|
151
|
+
rescue AbiquoAPIClient::BadRequest => e
|
152
|
+
puts "Bad Request - HTTP 400 or 406 Received"
|
153
|
+
puts e.inspect
|
154
|
+
rescue AbiquoAPIClient::NotFound
|
155
|
+
puts "Not Found - HTTP 400 Received"
|
156
|
+
rescue AbiquoAPIClient::UnsupportedMediaType
|
157
|
+
puts "Unsupported Media Type Specified - HTTP 415 Received"
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
desc "poweron",
|
162
|
+
"poweron [optional] --vm=<virtualmachine id>
|
163
|
+
[required] --va=<virtualappliance id>
|
164
|
+
[required] --vdc=<vdc id>"
|
165
|
+
method_option :virtualmachine, :type => :string, :aliases => "-vm"
|
166
|
+
method_option :virtualappliance, :type => :string, :aliases => "-va", :required => true
|
167
|
+
method_option :vdc, :type => :string, :required => true
|
168
|
+
def poweron()
|
169
|
+
#TODO
|
170
|
+
end
|
171
|
+
|
172
|
+
desc "poweroff",
|
173
|
+
"poweroff [optional] --vm=<virtualmachine id>
|
174
|
+
[required] --va=<virtualappliance id>
|
175
|
+
[required] --vdc=<vdc id>"
|
176
|
+
method_option :virtualmachine, :type => :string, :aliases => "-vm"
|
177
|
+
method_option :virtualappliance, :type => :string, :aliases => "-va", :required => true
|
178
|
+
method_option :vdc, :type => :string, :required => true
|
179
|
+
def poweroff()
|
180
|
+
#TODO
|
181
|
+
end
|
79
182
|
end
|
80
183
|
end
|
data/lib/vcli/cli/create.rb
CHANGED
@@ -89,8 +89,7 @@ module Vcli
|
|
89
89
|
:abiquo_username => Vcli::user,
|
90
90
|
:abiquo_password => Vcli::password)
|
91
91
|
|
92
|
-
|
93
|
-
|
92
|
+
|
94
93
|
# Link to post
|
95
94
|
link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines' ,
|
96
95
|
:type => 'application/vnd.abiquo.virtualmachine+json')
|
data/lib/vcli/cli/show.rb
CHANGED
@@ -99,6 +99,8 @@ module Vcli
|
|
99
99
|
desc "show vlans", "Show all VLANS within your account, Options --vdc limits query to single VDC, --ips shows IP address"
|
100
100
|
method_option :vdc, :type => :string
|
101
101
|
method_option :ips, :type => :boolean
|
102
|
+
method_option :allocated, :type => :boolean, :default => false
|
103
|
+
method_option :free, :type => :boolean, :default => false
|
102
104
|
def vlans( )
|
103
105
|
begin
|
104
106
|
abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
|
@@ -120,7 +122,33 @@ module Vcli
|
|
120
122
|
:type => 'application/vnd.abiquo.privateips+json')
|
121
123
|
listofips=abq.list(link2)
|
122
124
|
listofips.each { |m|
|
123
|
-
|
125
|
+
case options[:free]
|
126
|
+
when true
|
127
|
+
if !m.has_link?(:virtualmachine)
|
128
|
+
virtualmachine="Free"
|
129
|
+
puts " - #{m.id}, #{m.ip}, #{virtualmachine}"
|
130
|
+
end
|
131
|
+
when false
|
132
|
+
case options[:allocated]
|
133
|
+
when true
|
134
|
+
if m.has_link?(:virtualmachine)
|
135
|
+
virtualmachinelink=m.link(:virtualmachine)
|
136
|
+
virtualmachinelink.get
|
137
|
+
virtualmachine=virtualmachinelink.title
|
138
|
+
puts " - #{m.id}, #{m.ip}, #{virtualmachine}"
|
139
|
+
end
|
140
|
+
when false
|
141
|
+
if m.has_link?(:virtualmachine)
|
142
|
+
virtualmachinelink=m.link(:virtualmachine)
|
143
|
+
virtualmachinelink.get
|
144
|
+
virtualmachine=virtualmachinelink.title
|
145
|
+
puts " - #{m.id}, #{m.ip}, #{virtualmachine}"
|
146
|
+
else
|
147
|
+
virtualmachine="Free"
|
148
|
+
puts " - #{m.id}, #{m.ip}, #{virtualmachine}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
end
|
124
152
|
}
|
125
153
|
end
|
126
154
|
|
data/lib/vcli/version.rb
CHANGED
@@ -19,6 +19,10 @@ module Vcli
|
|
19
19
|
# # # nic uses default, need to work out nic
|
20
20
|
# # # allocation.
|
21
21
|
#################################################################
|
22
|
+
# 0.2.5 #31072015# Added deploy and undeploy for virtualappliance
|
23
|
+
# # # and virtualmachines
|
24
|
+
#################################################################
|
25
|
+
|
22
26
|
|
23
|
-
VERSION = "0.2.
|
27
|
+
VERSION = "0.2.5"
|
24
28
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vcli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jay Fearn
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -66,6 +66,20 @@ dependencies:
|
|
66
66
|
- - '='
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: 0.5.5
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: rspec-core
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - '='
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 3.3.0
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - '='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 3.3.0
|
69
83
|
- !ruby/object:Gem::Dependency
|
70
84
|
name: thor
|
71
85
|
requirement: !ruby/object:Gem::Requirement
|