vcli 0.2.6 → 0.2.7

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: 46c3b42fcb446f735257bda7f13025ec65f2b697
4
- data.tar.gz: edea7f33a1cf74778c4587253eb63e58d31056e1
3
+ metadata.gz: f7e81df0bb2f86fe03b09126c0d8eb1b94311cb4
4
+ data.tar.gz: 8855ae08ad7abe06fccfe03ec3b013a201cfaff0
5
5
  SHA512:
6
- metadata.gz: 72973dbf8cccb3b7d9a5760782feaaeaa28ba7fca09d2e3a6eccd77b9676b3d9fed6aba30bd5753f0441d590523fe8a8e762a7166489162e195cac9ea4d25fae
7
- data.tar.gz: f3e513398d4897c1e0fad293133bf5e9469c6df69bdf3f34ac9a91ef617b2e678caadd740891cfed670cd41d6551d758f986eef4319bc2067d3778353042a01d
6
+ metadata.gz: 6fbccfa4493719c91059d197c92b129c85e5daff9ef0680cc07956396aeba0a739037e9c79cfdd9ff79286472fcb3e4e43d0d77f4f9067774975d8a599d4620d
7
+ data.tar.gz: 4420b8b9c08e0c934ead13d07fc6ebbd6b2c83c5dbd0f48af717c2e414cfbca79780cccf21895fad99971e32708be644a0dd94298cfc4b7b2a8908d5c0f4a11b
File without changes
data/bin/setup CHANGED
File without changes
data/bin/vcli CHANGED
File without changes
@@ -1,6 +1,6 @@
1
1
  require 'thor'
2
2
  require 'vcli/cli/show'
3
- require 'vcli/cli/resource'
3
+ require 'vcli/cli/modify'
4
4
  require 'vcli/cli/create'
5
5
  require 'vcli/cli/delete'
6
6
  require 'abiquo-api'
@@ -77,6 +77,9 @@ module Vcli
77
77
  desc "delete COMMANDS", "Delete items within the Abiquo VDC"
78
78
  subcommand "delete", Vcli::CLI::Delete
79
79
 
80
+ desc "modify COMMANDS", "Modify items within the Abiquo VDC"
81
+ subcommand "modify", Vcli::CLI::Modify
82
+
80
83
  desc "deploy",
81
84
  "deploy [optional] --vm=<virtualmachine id>
82
85
  [required] --va=<virtualappliance id>
@@ -149,7 +152,7 @@ module Vcli
149
152
  reqoptions=Hash.new
150
153
  reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
151
154
  print "Powering Off VM."
152
- tries ||= 3
155
+ tries ||= 5
153
156
  begin
154
157
  response=abq.put(link,reqdata,reqoptions)
155
158
  status=response.link(:status).get
@@ -66,28 +66,30 @@ module Vcli
66
66
  end
67
67
 
68
68
  desc "create virtualmachine", "create virtualmachine <name> <template id> <vdc id> <virtualappliance id>"
69
- method_option :cpu, :type => :string, :aliases => "-t"
69
+ method_option :cpu, :type => :string, :aliases => "-c"
70
70
  method_option :ram, :type => :string, :aliases => "-r"
71
71
  method_option :description, :type => :string, :aliases => "-d"
72
72
  method_option :password, :type => :string, :aliases => "-p"
73
- method_option :ip, :type => :string, :aliases => "-i"
74
- method_option :vlan, :type => :string, :aliases => "-v"
73
+ method_option :vlanid, :type => :string, :aliases => "-v"
74
+ method_option :ipid, :type => :string, :aliases => "-i"
75
75
  def virtualmachine(name, template, vdc, va)
76
76
  begin
77
77
  abq = AbiquoAPI.new(:abiquo_api_url => Vcli::target, :abiquo_username => Vcli::user, :abiquo_password => Vcli::password)
78
78
  # Link to post
79
79
  link=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines' ,
