vcli 0.2.3 → 0.2.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cbd2409333acc1256d46fe566bbba8fb2e89a2b
4
- data.tar.gz: 112f726bd85e0a4a07723ff46699cc8f29d2be2e
3
+ metadata.gz: 2ca49ce6cb3ce084f921e40b31fdbffa3ce0280d
4
+ data.tar.gz: ee9be5e5df59c172c3dde26e7ab68498d35d65ca
5
5
  SHA512:
6
- metadata.gz: 79a90c1e568f16406682ff9f96cfe49c2d09d07f8659a05460f8ed25d62163613c70c827637d42458a0144bdeb0519372e2918f81ca71072f06a2d234d5b01f5
7
- data.tar.gz: d0370750b670712e3d091ac864a6e00a5b6ab6ef5a44b8b05a9c9732b074a0d9412c03a3f4f2e05f626c3bc366048d45570a635774447ba9024c60aff50413e2
6
+ metadata.gz: 92acb347d9f3414130323438211c68bf76f92244c6dbdbb839d81feda4d44f90af2d9772739b428c2e1159e3540c41e14f541071cbf49cec69dc5836910f281c
7
+ data.tar.gz: 05784f604a14cd9a9bd140e31be5aac8ab96641686c4155dcd1c4d4df2b56a236ebd1039238827444405a6f966405441ae0df9404dfbcdb45a1ea7bfd957a302
@@ -33,13 +33,13 @@ module Vcli
33
33
  rescue AbiquoAPIClient::BadRequest
34
34
  puts "Bad Request - HTTP 400 or 406 Received"
35
35
  rescue AbiquoAPIClient::NotFound
36
- puts "Note Found - HTTP 400 Received"
36
+ puts "Not Found - HTTP 400 Received"
37
37
  rescue AbiquoAPIClient::UnsupportedMediaType
38
38
  puts "Unsupported Media Type Specified - HTTP 415 Received"
39
39
  end
40
40
  end
41
41
 
42
- desc "create vlan", "Create VLAN <name> <address> <mask> <gateway> <vdc id>"
42
+ desc "create vlan", "create vlan <name> <address> <mask> <gateway> <vdc id>"
43
43
  def vlan(name, address, mask, gateway, vdc)
44
44
  begin
45
45
  abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
@@ -68,6 +68,90 @@ module Vcli
68
68
  puts "Error - "+ e.message
69
69
  end
70
70
  end
