Sha256: 850b5f4fa8df9027dce4fb5a19cd59d12ff3fac885591766d4475cd0ab0c1491

Contents?: true

Size: 1.41 KB

Versions: 13

Compression:

Stored size: 1.41 KB

Contents

class NetworkOffer < CloudstackCli::Base

  desc 'list', 'list network offerings'
  option :guest_ip_type, enum: %w(isolated shared),
    desc: "list network offerings by guest type."
  option :format, default: "table",
    enum: %w(table json yaml)
  def list
    offerings = client.list_network_offerings(options)
    if offerings.size < 1
      puts "No offerings found."
    else
      case options[:format].to_sym
      when :yaml
        puts({network_offers: offerings}.to_yaml)
      when :json
        puts JSON.pretty_generate(network_offers: offerings)
      else
        table = [%w(Name Display_Text Default? Guest_IP_Type State)]
        offerings.each do |offer|
          table << [
            offer['name'],
            offer['displaytext'],
            offer['isdefault'],
            offer['guestiptype'],
            offer['state'],
          ]
        end
        print_table table
      end
    end
  end

  desc "show NAME", "show detailed infos about a network offering"
  def show(name)
    unless offer = client.list_network_offerings(name: name).first
      say "Error: No network offering with name '#{name}' found.", :red
    else
      table = offer.map do |key, value|
        if key == "service"
          [ set_color("services", :yellow),  value.map{|s| s["name"]}.join(", ") ]
        else
          [ set_color("#{key}", :yellow), "#{value}" ]
        end
      end
      print_table table
    end
  end

end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
cloudstack-cli-1.6.10 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.9 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.8 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.7 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.6 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.5 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.4 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.3 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.2 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.1 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.6.0 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.5.13 lib/cloudstack-cli/commands/network_offer.rb
cloudstack-cli-1.5.12 lib/cloudstack-cli/commands/network_offer.rb