maas-client 0.1.23 → 0.1.24

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: 398dd039d11e9b0bfba7107737913aadd6bc61c4
4
- data.tar.gz: 95bd91f51bdd348e029b0d6ca90f078481fbc43a
3
+ metadata.gz: e4909834732e25bcc549c997a8691da4e6a4d70a
4
+ data.tar.gz: df1a42b383a7fb990aa8b04229bb88132c35da80
5
5
  SHA512:
6
- metadata.gz: d204d9c39cd47f680531005595a8db7988b7b039213a822c97e1decd0cde4925e02f383d4e072655df2a910c2987169e185bec7075a5cd0f4f27414ada18df44
7
- data.tar.gz: 58b9789e46264d1957e2a5a69b382269fb8cf614f49e998f34969c9a942def0b532c31d2f1e17c4039d2adb90cb20fadaa4abbf768e373769ba912f7a0a334fd
6
+ metadata.gz: e955f95eda898f7ea634fdc5b843edb6be22da8e961a948853f9dddcc0e3887ac0783051d1c846e66b796dfb8866002585367ba972b65c2f0fc7e637900283b4
7
+ data.tar.gz: a5df8779c9a21ebb259a26dfa70870b8c562a290129a7e199e4b8dccae71f8edea23580c69e7044d1102f000af78d27192d1a2817db304d45ceaac2ad575c48d
@@ -1,16 +1,12 @@
1
1
  require 'thor'
2
2
  require 'maas/client'
3
- require 'maas/client/util'
4
- require 'pry'
5
- require 'yaml'
3
+ require 'maas/client/config'
6
4
 
7
5
  module Maas
8
6
  module Client
9
7
  class CLI < Thor
10
8
  package_name 'maas-client'
11
9
  # DO NOT DUPLICATE EXISTING 'maas' COMMAND.
12
- include Maas::Client::Util
13
-
14
10
  attr_reader :conn
15
11
 
16
12
  def initialize(*args)
@@ -20,30 +16,16 @@ module Maas
20
16
 
21
17
  no_commands do
22
18
  def init_rbmaas
23
- user_rbmaas_home = Dir.home + '/.rbmaas'
24
- maas_config = {}
25
- maas_config[:user_rbmaas_home] = user_rbmaas_home
26
- if not File.directory?(user_rbmaas_home)
27
- puts 'Creating home directory..'
28
- FileUtils.mkdir(user_rbmaas_home)
29
- end
30
-
31
- lib_dir = Gem::Specification.find_by_name("maas-client").gem_dir
32
- maas_config[:lib_dir] = lib_dir
33
- conf_file = user_rbmaas_home + '/rbmaas.yml'
34
- if not File.exists?(conf_file)
35
- src = File.new(lib_dir + '/lib/maas/client/template/rbmaas.yml')
36
- dst = Dir.new(user_rbmaas_home)
37
- puts 'Copying sample rbmaas.yml..'
38
- FileUtils.cp(src, dst)
39
- abort("Please define default configuration for rbmaas at #{conf_file}")
19
+ maas_config = Maas::Client::Config.config
20
+ if File.exists?(maas_config[:conf_file])
21
+ Maas::Client::Config.set_config
22
+ Maas::Client::MaasClient.new(
23
+ maas_config[:maas][:key],
24
+ maas_config[:maas][:url]
25
+ )
26
+ else
27
+ Maas::Client::Config.init_config
40
28
  end
41
-
42
- maas_config.merge!(symbolize_keys(YAML.load_file(conf_file)))
43
- conn = Maas::Client::MaasClient.new(
44
- maas_config[:maas][:key],
45
- maas_config[:maas][:url]
46
- )
47
29
  end
48
30
  end
49
31
 
@@ -59,7 +41,8 @@ module Maas
59
41
  end
60
42
 
61
43
  if domains == []
62
- abort("There is no dnsresource to clear.")
44
+ puts "There is no dnsresource to clear."
45
+ return nil
63
46
  end
64
47
 
65
48
  domains.each do |d|
@@ -73,6 +56,8 @@ module Maas
73
56
 
74
57
  desc 'generate', "Generate custom data."
75
58
  def generate(resource)
59
+ # clear dnsresources before generation
60
+ invoke :clear, ['dns']
76
61
  case resource
77
62
  when 'hosts'
78
63
  records = []
@@ -0,0 +1,39 @@
1
+ require 'maas/client/util'
2
+ require 'yaml'
3
+
4
+ module Maas
5
+ module Client
6
+ module Config
7
+ extend Maas::Client::Util
8
+ class << self
9
+ attr_reader :config
10
+ end
11
+
12
+ @config = {}
13
+
14
+ config[:lib_dir] = Gem::Specification.find_by_name("maas-client").gem_dir
15
+ config[:user_rbmaas_home] = Dir.home + '/.rbmaas'
16
+ config[:conf_file] = config[:user_rbmaas_home] + '/rbmaas.yml'
17
+
18
+ def self.init_config
19
+ if not File.directory?(config[:user_rbmaas_home])
20
+ puts 'Creating home directory..'
21
+ FileUtils.mkdir(config[:user_rbmaas_home])
22
+ end
23
+
24
+ if not File.exists?(config[:conf_file])
25
+ src = File.new(config[:lib_dir] + '/lib/maas/client/template/rbmaas.yml')
26
+ dst = Dir.new(config[:user_rbmaas_home])
27
+ puts 'Copying sample rbmaas.yml..'
28
+ FileUtils.cp(src, dst)
29
+ abort("Please define default configuration for rbmaas at #{config[:conf_file]}")
30
+ end
31
+ end
32
+
33
+ def self.set_config
34
+ config.merge!(symbolize_keys(YAML.load_file(config[:conf_file])))
35
+ end
36
+ end
37
+ end
38
+ end
39
+
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Maas
4
4
  module Client
5
- VERSION = '0.1.23'
5
+ VERSION = '0.1.24'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: maas-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.23
4
+ version: 0.1.24
5
5
  platform: ruby
6
6
  authors:
7
7
  - Don Draper
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-22 00:00:00.000000000 Z
11
+ date: 2017-07-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -173,6 +173,7 @@ files:
173
173
  - bin/rbmaas
174
174
  - lib/maas/client.rb
175
175
  - lib/maas/client/cli.rb
176
+ - lib/maas/client/config.rb
176
177
  - lib/maas/client/template/rbmaas.yml
177
178
  - lib/maas/client/util.rb
178
179
  - lib/maas/client/version.rb
@@ -197,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
197
198
  version: '0'
198
199
  requirements: []
199
200
  rubyforge_project:
200
- rubygems_version: 2.6.12
201
+ rubygems_version: 2.6.11
201
202
  signing_key:
202
203
  specification_version: 4
203
204
  summary: A client library for MAAS