Class: Stingray::Exec::Cli

Inherits:
Object
  • Object
show all
Defined in:
lib/stingray/exec/cli.rb

Constant Summary collapse

<<-EOB.gsub(/^  /, '')
Usage: stingray-exec [options] <script>

Executes scripts in the context of Stingray Traffic Manager configuration
models, allowing for access to all methods documented in the Control API.  The
<script> argument may be a string expression or a filename (or "-" for stdin),
and if ommitted will cause stingray-exec to drop into a fancy DSL-tastic pry
console.

All of the command-line configuration flags may also be given as
environmental variables, as noted in the help text for each flag.  The
"endpoint" flag/var deserves special attention as the expected value is buried
in the Stingray docs.
e.g.: STINGRAY_ENDPOINT='https://stingray-pool-master.example.com:9090/soap'

See the 'examples' directory in the stingray-exec gem tree for some
(surprise!) examples of how to do stuff.

------- FAIR WARNING: -------
The vast majority of Control API methods have been wrapped in very dumb
generated code.  Read-only methods work fine, but methods that take arguments
invariably require custom implementations -- the kind of thing that's typically
generated from a WSDL, which we can't legally redistribute.  The Control API
makes things even more fun by requiring the use of soapenc arrays and lists of
arrays.  If you want or need to implement such code, the "soap_helper_methods.rb"
file in the stingray-exec source may be of help. YMMV.


EOB

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(argv) ⇒ Cli

Returns a new instance of Cli.



41
42
43
# File 'lib/stingray/exec/cli.rb', line 41

def initialize(argv)
  @argv = argv
end

Instance Attribute Details

#argvObject (readonly)

Returns the value of attribute argv.



39
40
41
# File 'lib/stingray/exec/cli.rb', line 39

def argv
  @argv
end

#filenameObject (readonly)

Returns the value of attribute filename.



39
40
41
# File 'lib/stingray/exec/cli.rb', line 39

def filename
  @filename
end

#scriptObject (readonly)

Returns the value of attribute script.



39
40
41
# File 'lib/stingray/exec/cli.rb', line 39

def script
  @script
end

Class Method Details

.main(argv = ARGV) ⇒ Object



35
36
37
# File 'lib/stingray/exec/cli.rb', line 35

def self.main(argv = ARGV)
  new(argv).run!
end

Instance Method Details

#run!Object



45
46
47
48
49
50
# File 'lib/stingray/exec/cli.rb', line 45

def run!
  parse_options
  prepare_script
  configure
  evaluate_script
end