Class: HP::Cloud::CLI
- Defined in:
- lib/hpcloud/cli.rb,
lib/hpcloud/commands/lb.rb,
lib/hpcloud/commands/acl.rb,
lib/hpcloud/commands/dns.rb,
lib/hpcloud/commands/get.rb,
lib/hpcloud/commands/copy.rb,
lib/hpcloud/commands/info.rb,
lib/hpcloud/commands/list.rb,
lib/hpcloud/commands/move.rb,
lib/hpcloud/commands/ports.rb,
lib/hpcloud/commands/config.rb,
lib/hpcloud/commands/images.rb,
lib/hpcloud/commands/lb/add.rb,
lib/hpcloud/commands/remove.rb,
lib/hpcloud/commands/account.rb,
lib/hpcloud/commands/dns/add.rb,
lib/hpcloud/commands/flavors.rb,
lib/hpcloud/commands/migrate.rb,
lib/hpcloud/commands/routers.rb,
lib/hpcloud/commands/servers.rb,
lib/hpcloud/commands/subnets.rb,
lib/hpcloud/commands/tempurl.rb,
lib/hpcloud/commands/volumes.rb,
lib/hpcloud/commands/complete.rb,
lib/hpcloud/commands/keypairs.rb,
lib/hpcloud/commands/lb/nodes.rb,
lib/hpcloud/commands/location.rb,
lib/hpcloud/commands/metadata.rb,
lib/hpcloud/commands/networks.rb,
lib/hpcloud/commands/acl/grant.rb,
lib/hpcloud/commands/addresses.rb,
lib/hpcloud/commands/lb/limits.rb,
lib/hpcloud/commands/lb/remove.rb,
lib/hpcloud/commands/lb/update.rb,
lib/hpcloud/commands/ports/add.rb,
lib/hpcloud/commands/snapshots.rb,
lib/hpcloud/commands/acl/revoke.rb,
lib/hpcloud/commands/config/set.rb,
lib/hpcloud/commands/dns/remove.rb,
lib/hpcloud/commands/dns/update.rb,
lib/hpcloud/commands/images/add.rb,
lib/hpcloud/commands/account/use.rb,
lib/hpcloud/commands/dns/records.rb,
lib/hpcloud/commands/dns/servers.rb,
lib/hpcloud/commands/lb/versions.rb,
lib/hpcloud/commands/routers/add.rb,
lib/hpcloud/commands/servers/add.rb,
lib/hpcloud/commands/servers/ssh.rb,
lib/hpcloud/commands/subnets/add.rb,
lib/hpcloud/commands/volumes/add.rb,
lib/hpcloud/commands/account/copy.rb,
lib/hpcloud/commands/account/edit.rb,
lib/hpcloud/commands/keypairs/add.rb,
lib/hpcloud/commands/lb/nodes/add.rb,
lib/hpcloud/commands/lb/protocols.rb,
lib/hpcloud/commands/metadata/set.rb,
lib/hpcloud/commands/networks/add.rb,
lib/hpcloud/commands/ports/remove.rb,
lib/hpcloud/commands/ports/update.rb,
lib/hpcloud/commands/account/setup.rb,
lib/hpcloud/commands/addresses/add.rb,
lib/hpcloud/commands/images/remove.rb,
lib/hpcloud/commands/lb/algorithms.rb,
lib/hpcloud/commands/lb/virtualips.rb,
lib/hpcloud/commands/snapshots/add.rb,
lib/hpcloud/commands/account/remove.rb,
lib/hpcloud/commands/account/verify.rb,
lib/hpcloud/commands/cdn_containers.rb,
lib/hpcloud/commands/containers/add.rb,
lib/hpcloud/commands/routers/remove.rb,
lib/hpcloud/commands/routers/update.rb,
lib/hpcloud/commands/securitygroups.rb,
lib/hpcloud/commands/servers/limits.rb,
lib/hpcloud/commands/servers/reboot.rb,
lib/hpcloud/commands/servers/remove.rb,
lib/hpcloud/commands/subnets/remove.rb,
lib/hpcloud/commands/subnets/update.rb,
lib/hpcloud/commands/volumes/attach.rb,
lib/hpcloud/commands/volumes/detach.rb,
lib/hpcloud/commands/volumes/remove.rb,
lib/hpcloud/commands/volumes/server.rb,
lib/hpcloud/commands/account/catalog.rb,
lib/hpcloud/commands/account/tenants.rb,
lib/hpcloud/commands/containers/sync.rb,
lib/hpcloud/commands/dns/records/add.rb,
lib/hpcloud/commands/images/metadata.rb,
lib/hpcloud/commands/keypairs/import.rb,
lib/hpcloud/commands/keypairs/remove.rb,
lib/hpcloud/commands/lb/nodes/remove.rb,
lib/hpcloud/commands/lb/nodes/update.rb,
lib/hpcloud/commands/networks/remove.rb,
lib/hpcloud/commands/networks/update.rb,
lib/hpcloud/commands/servers/console.rb,
lib/hpcloud/commands/servers/rebuild.rb,
lib/hpcloud/commands/addresses/remove.rb,
lib/hpcloud/commands/keypairs/private.rb,
lib/hpcloud/commands/servers/metadata.rb,
lib/hpcloud/commands/servers/password.rb,
lib/hpcloud/commands/snapshots/remove.rb,
lib/hpcloud/commands/volumes/metadata.rb,
lib/hpcloud/commands/containers/remove.rb,
lib/hpcloud/commands/cdn_containers/add.rb,
lib/hpcloud/commands/cdn_containers/get.rb,
lib/hpcloud/commands/cdn_containers/set.rb,
lib/hpcloud/commands/dns/records/remove.rb,
lib/hpcloud/commands/dns/records/update.rb,
lib/hpcloud/commands/securitygroups/add.rb,
lib/hpcloud/commands/servers/ratelimits.rb,
lib/hpcloud/commands/addresses/associate.rb,
lib/hpcloud/commands/images/metadata/add.rb,
lib/hpcloud/commands/keypairs/public_key.rb,
lib/hpcloud/commands/keypairs/private/add.rb,
lib/hpcloud/commands/securitygroups/rules.rb,
lib/hpcloud/commands/servers/metadata/add.rb,
lib/hpcloud/commands/volumes/metadata/add.rb,
lib/hpcloud/commands/cdn_containers/remove.rb,
lib/hpcloud/commands/routers/interface/add.rb,
lib/hpcloud/commands/securitygroups/remove.rb,
lib/hpcloud/commands/addresses/disassociate.rb,
lib/hpcloud/commands/images/metadata/remove.rb,
lib/hpcloud/commands/cdn_containers/location.rb,
lib/hpcloud/commands/keypairs/private/remove.rb,
lib/hpcloud/commands/servers/metadata/remove.rb,
lib/hpcloud/commands/routers/interface/remove.rb,
lib/hpcloud/commands/securitygroups/rules/add.rb,
lib/hpcloud/commands/keypairs/private/location.rb,
lib/hpcloud/commands/servers/securitygroups/add.rb,
lib/hpcloud/commands/securitygroups/rules/remove.rb,
lib/hpcloud/commands/servers/securitygroups/remove.rb
Constant Summary collapse
- GOPTS =
{:availability_zone => {:type => :string, :aliases => '-z', :desc => 'Set the availability zone.'}, :debug => {:type => :string, :aliases => '-x', :desc => 'Debug logging 1,2,3,...'}, :tenantid => {:type => :string, :desc => 'Tenant id for account.'}, :account_name => {:type => :string, :aliases => '-a', :desc => 'Select account.'}}
Instance Attribute Summary collapse
-
#exit_status ⇒ Object
Returns the value of attribute exit_status.
Class Method Summary collapse
Instance Method Summary collapse
- #account(name = nil) ⇒ Object
- #acl(name, *names) ⇒ Object
- #addresses(*arguments) ⇒ Object
- #complete ⇒ Object
- #config ⇒ Object
- #copy(source, *destination) ⇒ Object
- #dns(*arguments) ⇒ Object
- #flavors(*arguments) ⇒ Object
- #get(source, *sources) ⇒ Object
- #images(*arguments) ⇒ Object
- #info ⇒ Object
-
#initialize(*args) ⇒ CLI
constructor
A new instance of CLI.
- #keypairs(*arguments) ⇒ Object
- #lb(*arguments) ⇒ Object
- #list(*sources) ⇒ Object
- #location(name, *names) ⇒ Object
- #migrate(source_account, source, *destination) ⇒ Object
- #move(source, *destination) ⇒ Object
- #networks(*arguments) ⇒ Object
- #ports(*arguments) ⇒ Object
- #remove(name, *names) ⇒ Object
- #routers(*arguments) ⇒ Object
- #securitygroups(*arguments) ⇒ Object
- #servers(*arguments) ⇒ Object
- #snapshots(*arguments) ⇒ Object
- #subnets(*arguments) ⇒ Object
- #tempurl(name, *names) ⇒ Object
- #volumes(*arguments) ⇒ Object
Methods inherited from Thor
Constructor Details
Instance Attribute Details
#exit_status ⇒ Object
Returns the value of attribute exit_status.
30 31 32 |
# File 'lib/hpcloud/cli.rb', line 30 def exit_status @exit_status end |
Class Method Details
.exit_on_failure? ⇒ Boolean
65 66 67 |
# File 'lib/hpcloud/cli.rb', line 65 def exit_on_failure? true end |
Instance Method Details
#account(name = nil) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/hpcloud/commands/account.rb', line 49 def account(name=nil) cli_command() { accounts = HP::Cloud::Accounts.new() if name.nil? config = Config.new(true) name = config.get(:default_account) listo = accounts.list @log.display listo.gsub(/^(#{name})$/, '\1 <= default') else sub_command { acct = accounts.read(name) @log.display acct.to_yaml.gsub(/---\n/,'').gsub(/^:/,'').gsub(/^[ ]*:/,' ') } end } end |
#acl(name, *names) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hpcloud/commands/acl.rb', line 40 def acl(name, *names) cli_command() { names = [name] + names ray = [] names.each { |name| resource = ResourceFactory.create(Connection.instance.storage, name) if resource.container_head ray << resource.to_hash() else @log.error resource.cstatus end } keys = [ "public", "readers", "writers", "public_url"] if ray.empty? @log.display "There are no resources that match the provided arguments" else Tableizer.new(, keys, ray).print end } end |
#addresses(*arguments) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hpcloud/commands/addresses.rb', line 46 def addresses(*arguments) cli_command() { addresses = FloatingIps.new if addresses.empty? @log.display "You currently have no public IP addresses, use `#{selfname} addresses:add` to create one." else ray = addresses.get_array(arguments) if ray.empty? @log.display "There are no IP addresses that match the provided arguments" else Tableizer.new(, FloatingIpHelper.get_keys(), ray).print end end } end |
#complete ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/hpcloud/commands/complete.rb', line 35 def complete begin completion_dir = File.(File.join(File.dirname(__FILE__), '../../..', 'completion')) destination = '/etc/bash_completion.d/' unless File.writable?(destination) @log.display "The system wide #{destination} directory exists, but is not writable." if File.exists?(destination) destination = "/opt/local/etc/bash_completion.d" unless File.writable?(destination) @log.display "The system wide #{destination} directory exists, but is not writable." if File.exists?(destination) destination = "#{ENV['HOME']}/.bash_completion.d" FileUtils.mkdir(destination) unless File.exists?(destination) @log.display "You may need to manually execute the bash completion script in your .bashrc" end end completion_file = "#{completion_dir}/hpcloud" destination = "#{destination}/hpcloud" @log.display "Attempting to copy #{completion_file} file to #{destination}" FileUtils.copy(completion_file, destination) @log.display "Success" rescue Exception => e @log.error "Error configuring bash completion: #{e}" end end |
#config ⇒ Object
39 40 41 42 43 |
# File 'lib/hpcloud/commands/config.rb', line 39 def config cli_command() { @log.display Config.new.list } end |
#copy(source, *destination) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/hpcloud/commands/copy.rb', line 55 def copy(source, *destination) cli_command() { last = destination.pop source = [source] + destination destination = last to = ResourceFactory.create_any(Connection.instance.storage, destination) if source.length > 1 && to.isDirectory() == false @log.fatal("The destination '#{destination}' for multiple files must be a directory or container") end source.each { |name| from = ResourceFactory.create_any(Connection.instance.storage([:source_account]), name) from.set_mime_type([:mime]) to.set_restart([:restart]) if to.copy(from) @log.display "Copied #{from.fname} => #{to.fname}" else @log.fatal to.cstatus end } } end |
#dns(*arguments) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hpcloud/commands/dns.rb', line 48 def dns(*arguments) cli_command() { dnss = Dnss.new if dnss.empty? @log.display "You currently have no DNS domains, use `#{selfname} dns:add <name>` to create one." else ray = dnss.get_array(arguments) if ray.empty? @log.display "There are no DNS domains that match the provided arguments" else Tableizer.new(, DnsHelper.get_keys(), ray).print end end } end |
#flavors(*arguments) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/hpcloud/commands/flavors.rb', line 41 def flavors(*arguments) columns = [ "id", "name", "ram", "disk" ] cli_command() { flavors = Flavors.new if flavors.empty? @log.display "You currently have no flavors." else ray = flavors.get_array(arguments) if ray.empty? @log.display "There are no flavors that match the provided arguments" else Tableizer.new(, columns, ray).print end end } end |
#get(source, *sources) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/hpcloud/commands/get.rb', line 39 def get(source, *sources) cli_command() { sources = [source] + sources to = ResourceFactory.create(Connection.instance.storage, ".") sources.each { |name| from = ResourceFactory.create(Connection.instance.storage, name) if from.isRemote() == false @log.error "Source object does not appear to be remote '#{from.fname}'.", :incorrect_usage elsif to.copy(from) @log.display "Copied #{from.fname} => #{to.fname}" else @log.fatal to.cstatus end } } end |
#images(*arguments) ⇒ Object
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hpcloud/commands/images.rb', line 49 def images(*arguments) cli_command() { images = Images.new() if images.empty? @log.display "You currently have no images, use `#{selfname} images:add` to create one." else ray = images.get_array(arguments) if ray.empty? @log.display "There are no images that match the provided arguments" else Tableizer.new(, ImageHelper.get_keys(), ray).print end end } end |
#info ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/hpcloud/commands/info.rb', line 29 def info @log.display "******************************************************************" @log.display " HP Cloud CLI" @log.display " Command-line interface for managing HP Cloud services" @log.display "\n Version: #{VERSION}" @log.display " SHA1: #{SHA1}" @log.display "\n Copyright (c) 2011 Hewlett-Packard Development Company, L.P." @log.display "******************************************************************" end |
#keypairs(*arguments) ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/hpcloud/commands/keypairs.rb', line 47 def keypairs(*arguments) cli_command() { keypairs = Keypairs.new if keypairs.empty? @log.display "You currently have no keypairs, use `#{selfname} keypairs:add <name>` to create one." else ray = keypairs.get_array(arguments) if ray.empty? @log.display "There are no keypairs that match the provided arguments" else Tableizer.new(, KeypairHelper.get_keys(), ray).print end end } end |
#lb(*arguments) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hpcloud/commands/lb.rb', line 55 def lb(*arguments) columns = [ "id", "name", "algorithm", "protocol", "port", "status" ] cli_command() { lb = Lbs.new if lb.empty? @log.display "You currently have no load balancers, use `#{selfname} lb:add <name>` to create one." else ray = lb.get_array(arguments) if ray.empty? @log.display "There are no load balancers that match the provided arguments" else Tableizer.new(, columns, ray).print end end } end |
#list(*sources) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/hpcloud/commands/list.rb', line 50 def list(*sources) cli_command() { sources = [""] if sources.empty? multi = sources.length > 1 opt = {} opt[Columns.option_name] = [Columns.option_name] opt[Tableizer.option_name] = [Tableizer.option_name] if [:long] longlist = true else if [:sync] longlist = true else longlist = false opt[Tableizer.option_name] = ' ' if opt[Tableizer.option_name].nil? end end sources.each { |name| sub_command { from = ResourceFactory.create(Connection.instance.storage, name) if from.valid_source() multi = true unless from.is_container? if multi keys = [ "lname" ] else keys = [ "sname" ] end if longlist == true if from.is_object_store? if [:sync] keys += [ "count", "size", "synckey", "syncto" ] else keys += [ "count", "size" ] end else keys += [ "size", "type", "etag", "modified" ] end end tableizer = Tableizer.new(opt, keys) from.foreach { |file| if [:sync] file.container_head(true) end tableizer.add(file.to_hash) } tableizer.print if tableizer.found == false if from.is_object_store? @log.error "Cannot find any containers, use `#{selfname} containers:add <name>` to create one.", :not_found elsif from.isDirectory() == false @log.error "Cannot find resource named '#{name}'.", :not_found end end else @log.error from.cstatus end } } } end |
#location(name, *names) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/hpcloud/commands/location.rb', line 41 def location(name, *names) cli_command() { names = [name] + names names.each { |name| resource = ResourceFactory.create(Connection.instance.storage, name) if resource.head @log.display resource.public_url else @log.error resource.cstatus end } } end |
#migrate(source_account, source, *destination) ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/hpcloud/commands/migrate.rb', line 39 def migrate(source_account, source, *destination) cli_command() { last = destination.pop source = [source] + destination destination = last to = ResourceFactory.create_any(Connection.instance.storage, destination) if source.length > 1 && to.isDirectory() == false @log.fatal("The destination '#{destination}' for multiple files, must be a directory or container") end source.each { |name| from = ResourceFactory.create_any(Connection.instance.storage(source_account), name) from.set_mime_type([:mime]) if to.copy(from) @log.display "Migrated #{from.fname} => #{to.fname}" else @log.fatal to.cstatus end } } end |
#move(source, *destination) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/hpcloud/commands/move.rb', line 41 def move(source, *destination) cli_command() { last = destination.pop if last.nil? @log.fatal "To move you must specify a source and a destination", :incorrect_usage end source = [source] + destination destination = last to = ResourceFactory.create_any(Connection.instance.storage, destination) if source.length > 1 && to.isDirectory() == false @log.fatal("The destination '#{destination}' for multiple files must be a directory or container") end source.each { |name| from = ResourceFactory.create_any(Connection.instance.storage, name) if from.isLocal() @log.error "Move is limited to remote objects. Please use '#{selfname} copy' instead.", :incorrect_usage next end if to.copy(from) if from.remove(false) @log.display "Moved #{from.fname} => #{to.fname}" else @log.error from.cstatus end else @log.error to.cstatus end } } end |
#networks(*arguments) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hpcloud/commands/networks.rb', line 46 def networks(*arguments) cli_command() { networks = Networks.new if networks.empty? @log.display "You currently have no networks, use `#{selfname} networks:add <name>` to create one." else ray = networks.get_array(arguments) if ray.empty? @log.display "There are no networks that match the provided arguments" else Tableizer.new(, NetworkHelper.get_keys(), ray).print end end } end |
#ports(*arguments) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hpcloud/commands/ports.rb', line 46 def ports(*arguments) cli_command() { ports = Ports.new if ports.empty? @log.display "You currently have no ports, use `#{selfname} ports:add <name>` to create one." else ray = ports.get_array(arguments) if ray.empty? @log.display "There are no ports that match the provided arguments" else Tableizer.new(, PortHelper.get_keys(), ray).print end end } end |
#remove(name, *names) ⇒ Object
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/hpcloud/commands/remove.rb', line 51 def remove(name, *names) cli_command() { names = [name] + names names.each { |name| resource = ResourceFactory.create(Connection.instance.storage, name) if resource.remove(.force, [:at], [:after]) if [:at].nil? if [:after].nil? @log.display "Removed '#{name}'." else @log.display "Removing '#{name}' after #{[:after]} seconds." end else @log.display "Removing '#{name}' at #{[:at]} seconds of the epoch." end else @log.error resource.cstatus end } } end |
#routers(*arguments) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# File 'lib/hpcloud/commands/routers.rb', line 48 def routers(*arguments) columns = [ "id", "name", "admin_state_up", "status", "external_gateway_info" ] cli_command() { routers = Routers.new if routers.empty? @log.display "You currently have no routers, use `#{selfname} routers:add <name>` to create one." else ray = routers.get_array(arguments) if ray.empty? @log.display "There are no routers that match the provided arguments" else Tableizer.new(, columns, ray).print end end } end |
#securitygroups(*arguments) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/hpcloud/commands/securitygroups.rb', line 45 def securitygroups(*arguments) cli_command() { securitygroups = SecurityGroups.new if securitygroups.empty? @log.display "You currently have no security groups, , use `#{selfname} securitygroups:add <name>` to create one." else ray = securitygroups.get_array(arguments) if ray.empty? @log.display "There are no security groups that match the provided arguments" else Tableizer.new(, SecurityGroupHelper.get_keys(), ray).print end end } end |
#servers(*arguments) ⇒ Object
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/hpcloud/commands/servers.rb', line 61 def servers(*arguments) cli_command() { keys = ServerHelper.get_keys().dup if [:all_regions].nil? servers = Servers.new if servers.empty? @log.display "You currently have no servers, use `#{selfname} servers:add <name>` to create one." end ray = servers.get_array(arguments) else ray = [] keys.concat(["region"]) myopts = .dup Connection.instance.zones("Compute").each { |x| myopts[:availability_zone] = x Connection.instance.(myopts) zoneray = Servers.new.get_array(arguments) zoneray.each { |srv| srv['region'] = x } ray.concat(zoneray) Connection.instance.() } end if ray.empty? @log.display "There are no servers that match the provided arguments" else Tableizer.new(, keys, ray).print end } end |
#snapshots(*arguments) ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/hpcloud/commands/snapshots.rb', line 45 def snapshots(*arguments) cli_command() { snapshots = Snapshots.new if snapshots.empty? @log.display "You currently have no block snapshot devices, use `#{selfname} snapshots:add <name>` to create one." else ray = snapshots.get_array(arguments) if ray.empty? @log.display "There are no snapshots that match the provided arguments" else Tableizer.new(, SnapshotHelper.get_keys(), ray).print end end } end |
#subnets(*arguments) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/hpcloud/commands/subnets.rb', line 46 def subnets(*arguments) cli_command() { subnets = Subnets.new if subnets.empty? @log.display "You currently have no subnets, use `#{selfname} subnets:add <name>` to create one." else ray = subnets.get_array(arguments) if ray.empty? @log.display "There are no subnets that match the provided arguments" else Tableizer.new(, SubnetHelper.get_keys(), ray).print end end } end |
#tempurl(name, *names) ⇒ Object
46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'lib/hpcloud/commands/tempurl.rb', line 46 def tempurl(name, *names) cli_command() { names = [name] + names names.each { |name| resource = ResourceFactory.create(Connection.instance.storage, name) url = resource.tempurl(TimeParser.parse([:time_period])) unless url.nil? @log.display url else @log.error resource.cstatus end } } end |
#volumes(*arguments) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/hpcloud/commands/volumes.rb', line 48 def volumes(*arguments) cli_command() { volumes = Volumes.new if volumes.empty? @log.display "You currently have no block volume devices, use `#{selfname} volumes:add <name>` to create one." else ray = volumes.get_array(arguments) if ray.empty? @log.display "There are no volumes that match the provided arguments" else Tableizer.new(, VolumeHelper.get_keys(), ray).print end end } end |