Class: Mu

Inherits:
Object
  • Object
show all
Extended by:
Helper
Defined in:
lib/mu.rb,
lib/mu/client.rb,
lib/mu/helper.rb,
lib/mu/api/ddt.rb,
lib/mu/command.rb,
lib/mu/api/muapi.rb,
lib/mu/api/scale.rb,
lib/mu/api/system.rb,
lib/mu/curl/error.rb,
lib/mu/command/api.rb,
lib/mu/curl/verify.rb,
lib/mu/http_helper.rb,
lib/mu/api/homepage.rb,
lib/mu/command/curl.rb,
lib/mu/command/help.rb,
lib/mu/api/netconfig.rb,
lib/mu/command/cmd_ddt.rb,
lib/mu/command/cmd_musl.rb,
lib/mu/command/cmd_muapi.rb,
lib/mu/command/cmd_scale.rb,
lib/mu/command/cmd_system.rb,
lib/mu/command/cmd_homepage.rb,
lib/mu/command/cmd_runscale.rb,
lib/mu/command/cmd_netconfig.rb,
lib/mu/command/cmd_runverify.rb,
lib/mu/command/cmd_runanalysis.rb,
lib/mu/command/cmd_runscenario.rb

Overview

Command-line tools and applications for using the Mu Dynamics REST Api’s

Defined Under Namespace

Modules: Curl, Helper Classes: Client, Command, Ddt, Homepage, HttpHelper, Muapi, Netconfig, Scale, System

Constant Summary collapse

Version =
@version.freeze

Constants included from Helper

Helper::ESCAPES

Class Method Summary collapse

Methods included from Helper

ask, bin2hex, error, escape, format_float, get_file_as_string_array, make_xml, msg, shift, to_boolean

Class Method Details

.check_versionObject



45
46
47
48
49
50
51
52
53
54
55
56
57
58
# File 'lib/mu.rb', line 45

def self.check_version
  begin
    api = Mu::System.new(ENV['MU_IP'], ENV['MU_ADMIN_USER'], ENV['MU_ADMIN_PASS'])
    resp = Nokogiri::XML(api.status)
    version_string = resp.xpath("//versions/platform")[0].content
    version = version_string[0...version_string.rindex(".")]
    if @version > version
      puts "Note. Version mismatch. Mu Gem version (#{@version}) is higher than Mu Platform version (#{version})."
    end
  rescue => e
    puts "#{e}. Check Mu env settings: $MU_IP (#{ENV['MU_IP']}), $MU_ADMIN_USER (#{ENV['MU_ADMIN_USER']}), $MU_ADMIN_PASS (#{ENV['MU_ADMIN_PASS']}) "
  end

end

.run(cmd, argv) ⇒ Object



21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# File 'lib/mu.rb', line 21

def self.run cmd, argv
    $log.datetime_format = "%Y-%m-%d %H:%M:%S"
    $log.formatter = proc { |severity, datetime, progname, msg|
     "[#{datetime} #{severity}]: #{msg}\n"
     }

    #check_version

    kname, mname = cmd.split(':', 2)
    klass = Mu::Command.const_get kname.capitalize rescue nil
    mname ||= 'default'
    mname = "cmd_#{mname}".to_sym
    if klass and klass < Mu::Command and klass.method_defined? mname
        command = klass.new
        begin
            command.send mname, argv
        rescue => e
            error e.message.chomp('.')
        end
    else
        error "Unknown command #{cmd}"
    end        
end