80
- :type => 'application/vnd.abiquo.virtualmachine+json')
80
+ :type => 'application/vnd.abiquo.virtualmachine+json',
81
+ :client => abq)
82
+
83
+ # Link to get link for Template
84
+ templatelink=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates/',
85
+ :type => 'application/vnd.abiquo.virtualmachinetemplates+json',
86
+ :client => abq)
87
+
81
88
  # Hash to populate for new virtual machine
82
89
  newvirtualmachine=Hash.new
83
- # Hash to populate for link
84
90
  link2hash=Hash.new
85
91
  linkhash=Hash.new
86
- # Link to get link for Template
87
- link2=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/action/templates/',
88
- :type => 'application/vnd.abiquo.virtualmachinetemplates+json',
89
- :client => abq)
90
- templates=link2.get
92
+ templates=templatelink.get
91
93
  templates.each {|l|
92
94
  if l.id.to_s == template.to_s
93
95
  link2hash[:title]=l.name
@@ -96,17 +98,16 @@ module Vcli
96
98
  link2hash[:href]=l.url
97
99
  end
98
100
  }
99
- newvirtualmachine[:label]=linkhash[:title]
100
101
  newvirtualmachine[:label]=name
101
102
  arrayforlinks=Array.new
102
103
  arrayforlinks[0]=link2hash
103
104
  newvirtualmachine[:links]=arrayforlinks
104
105
  cpu=options[:cpu].to_s
105
106
  ram=options[:ram].to_s
107
+ vlanid=options[:vlanid].to_s
108
+ ipid=options[:ipid].to_s
106
109
  description=options[:description].to_s
107
110
  password=options[:password].to_s
108
- ip=options[:ip].to_s
109
- vlan=options[:vlan].to_s
110
111
  newvirtualmachine[:cpu]= cpu if cpu.length >0
111
112
  newvirtualmachine[:ram]= ram if ram.length >0
112
113
  newvirtualmachine[:description]= description if description.length >0
@@ -117,35 +118,13 @@ module Vcli
117
118
  puts "ID for Virtual Machine - #{response.id}"
118
119
  system("vcli deploy --vdc=#{vdc} --va=#{va} --vm=#{response.id}")
119
120
  sleep 20
120
- puts
121
+ puts "Powering Off VM"
121
122
  system("vcli poweroff --vdc=#{vdc} --va=#{va} --vm=#{response.id}")
123
+ puts "Reconfiguring VM"
124
+ system("vcli modify ip --vdc=#{vdc} --va=#{va} --vmid=#{response.id} --vlanid=#{vlanid} --ipid=#{ipid}")
125
+ puts "Powering On VM"
126
+ system("vcli poweron --vdc=#{vdc} --va=#{va} --vm=#{response.id}")
122
127
  puts
123
-
124
- # Link to get put modified machine
125
- link4=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/virtualappliances/' + va + '/virtualmachines/' + response.id.to_s ,
126
- :type => 'application/vnd.abiquo.virtualmachine+json',
127
- :client => abq)
128
- # Private IPS in VLAN
129
- link5=AbiquoAPI::Link.new(:href => 'api/cloud/virtualdatacenters/' + vdc + '/privatenetworks/' + vlan + '/ips',
130
- :type => 'application/vnd.abiquo.privateips+json',
131
- :client => abq)
132
- listofips=abq.list(link5)
133
- listofips.each { |m|
134
- if m.ip == ip
135
- if !m.has_link?(:virtualmachine)
136
- url=m.url
137
- break
138
- else
139
- puts "IP Address already allocated"
140
- exit 1
141
- end
142
- end
143
- }
144
- reqoptions=Hash.new
145
- reqoptions[:accept] = 'application/vnd.abiquo.acceptedrequest+json'
146
- virtualmachine2=abq.get(link4)
147
- puts virtualmachine2.to_yaml
148
- response=abq.put(link4,virtualmachine2,reqoptions)
149
128
  rescue AbiquoAPIClient::Forbidden
150
129
  puts "Forbidden HTTP 403 Received"
151
130
  rescue AbiquoAPIClient::InvalidCredentials
