knife-maas 1.1.2.pre → 1.1.3.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d3e9afc91121101a8cbfcb9f52bf25eab60ba1f4
4
- data.tar.gz: d7c5c5705c11cb9be8f088b7d18411f8a7853d24
3
+ metadata.gz: 098cec2c19b768d4af4e30431c2c7c97dbcbd70f
4
+ data.tar.gz: 259d8b7646d570680352bb60cfca067c7634a68d
5
5
  SHA512:
6
- metadata.gz: 134adcc440271ed7337cc9dc9314ccdb289e2a85c2d5b5294a102445db15eb80faa5ef1fabec0eee68d6f93fb2490fd1772ed61d389f361804ee6be09c297a18
7
- data.tar.gz: e4ad0eded0465887acd93429caee39127cf55bba337780695a2061b8d7fbed314d0f56f6b8c04f5c39513726029707eb1dcef78d81d755967e3cdedff7fafe5d
6
+ metadata.gz: 737b60942323354f6a4a47a85d50c9f4b883bd2dd7042ad5c52baebca979f1fcedac6b47ec11b0ca9ff80c9c6f17769d25af49ebe3d8f5cb56379e74aa55485f
7
+ data.tar.gz: 42e5885b0f06d662f37f94446c702a3c20d26cc07733f75c5dc4e6fe11be9d432f0965867359b27d121b0fd937fecbe26b4d6e0a83c708a55769e55e672d576e
@@ -1,7 +1,7 @@
1
1
  class Chef
2
2
  class Knife
3
3
  module Maas
4
- VERSION = "1.1.2.pre"
4
+ VERSION = "1.1.3.pre"
5
5
  end
6
6
  end
7
7
  end
@@ -50,8 +50,19 @@ class Chef
50
50
  Chef::Config[:knife][key] || config[key]
51
51
  end
52
52
 
53
+ def validate!(keys=[:hostname, :system_id])
54
+ errors = []
53
55
 
56
+ keys.each do |k|
57
+ if Chef::Config[:knife][k].nil?
58
+ errors << "You did not provide a valid '#{k}' value."
59
+ end
60
+ end
54
61
 
62
+ if errors.each{|e| ui.error(e)}.any?
63
+ exit 1
64
+ end
65
+ end
55
66
  end
56
67
  end
57
68
  end
@@ -17,7 +17,6 @@ class Chef
17
17
  puts "Acquiring #{hostname} under your account now...."
18
18
  end
19
19
 
20
-
21
20
  end
22
21
  end
23
22
  end
@@ -27,8 +27,6 @@ class Chef
27
27
  :default => []
28
28
 
29
29
  def run
30
- hostname = locate_config_value(:hostname)
31
- system_id = locate_config_value(:system_id)
32
30
 
33
31
  response = access_token.request(:post, "/nodes/?op=acquire")
34
32
  hostname = JSON.parse(response.body)["hostname"]
@@ -13,19 +13,19 @@ class Chef
13
13
  option :hostname,
14
14
  :short => "-h HOSTNAME",
15
15
  :long => "--hostname HOSTNAME",
16
- :description => "The HOSTNAME inside of MaaS"
16
+ :description => "The HOSTNAME inside of MAAS"
17
17
 
18
18
  option :system_id,
19
19
  :short => "-s SYSTEM_ID",
20
20
  :long => "--system-id SYSTEM_ID",
21
- :description => "The System ID inside of MaaS"
21
+ :description => "The System ID inside of MAAS"
22
22
 
23
23
  option :purge,
24
24
  :short => "-P",
25
25
  :long => "--purge",
26
26
  :boolean => true,
27
27
  :default => false,
28
- :description => "Destroy corresponding node and client on the Chef Server, in addition to releasing the MaaS node itself. Assumes node and client have the same name as the server."
28
+ :description => "Destroy corresponding node and client on the Chef Server, in addition to releasing the MAAS node itself. Assumes node and client have the same name as the server."
29
29
 
30
30
  def destroy_item(klass, name, type_name)
31
31
  begin
@@ -38,6 +38,9 @@ class Chef
38
38
  end
39
39
 
40
40
  def run
41
+
42
+ validate!
43
+
41
44
  system_id = locate_config_value(:system_id)
42
45
  hostname = locate_config_value(:hostname)
43
46
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: knife-maas
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.2.pre
4
+ version: 1.1.3.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - JJ Asghar