ocular 0.1.6 → 0.1.7

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: 36bed9da6ba25bfdd86c18ec3de32295c847ed10
4
- data.tar.gz: e8c372858270c7497f080251fd0ff42c0d1183be
3
+ metadata.gz: 33d5f708edcb7dd43619b5222bfa86e5897d84ef
4
+ data.tar.gz: 9dcd6fd9dba29ebebc23c0ea227d12cf73b64da0
5
5
  SHA512:
6
- metadata.gz: b29306534a2ddc5947988858f4b0330468f501fa09374158ad8c1dc86894619e2a626c0242d52759fa4e8ed316e9b0de9b4020aaf1d16012d5bf5d026bd31206
7
- data.tar.gz: 3c4b7a4a81cdc76799616bf5e4e71fb3fd34f51ba4d0399dca67b0bb790dc838fe63494b159d5d15c1659f6d75cde6102142e661a2930d50fb286b788ed91058
6
+ metadata.gz: 3c2c902cde308bab0ce9885c4d64f665b9a10c296f3ac52ebe3fd53c3ef05e924762ad3ee088c9ccdfa1f2c6f896facc3524ebb836c3fb1ae036009236d68b17
7
+ data.tar.gz: a2b3a5f4a76be86332520655793958c81f996513be1fb2cc2a84f26c3a3c235a0e01ac4fd700af3ff3727f0801d88f66ae85184bb6879fc92bc1d944a8c0b8b8
data/bin/ocular CHANGED
@@ -69,7 +69,31 @@ end # class OptparseExample
69
69
 
70
70
  options = OptparseExample.parse(ARGV)
71
71
 
72
- Ocular::Settings.load_from_file(Ocular::Settings.find_settings_file_from_system(options.settings))
72
+ begin
73
+ Ocular::Settings.load_from_file(Ocular::Settings.find_settings_file_from_system(options.settings))
74
+ rescue Errno::ENOENT
75
+ puts "Could not find #{options.settings} in any search path."
76
+ puts "Please create a yaml settings file in either ~/.ocular.yaml or /etc/ocular.yaml"
77
+ puts "Here's an example file:\n"
78
+ puts "
79
+ aws:
80
+ aws_access_key_id: AKI...
81
+ aws_secret_access_key: ....
82
+ ssh:
83
+ keys:
84
+ - /home/user/.ssh/id_dsa
85
+ user: ubuntu
86
+
87
+ inputs:
88
+ http:
89
+ port: 8083
90
+ etcd:
91
+ host: etc
92
+ port: 4001
93
+
94
+ "
95
+ exit -1
96
+ end
73
97
 
74
98
  if options.server
75
99
  if !options.root && !Ocular::Settings.get(:script_root)
@@ -88,7 +112,14 @@ else
88
112
  # Start shell mode
89
113
 
90
114
  if ARGV.length == 0
91
- puts "Missing script file to run, starting ocular interactive shell. use -h to get more info"
115
+ puts "Missing script file to run, starting ocular interactive shell. use \"ocular -h\" to get full options"
116
+ puts ""
117
+ longest_name = $dsl_help.keys.max_by(&:length).length
118
+ $dsl_help.each do |cmd, help|
119
+ spacing = " "*(longest_name.to_i+1-cmd.length)
120
+ puts " #{cmd}#{spacing}#{help}"
121
+ end
122
+ puts ""
92
123
 
93
124
  ARGV.clear
94
125
  require 'irb'
@@ -106,7 +137,7 @@ else
106
137
  IRB.conf[:PROMPT_MODE] = :MY_PROJECT
107
138
 
108
139
  IRB.conf[:RC] = false
109
-
140
+ IRB.conf[:AUTO_INDENT] = true
110
141
  require 'irb/completion'
111
142
  require 'irb/ext/save-history'
112
143
  IRB.conf[:READLINE] = true
@@ -1,5 +1,14 @@
1
+
2
+ $dsl_help = {}
3
+
4
+ def add_help(name, help)
5
+ $dsl_help[name] = help
6
+ end
7
+
8
+
1
9
  require 'ocular/dsl/etcd.rb'
2
10
  require 'ocular/dsl/fog.rb'
3
11
  require 'ocular/dsl/logging.rb'
4
12
  require 'ocular/dsl/ssh.rb'
5
- require 'ocular/dsl/orbit.rb'
13
+ require 'ocular/dsl/orbit.rb'
14
+
@@ -6,11 +6,13 @@ class Ocular
6
6
  module Etcd
7
7
  @@__etcd_instance = nil
8
8
 
9
+ add_help "etcd", "Returns an etcd client instance"
10
+
9
11
  def etcd()
10
12
  if @@__etcd_instance
11
13
  return @@__etcd_instance
12
14
  end
13
-
15
+
14
16
  settings = ::Ocular::Settings::get(:inputs)[:etcd] || {}
15
17
  @@__etcd_instance = ::Etcd.client(
16
18
  host: (settings[:host] || "localhost"),
@@ -6,6 +6,7 @@ class Ocular
6
6
  module Fog
7
7
  @@__aws_instance = nil
8
8
 
9
+ add_help "aws", "Returns Fog::Compute instance"
9
10
  def aws()
10
11
  if @@__aws_instance
11
12
  return @@__aws_instance
@@ -20,6 +21,7 @@ class Ocular
20
21
  return @@__aws_instance
21
22
  end
22
23
 
24
+ add_help "autoscaling", "Returns Fog::AWS::AutoScaling instance"
23
25
  def autoscaling()
24
26
  return ::Fog::AWS::AutoScaling.new({
25
27
  :aws_access_key_id => ::Ocular::Settings::get(:aws)[:aws_access_key_id],
@@ -27,6 +29,8 @@ class Ocular
27
29
  })
28
30
  end
29
31
 
32
+
33
+ add_help "find_servers_in_autoscaling_groups(substring)", "Returns instances in an autoscaling group which name matches substring"
30
34
  def find_servers_in_autoscaling_groups(substring)
31
35
  instances = []
32
36
  for group in autoscaling.groups
@@ -5,11 +5,14 @@ class Ocular
5
5
  module DSL
6
6
  module Orbit
7
7
 
8
+ add_help "orbit", "Returns OrbitFunctions instance for accessing orbit control data"
9
+
8
10
  class OrbitFunctions
9
11
  def initialize(etcd)
10
12
  @etcd = etcd
11
13
  end
12
14
 
15
+ add_help "orbit::get_service_endpoints(service_name)", "Returns an array of ips running service_name"
13
16
  def get_service_endpoints(service_name)
14
17
  orbit_endpoints = []
15
18
  endpoints = @etcd.get("/orbit/services/#{service_name}/endpoints").node.children
@@ -5,6 +5,7 @@ class Ocular
5
5
  module DSL
6
6
  module SSH
7
7
 
8
+ add_help "ssh_to(hostname)", "Returns Rye::Box ready to execute commands on host hostname"
8
9
  def ssh_to(hostname)
9
10
  settings = ::Ocular::Settings::get(:ssh)
10
11
  settings[:password_prompt] = false
@@ -1,6 +1,4 @@
1
1
  require 'ocular/mixin/from_file'
2
- require 'ocular/dsl/fog'
3
- require 'ocular/dsl/ssh'
4
2
  require 'ocular/dsl/logging'
5
3
 
6
4
  class Ocular
@@ -1,3 +1,3 @@
1
1
  class Ocular
2
- Version = "0.1.6"
2
+ Version = "0.1.7"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ocular
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.6
4
+ version: 0.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Juho Mäkinen