@@ -23,7 +23,9 @@ module Vcli
23
23
  # # # and virtualmachines
24
24
  #################################################################
25
25
  # 0.2.6 #05082015# Added create virtualmachine
26
+ #################################################################
27
+ # 0.2.7 #11082015# Added modify ip
26
28
  #################################################################
27
29
 
28
- VERSION = "0.2.6"
30
+ VERSION = "0.2.7"
29
31
  end
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vcli
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.6
4
+ version: 0.2.7
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-08-05 00:00:00.000000000 Z
11
+ date: 2015-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ~>
17
+ - - "~>"
18
18
  - !ruby/object:Gem::Version
19
19
  version: '1.10'
20
20
  type: :development
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - ~>
24
+ - - "~>"
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.10'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: rake
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - ~>
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
33
  version: '10.0'
34
34
  type: :development
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - ~>
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '10.0'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: minitest
43
43
  requirement: !ruby/object:Gem::Requirement
44
44
  requirements:
45
- - - ~>
45
+ - - "~>"
46
46
  - !ruby/object:Gem::Version
47
47
  version: '5'
48
48
  type: :development
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
- - - ~>
52
+ - - "~>"
53
53
  - !ruby/object:Gem::Version
54
54
  version: '5'
55
55
  - !ruby/object:Gem::Dependency
@@ -84,28 +84,28 @@ dependencies:
84
84
  name: thor
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - ~>
87
+ - - "~>"
88
88
  - !ruby/object:Gem::Version
89
89
  version: '0'
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - ~>
94
+ - - "~>"
95
95
  - !ruby/object:Gem::Version
96
96
  version: '0'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: httparty
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ~>
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
103
  version: '0'
104
104
  type: :runtime
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ~>
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
110
  version: '0'
111
111
  - !ruby/object:Gem::Dependency
@@ -126,14 +126,14 @@ dependencies:
126
126
  name: abiquo-api
127
127
  requirement: !ruby/object:Gem::Requirement
128
128
  requirements:
129
- - - ~>
129
+ - - "~>"
130
130
  - !ruby/object:Gem::Version
131
131
  version: '0'
132
132
  type: :runtime
133
133
  prerelease: false
134
134
  version_requirements: !ruby/object:Gem::Requirement
135
135
  requirements:
136
- - - ~>
136
+ - - "~>"
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
139
  description: "Command Line Interface for the Abiquo API\nStart with 'vcli target https://put.your.portal.api.fqdn.here/api'\nthen
@@ -153,13 +153,13 @@ files:
153
153
  - bin/console
154
154
  - bin/setup
155
155
  - bin/vcli
156
+ - lib/vcli.rb
157
+ - lib/vcli/cli.rb
156
158
  - lib/vcli/cli/create.rb
157
159
  - lib/vcli/cli/delete.rb
158
160
  - lib/vcli/cli/resource.rb
159
161
  - lib/vcli/cli/show.rb
160
- - lib/vcli/cli.rb
161
162
  - lib/vcli/version.rb
162
- - lib/vcli.rb
163
163
  - test/test_helper.rb
164
164
  - test/vcli_test.rb
165
165
  homepage: http://www.sittingonthe.net
@@ -172,17 +172,17 @@ require_paths:
172
172
  - lib
173
173
  required_ruby_version: !ruby/object:Gem::Requirement
174
174
  requirements:
175
- - - '>='
175
+ - - ">="
176
176
  - !ruby/object:Gem::Version
177
177
  version: '0'
178
178
  required_rubygems_version: !ruby/object:Gem::Requirement
179
179
  requirements:
180
- - - '>='
180
+ - - ">="
181
181
  - !ruby/object:Gem::Version
182
182
  version: '0'
183
183
  requirements: []
184
184
  rubyforge_project:
185
- rubygems_version: 2.0.14
185
+ rubygems_version: 2.4.5
186
186
  signing_key:
187
187
  specification_version: 4
188
188
  summary: Command Line Interface for the Abiquo API