knife-vcair 0.7.0 → 0.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 199066f3714ad9369bf2d91bb8e4ac713a3c79fa
4
- data.tar.gz: 8ad35c187f1daa6d90c52199a2f3a5642377fee8
3
+ metadata.gz: f5fb6ce00fc091f2234646d471b17580de7f7597
4
+ data.tar.gz: f16f1691a223cd4ee3928a2f91b1b1c8e42e2e8c
5
5
  SHA512:
6
- metadata.gz: 634f1a0bfd8af10368833a76caa22daa54c79558fc1669994956252aaf01a73d726c27162f858b99f9c33b4c5b23fd287d350ec0ba707193cd5697af16175e90
7
- data.tar.gz: 4ab56fa22e838aa95f10c009633d12e365756feb8ed7928a72a70771aa68a134d97ed7ef6e8d1ab966f40f9fdddb29fd56aa14ab6e05959159a170bb843164f5
6
+ metadata.gz: d46cd5af03fb0f55e725fb599c155d67d0a1cb678103e979ef1f01a032a9e5a60420823355792622960f302be327d67aa9906325626a826f9d44a19cea43b3b0
7
+ data.tar.gz: f7a032cc18dd22499b2c6727e5957ec451ec3dbd3c72f690e292a1c198410acc11ed6eae8c367c0f2391314fb47e7067fd0db617374cc02da33f92e85cbfa82a
@@ -1,3 +1,9 @@
1
+ ## 0.8.0
2
+ * added better exception handling for looking up vCloud Air networks, including adding ability to specify the network by ID instead of name
3
+
4
+ ## 0.7.0
5
+ * added a vcair_api_path option, necessary for when using vCloud Air OnDemand #28
6
+
1
7
  ## 0.6.1
2
8
  * Fixed network selection for creating servers #23
3
9
  * Update bootstrap scripts #17
data/README.md CHANGED
@@ -152,18 +152,6 @@ List the available vcair templates or images that may be used for deploying VMs.
152
152
 
153
153
  Lists the networks available to the current vcair organization.
154
154
 
155
- ## knife vcair nat list ##
156
-
157
- **TODO** List the Network Address Translation (NAT) rules modifying the source/destination IP Addresses or packets arriving to and leaving from the vcair organization network.
158
-
159
- ## knife vcair firewall list ##
160
-
161
- **TODO** The list of firewall rules configured for the current vcair organization network.
162
-
163
- ## knife vcair ip list ##
164
-
165
- **TODO** The list of public IP Addresses provided and allocated for the current vcair organization network.
166
-
167
155
 
168
156
  # Notes #
169
157
 
@@ -49,10 +49,16 @@ class Chef
49
49
 
50
50
  option :vcair_net,
51
51
  :long => "--vcair-net NETWORKNAME",
52
- :description => "Your VCAIR NETWORK",
52
+ :description => "vCloud Air Network Name",
53
53
  :default => nil,
54
54
  :proc => Proc.new { |key| Chef::Config[:knife][:vcair_net] = key }
55
55
 
56
+ option :vcair_net_id,
57
+ :long => "--vcair-net-id NETWORKNAME",
58
+ :description => "vCloud Air Network ID - take preference over --vcair-net",
59
+ :default => nil,
60
+ :proc => Proc.new { |key| Chef::Config[:knife][:vcair_net_id] = key }
61
+
56
62
  # TODO - Define your cloud specific create server options here. Example.
57
63
  # Vcair Server create params.
58
64
  # option :private_network,
@@ -13,7 +13,7 @@ class Chef
13
13
  def create_service_instance
14
14
  VcairService.new
15
15
  end
16
-
16
+
17
17
  def org
18
18
  @org ||= @service.connection.organizations.get_by_name(
19
19
  config_value(:vcair_org))
@@ -26,14 +26,32 @@ class Chef
26
26
  @vdc ||= org.vdcs.first
27
27
  end
28
28
  end
29
-
29
+
30
30
  def net
31
- if config_value(:vcair_net)
31
+ if config_value(:vcair_net_id)
32
+ Chef::Log.debug("Looking up network by ID: #{config_value(:vcair_net_id)}")
33
+ begin
34
+ @net ||= org.networks.get(config_value(:vcair_net_id))
35
+ rescue => e
36
+ raise "Unable to locate network ID #{config_value(:vcair_net_id)} -- #{e.message}"
37
+ end
38
+ elsif config_value(:vcair_net)
39
+ Chef::Log.debug("Looking up network by name: #{config_value(:vcair_net)}")
32
40
  @net ||= org.networks.get_by_name(config_value(:vcair_net))
33
41
  else
34
42
  # Grab first non-isolated (bridged, natRouted) network
43
+ Chef::Log.debug("No network specified, trying to locate one...")
35
44
  @net ||= org.networks.find { |n| n if !n.fence_mode.match("isolated") }
36
45
  end
46
+
47
+ raise "No network found - available networks: #{available_networks.join(', ')}" if @net.nil?
48
+
49
+ Chef::Log.debug("Using network #{@net.name} (#{@net.id})")
50
+ @net
51
+ end
52
+
53
+ def available_networks
54
+ org.networks.map { |network| "#{network.name} (#{network.id})"}
37
55
  end
38
56
 
39
57
  def template
@@ -43,11 +61,11 @@ class Chef
43
61
  cat.catalog_items.get_by_name(config_value(:image))
44
62
  end.compact.first
45
63
  end
46
-
64
+
47
65
  def vapp
48
66
  @vapp ||= vdc.vapps.get_by_name(config_value(:chef_node_name))
49
67
  end
50
-
68
+
51
69
  def vm
52
70
  @vm ||= vapp.vms.find {|v| v.vapp_name == config_value(:chef_node_name)}
53
71
  end
@@ -57,13 +75,13 @@ class Chef
57
75
  n if n[:networkName].match(net.name)
58
76
  end
59
77
  end
60
-
78
+
61
79
 
62
80
  def config_value(key)
63
81
  key = key.to_sym
64
82
  Chef::Config[:knife][key] || config[key]
65
83
  end
66
-
84
+
67
85
  def get_id(value)
68
86
  value['id']
69
87
  end
@@ -73,7 +91,7 @@ class Chef
73
91
  puts "#{ui.color(label, color)}: #{value}"
74
92
  end
75
93
  end
76
-
94
+
77
95
  def validate!(keys=[:vcair_username, :vcair_password, :vcair_api_host, :vcair_org, :vcair_api_version])
78
96
  errors = []
79
97
  keys.each do |k|
@@ -82,12 +100,12 @@ class Chef
82
100
  errors << "You did not provide a valid '#{pretty_key}' value. Please set knife[:#{k}] in your knife.rb or pass as an option."
83
101
  end
84
102
  end
85
-
103
+
86
104
  if errors.each{|e| ui.error(e)}.any?
87
105
  exit 1
88
106
  end
89
107
  end
90
-
108
+
91
109
  end
92
110
  end
93
111
  end
@@ -1,6 +1,6 @@
1
1
  module Knife
2
2
  module Vcair
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  MAJOR, MINOR, TINY = VERSION.split('.')
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-vcair
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matt Ray
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2015-08-12 00:00:00.000000000 Z
15
+ date: 2015-10-02 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: fog
@@ -250,7 +250,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
250
250
  version: '0'
251
251
  requirements: []
252
252
  rubyforge_project:
253
- rubygems_version: 2.4.4
253
+ rubygems_version: 2.4.8
254
254
  signing_key:
255
255
  specification_version: 4
256
256
  summary: VMware vcair support for Chef's Knife command