71
+
72
+ desc "create virtualmachine", "create virtualmachine <name> <template id> <vdc id> <virtualappliance id>"
73
+ method_option :cpu,
74
+ :type => :string,
75
+ :aliases => "-t"
76
+ method_option :ram,
77
+ :type => :string,
78
+ :aliases => "-r"
79
+ method_option :description,
80
+ :type => :string,
81
+ :aliases => "-d"
82
+ method_option :password,
83
+ :type => :string,
84
+ :aliases => "-p"
85
+ def virtualmachine(name, template, vdc, va)
86
+ begin
87
+
88
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
89
+ :abiquo_username => Vcli::user,
90
+ :abiquo_password => Vcli::password)
91
+
92
+ # Get template link
93
+
94
+ # Link to post
95
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines' ,
96
+ :type => 'application/vnd.abiquo.virtualmachine+json')
97
+ # Hash to populate for new virtual machine
98
+ newvirtualmachine=Hash.new
99
+ # Hash to populate for link
100
+ link2hash=Hash.new
101
+ linkhash=Hash.new
102
+ # Link to get link for Template
103
+ link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates/',
104
+ :type => 'application/vnd.abiquo.virtualmachinetemplates+json',
105
+ :client => abq)
106
+ templates=link2.get
107
+ templates.each {|l|
108
+ if l.id.to_s == template.to_s
109
+ link2hash[:title]=l.name
110
+ link2hash[:rel]= "virtualmachinetemplate"
111
+ link2hash[:type]="application/vnd.abiquo.virtualmachinetemplate+json"
112
+ link2hash[:href]=l.url
113
+ end
114
+ }
115
+ newvirtualmachine[:label]=linkhash[:title]
116
+ newvirtualmachine[:label]=name
117
+ #link2hash["0"]=linkhash
118
+ arrayforlinks=Array.new
119
+ arrayforlinks[0]=link2hash
120
+ newvirtualmachine[:links]=arrayforlinks
121
+ cpu=options[:cpu].to_s
122
+ if cpu.length >0
123
+ newvirtualmachine[:cpu]= cpu
124
+ end
125
+ ram=options[:ram].to_s
126
+ if ram.length >0
127
+ newvirtualmachine[:ram]= ram
128
+ end
129
+ description=options[:description].to_s
130
+ if description.length >0
131
+ newvirtualmachine[:description]= description
132
+ end
133
+ password=options[:password].to_s
134
+ if password.length >0
135
+ newvirtualmachine[:password]=password
136
+ end
137
+ newvirtualmachine[:vdrpEnabled]=true
138
+ response=abq.post(link,newvirtualmachine)
139
+ puts "ID for Virtual Machine - #{response.id}"
140
+ rescue AbiquoAPIClient::Forbidden
141
+ puts "Forbidden HTTP 403 Received"
142
+ rescue AbiquoAPIClient::InvalidCredentials
143
+ puts "Invalid Credentials - HTTP 401 Received"
144
+ rescue AbiquoAPIClient::BadRequest
145
+ puts "Bad Request - HTTP 400 or 406 Received"
146
+ rescue AbiquoAPIClient::NotFound
147
+ puts "Not Found - HTTP 400 Received"
148
+ rescue AbiquoAPIClient::UnsupportedMediaType
149
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
150
+ rescue AbiquoAPIClient::Error => e
151
+ puts "Error - "+ e.message
152
+ end
153
+ end
154
+
71
155
  end
72
156
  end
73
- end
157
+ end
@@ -31,7 +31,7 @@ module Vcli
31
31
  rescue AbiquoAPIClient::BadRequest
32
32
  puts "Bad Request - HTTP 400 or 406 Received"
33
33
  rescue AbiquoAPIClient::NotFound
34
- puts "Note Found - HTTP 400 Received"
34
+ puts "Not Found - HTTP 400 Received"
35
35
  rescue AbiquoAPIClient::UnsupportedMediaType
36
36
  puts "Unsupported Media Type Specified - HTTP 415 Received"
37
37
  end
@@ -61,6 +61,29 @@ module Vcli
61
61
  puts "Error - "+ e.message
62
62
  end
63
63
  end
64
+
65
+ desc "delete virtualmachine", "delete virtualmachine <virtualmachine id> <virtualappliance id> <vdc id>"
66
+ def virtualmachine(vm, va, vdc)
67
+ begin
68
+ abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target,
69
+ :abiquo_username => Vcli::user,
70
+ :abiquo_password => Vcli::password)
71
+ link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + vm,
72
+ :type => 'application/vnd.abiquo.virtualmachine+json')
73
+ response=abq.delete(link)
74
+ puts "VM Deleted"
75
+ rescue AbiquoAPIClient::Forbidden
76
+ puts "Forbidden HTTP 403 Received"
77
+ rescue AbiquoAPIClient::InvalidCredentials
78
+ puts "Invalid Credentials - HTTP 401 Received"
79
+ rescue AbiquoAPIClient::BadRequest
80
+ puts "Bad Request - HTTP 400 or 406 Received"
81
+ rescue AbiquoAPIClient::NotFound
82
+ puts "Not Found - HTTP 400 Received"
83
+ rescue AbiquoAPIClient::UnsupportedMediaType
84
+ puts "Unsupported Media Type Specified - HTTP 415 Received"
85
+ end
86
+ end
64
87
  end
65
88
  end
66
- end
89
+ end
data/lib/vcli/cli/show.rb CHANGED
@@ -40,7 +40,7 @@ module Vcli
40
40
  rescue AbiquoAPIClient::BadRequest
41
41
  puts "Bad Request - HTTP 400 or 406 Received"
42
42
  rescue AbiquoAPIClient::NotFound
43
- puts "Note Found - HTTP 400 Received"
43
+ puts "Not Found - HTTP 400 Received"
44
44
  rescue AbiquoAPIClient::UnsupportedMediaType
