Sha256: 970d2bf43439e7700170a9a1859d1152be33e7a6997880c181b8934f9445758a
Contents?: true
Size: 1014 Bytes
Versions: 2
Compression:
Stored size: 1014 Bytes
Contents
require "thor" require "yaml" module CloudstackCli class Base < Thor include Thor::Actions attr_reader :config # catch control-c and exit trap("SIGINT") { puts " bye" exit! } # exit with return code 1 in case of a error def self.exit_on_failure? true end no_commands do def client @config ||= CloudstackClient::ConnectionHelper.load_configuration(options[:config]) @client ||= CloudstackClient::Connection.new( @config[:url], @config[:api_key], @config[:secret_key] ) end def find_project(project_name = options[:project]) return nil unless project_name unless project = client.get_project(project_name) say "Project '#{options[:project]}' not found", :red exit 1 end project end def filter_by(objects, tag_name, tag) objects.select {|r| r[tag_name].downcase == tag.downcase } end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
cloudstack-cli-0.2.1 | lib/cloudstack-cli/base.rb |
cloudstack-cli-0.2.0 | lib/cloudstack-cli/base.rb |