vcloud-box-spinner 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.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ 0.2.5 2013-09-16
2
+ - Use multi_json gem rather than json
3
+ - Allow use of fog's credentials file
4
+
1
5
  0.2.4 2013-09-05
2
6
 
3
7
  - Use fog 1.15.0 for Set-Cookie header fix.
data/README.md CHANGED
@@ -18,6 +18,7 @@ You should be able to do `vcloud-box-spinner --help`
18
18
 
19
19
  e.g. vcloud-box-spinner -u username orgs/staging.json machines/frontend-1.json
20
20
 
21
+ -c, --credential=GROUP fog credential group
21
22
  -u, --user=USERNAME vCloud username
22
23
  -p, --password=PASSWORD vCloud password
23
24
  -F, --ssh-config=FILENAME SSH config file(s) to use (can be specified multiple times)
@@ -57,6 +58,11 @@ follows:
57
58
 
58
59
  vcloud-box-spinner -u username -p password org_config.json machine_config.json
59
60
 
61
+ ## Environment Variables
62
+
63
+ - `FOG_RC` specifies the fog credentials file if not `~/.fog`.
64
+ - `FOG_CREDENTIAL` specifies the credential group if not `default`.
65
+
60
66
  ## Hacking
61
67
 
62
68
  refer [here](/docs/hacking.md)
@@ -1,4 +1,4 @@
1
- require 'json'
1
+ require 'multi_json'
2
2
  require 'optparse'
3
3
  require 'provisioner/errors'
4
4
  require 'highline/import'
@@ -76,6 +76,10 @@ module Provisioner
76
76
  o.separator ""
77
77
  o.separator "[Available options]:"
78
78
 
79
+ o.on("-c", "--credential", "=GROUP", "fog credential group") do |v|
80
+ options[:credential] = v
81
+ end
82
+
79
83
  o.on("-u", "--user", "=USERNAME", "vCloud username") do |v|
80
84
  options[:user] = v
81
85
  end
@@ -91,14 +95,14 @@ module Provisioner
91
95
 
92
96
  options[:org_config] = {}
93
97
  o.on("-o", "--org-config", "=ORG-CONFIG-JSON",
94
- "The organisation configuration json file path") do |v|
95
- options[:org_config] = JSON.parse(File.read(v), :symbolize_names => true)
98
+ "The organisation configuration JSON file path") do |v|
99
+ options[:org_config] = MultiJson.load(File.read(v), :symbolize_names => true)
96
100
  end
97
101
 
98
102
  options[:machine_metadata] = {}
99
103
  o.on("-m", "--machine-config", "=METADATA",
100
- "The machine configuration json file path") do |v|
101
- options[:machine_metadata] = JSON.parse(File.read(v), :symbolize_names => true)
104
+ "The machine configuration JSON file path") do |v|
105
+ options[:machine_metadata] = MultiJson.load(File.read(v), :symbolize_names => true)
102
106
  end
103
107
 
104
108
  o.on('-s', '--setup-script', "=SETUP-SCRIPT", "path to setup script that should run after machine is brought up") do |v|
@@ -128,11 +132,7 @@ module Provisioner
128
132
 
129
133
  action = @args[0]
130
134
 
131
- if options[:user].nil? then
132
- options[:user] = ask("vCloud username: ")
133
- end
134
-
135
- if options[:password].nil? then
135
+ if options[:user] && options[:password].nil? then
136
136
  options[:password] = ask("vCloud password: ") { |q| q.echo = false }
137
137
  end
138
138
 
@@ -6,7 +6,6 @@ module Provisioner
6
6
  private :options=, :options
7
7
 
8
8
  def initialize options
9
- options[:provider] = 'vcloud'
10
9
  options[:created_by] = ENV['USER']
11
10
  self.options = options
12
11
  end
@@ -42,17 +41,20 @@ module Provisioner
42
41
  private :delete
43
42
 
44
43
  def compute
45
- @compute ||= Fog::Compute.new(
46
- :provider => options[:provider],
47
- :vcloud_username => "#{options[:user]}@#{options[:organisation]}",
48
- :vcloud_password => options[:password],
49
- :vcloud_host => options[:host],
44
+ opts = {
50
45
  :vcloud_default_vdc => options[:default_vdc],
51
46
  :connection_options => {
52
- :ssl_verify_peer => false,
53
47
  :omit_default_port => true
54
48
  }
55
- )
49
+ }
50
+ if options[:user]
51
+ opts[:vcloud_username] = "#{options[:user]}@#{options[:organisation]}"
52
+ opts[:vcloud_password] = options[:password]
53
+ end
54
+ opts[:vcloud_host] = options[:host] if options[:host]
55
+
56
+ Fog.credential = options[:credential] if options[:credential]
57
+ @compute ||= Fog::Vcloud::Compute.new(opts)
56
58
  end
57
59
  private :compute
58
60
 
@@ -78,7 +80,7 @@ module Provisioner
78
80
  end
79
81
 
80
82
  def validate_options
81
- unless options[:password] && options[:user] && options[:host]
83
+ unless (options[:password] && options[:user] && options[:host]) || options[:credential]
82
84
  logger.error "VCloud credentials missing"
83
85
  raise ConfigurationError, "VCloud credentials must be specified"
84
86
  end
@@ -1,3 +1,3 @@
1
1
  module Provisioner
2
- VERSION = '0.2.4'
2
+ VERSION = '0.2.5'
3
3
  end
@@ -33,4 +33,5 @@ which enables you to be able to configure VMs with static IPs}
33
33
  s.add_runtime_dependency "parallel"
34
34
  s.add_runtime_dependency "highline"
35
35
  s.add_runtime_dependency "nokogiri", "~> 1.5.0"
36
+ s.add_runtime_dependency "multi_json"
36
37
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: vcloud-box-spinner
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.4
5
+ version: 0.2.5
6
6
  platform: ruby
7
7
  authors:
8
8
  - Garima Singh
@@ -10,7 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2013-09-05 00:00:00 Z
13
+ date: 2013-09-16 00:00:00 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rake
@@ -133,6 +133,17 @@ dependencies:
133
133
  type: :runtime
134
134
  prerelease: false
135
135
  version_requirements: *id011
136
+ - !ruby/object:Gem::Dependency
137
+ name: multi_json
138
+ requirement: &id012 !ruby/object:Gem::Requirement
139
+ none: false
140
+ requirements:
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
144
+ type: :runtime
145
+ prerelease: false
146
+ version_requirements: *id012
136
147
  description: |-
137
148
  Create new VM and apply an opinionated set of commands to
138
149
  them, using vcloud API. The vcloud-box-spinner is a thin wrapper around fog,
@@ -189,7 +200,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
189
200
  requirements:
190
201
  - - ">="
191
202
  - !ruby/object:Gem::Version
192
- hash: -3432102660883927218
203
+ hash: 1125532872460758072
193
204
  segments:
194
205
  - 0
195
206
  version: "0"
@@ -198,7 +209,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
209
  requirements:
199
210
  - - ">="
200
211
  - !ruby/object:Gem::Version
201
- hash: -3432102660883927218
212
+ hash: 1125532872460758072
202
213
  segments:
203
214
  - 0
204
215
  version: "0"