45
45
  puts "Unsupported Media Type Specified - HTTP 415 Received"
46
46
  end
@@ -89,7 +89,7 @@ module Vcli
89
89
  rescue AbiquoAPIClient::BadRequest
90
90
  puts "Bad Request - HTTP 400 or 406 Received"
91
91
  rescue AbiquoAPIClient::NotFound
92
- puts "Note Found - HTTP 400 Received"
92
+ puts "Not Found - HTTP 400 Received"
93
93
  rescue AbiquoAPIClient::UnsupportedMediaType
94
94
  puts "Unsupported Media Type Specified - HTTP 415 Received"
95
95
  end
@@ -148,7 +148,7 @@ module Vcli
148
148
  rescue AbiquoAPIClient::BadRequest
149
149
  puts "Bad Request - HTTP 400 or 406 Received"
150
150
  rescue AbiquoAPIClient::NotFound
151
- puts "Note Found - HTTP 400 Received"
151
+ puts "Not Found - HTTP 400 Received"
152
152
  rescue AbiquoAPIClient::UnsupportedMediaType
153
153
  puts "Unsupported Media Type Specified - HTTP 415 Received"
154
154
  end
@@ -177,7 +177,7 @@ module Vcli
177
177
  rescue AbiquoAPIClient::BadRequest
178
178
  puts "Bad Request - HTTP 400 or 406 Received"
179
179
  rescue AbiquoAPIClient::NotFound
180
- puts "Note Found - HTTP 400 Received"
180
+ puts "Not Found - HTTP 400 Received"
181
181
  rescue AbiquoAPIClient::UnsupportedMediaType
182
182
  puts "Unsupported Media Type Specified - HTTP 415 Received"
183
183
  end
@@ -228,7 +228,7 @@ module Vcli
228
228
  rescue AbiquoAPIClient::BadRequest
229
229
  puts "Bad Request - HTTP 400 or 406 Received"
230
230
  rescue AbiquoAPIClient::NotFound
231
- puts "Note Found - HTTP 400 Received"
231
+ puts "Not Found - HTTP 400 Received"
232
232
  rescue AbiquoAPIClient::UnsupportedMediaType
233
233
  puts "Unsupported Media Type Specified - HTTP 415 Received"
234
234
  end
@@ -298,7 +298,7 @@ module Vcli
298
298
  rescue AbiquoAPIClient::BadRequest
299
299
  puts "Bad Request - HTTP 400 or 406 Received"
300
300
  rescue AbiquoAPIClient::NotFound
301
- puts "Note Found - HTTP 400 Received"
301
+ puts "Not Found - HTTP 400 Received"
302
302
  rescue AbiquoAPIClient::UnsupportedMediaType
303
303
  puts "Unsupported Media Type Specified - HTTP 415 Received"
304
304
  end
@@ -386,7 +386,7 @@ module Vcli
386
386
  rescue AbiquoAPIClient::BadRequest
387
387
  puts "Bad Request - HTTP 400 or 406 Received"
388
388
  rescue AbiquoAPIClient::NotFound
389
- puts "Note Found - HTTP 400 Received"
389
+ puts "Not Found - HTTP 400 Received"
390
390
  rescue AbiquoAPIClient::UnsupportedMediaType
391
391
  puts "Unsupported Media Type Specified - HTTP 415 Received"
392
392
  end
data/lib/vcli/version.rb CHANGED
@@ -14,7 +14,11 @@ module Vcli
14
14
  # 0.2.2 #28072015# Added VLAN functionality
15
15
  #################################################################
16
16
  # 0.2.3 #28072015# Added more help in the thor packages
17
+ #################################################################
18
+ # 0.2.4 #30072015# Added virtualmachine functionality
19
+ # # # nic uses default, need to work out nic
20
+ # # # allocation.
17
21
  #################################################################
18
22
 
19
- VERSION = "0.2.3"
23
+ VERSION = "0.2.4"
20
24
  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.3
4
+ version: 0.2.4
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-28 00:00:00.000000000 Z
11
+ date: 2015-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler