danarchy_sys 0.2.14 → 0.2.15

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: 2eb2359dc35e6ad315efe1e66f82c7e9341c1b72
4
- data.tar.gz: 0876ad89c05d969f6768b173fe1245f22cdeaf15
3
+ metadata.gz: a6941e444194b1fb07c1dedb70c8aeb3ff636dd9
4
+ data.tar.gz: 0219493fc680ca3be83fbb3ddfc143e71e6f50d8
5
5
  SHA512:
6
- metadata.gz: 2b7c28329ad67c2c1553b7d20a22eb581bdf7437675352402605abe6225b714998ca8307da3a4a9add757324abd84484eaf4cd284ff494890c045a550a2d077f
7
- data.tar.gz: f2a4c861f6157f9837d4b01a154100bc77e98101fef32bb0af51941005f22742735b7905a7f34539bcefbfb4493ce6f007de312e243ee070e5cef0c84f7132a4
6
+ metadata.gz: 734046026bdc11d9ba8ce27b9aa7972675c4b2a2b134ecf5cb45d0220049a05e83ede80b6be5e9a264620270d11433b1a0cc5b00417de6d14be2ce794c7ba532
7
+ data.tar.gz: 45a347fa21e336206b66f589a923a16b50e9bb8c12c9b9a8119b23a3543be0a159fb838905edb77f505e2185719f773b4e6a5d89ce59f74e895b642ae7ecd53e
@@ -6,7 +6,7 @@ class Providers
6
6
  provider = 'nil'
7
7
 
8
8
  if providers.count == 1
9
- provider = providers['1']
9
+ provider = providers[1]
10
10
  return provider
11
11
  end
12
12
 
@@ -1,3 +1,4 @@
1
+ require 'fileutils'
1
2
  require 'yaml'
2
3
  require_relative 'config_manager/openstack'
3
4
 
@@ -6,14 +7,14 @@ module DanarchySys
6
7
  module ConfigManager
7
8
  class Config
8
9
  def self.new
9
- @danarchysys_path = File.realpath(File.join(File.dirname(__FILE__), '..', '..'))
10
- @config_file = File.join(@danarchysys_path, 'config', 'danarchysys.yml')
10
+ danarchysys_cfg_path = File.join(File.realpath(ENV['HOME']), '.danarchy_sys')
11
+ config_yml = File.join(danarchysys_cfg_path, 'danarchysys.yml')
11
12
 
12
- if File.exists?(@config_file)
13
- return YAML.load_file(@config_file)
13
+ if File.exists?(config_yml)
14
+ return YAML.load_file(config_yml)
14
15
  else
15
16
  puts 'No existing configuration found!'
16
- return new_config
17
+ return new_config(danarchysys_cfg_path, config_yml)
17
18
  end
18
19
  end
19
20
 
@@ -24,15 +25,33 @@ module DanarchySys
24
25
  def self.config_template
25
26
  config_template = {
26
27
  global_settings: {
27
- ssh_key_path: "#{@danarchysys_path}/config/ssh"
28
+ ssh_key_path: nil
28
29
  },
29
30
  connections: {}
30
31
  }
31
32
  end
32
33
 
33
- def self.new_config
34
+ def self.new_config(danarchysys_cfg_path, config_yml)
34
35
  config = config_template
35
-
36
+ ssh_path = File.join(danarchysys_cfg_path, 'ssh')
37
+
38
+ puts "dAnarchy_sys config location: #{danarchysys_cfg_path}"
39
+ FileUtils.mkdir_p(danarchysys_cfg_path, mode: 0700) unless Dir.exist?(danarchysys_cfg_path)
40
+
41
+ print "Default ssh key location: #{ssh_path}. Is this location okay?: (Y/N) "
42
+ answer = gets.chomp
43
+
44
+ until answer =~ /^y(es)?$/i
45
+ print 'Enter a path for SSH keys: '
46
+ ssh_path = gets.chomp
47
+ print "Setting SSH key path to: #{ssh_path}. Is this location okay? (Y/N): "
48
+ answer = gets.chomp
49
+ end
50
+
51
+ puts "SSH key path set to: #{ssh_path}"
52
+ FileUtils.mkdir_p(ssh_path, mode: 0700) unless Dir.exist?(ssh_path)
53
+ global_setting_add(config, 'ssh_key_path', ssh_path)
54
+
36
55
  provider = nil
37
56
  if providers.count > 1
38
57
  num_providers = Helpers.array_to_numhash(providers)
@@ -75,23 +94,22 @@ module DanarchySys
75
94
  puts 'AWS not yet implemented!'
76
95
  end
77
96
 
78
- save(config)
79
- puts 'Configuration has been saved!'
97
+ save(config_yml, config)
98
+ puts "Configuration has been saved to #{config_yml}"
99
+ puts "Copy any existing #{provider} SSH keys to: #{ssh_path}"
80
100
  config
81
101
  end
82
102
 
83
- def self.save(param_hash)
84
- File.write(@config_file, param_hash.to_yaml)
103
+ def self.save(config_file, param_hash)
104
+ File.write(config_file, param_hash.to_yaml)
85
105
  end
86
106
 
87
107
 
88
- def self.global_setting_add(name, value)
89
- config = load
108
+ def self.global_setting_add(config, name, value)
90
109
  config[:global_settings][name.to_sym] = value
91
110
  end
92
111
 
93
- def self.global_setting_delete(name)
94
- config = load
112
+ def self.global_setting_delete(config, name)
95
113
  config[:global_settings].delete(name.to_sym)
96
114
  end
97
115
  end
@@ -1,3 +1,3 @@
1
1
  module DanarchySys
2
- VERSION = "0.2.14"
2
+ VERSION = "0.2.15"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: danarchy_sys
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dan James
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-07-16 00:00:00.000000000 Z
11
+ date: 2017-07-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: fog-openstack
@@ -91,7 +91,6 @@ files:
91
91
  - Rakefile
92
92
  - bin/console
93
93
  - bin/danarchy_sys
94
- - config/.gitignore
95
94
  - danarchy_sys.gemspec
96
95
  - lib/danarchy_sys.rb
97
96
  - lib/danarchy_sys/aws.rb
data/config/.gitignore DELETED
@@ -1,4 +0,0 @@
1
- # Ignore everything in this directory
2
- *
3
- # Except this file
4
- !.gitignore