Class: JoyentCLI
- Inherits:
-
Thor
- Object
- Thor
- JoyentCLI
- Defined in:
- bin/joyent
Instance Method Summary collapse
- #create_key ⇒ Object
- #create_machine ⇒ Object
- #delete_key(name) ⇒ Object
- #delete_machine(id) ⇒ Object
- #get_key(name) ⇒ Object
- #list_datacenters ⇒ Object
- #list_datasets ⇒ Object
- #list_keys ⇒ Object
- #list_machines ⇒ Object
- #list_packages ⇒ Object
- #reboot_machine(id) ⇒ Object
- #resize_machine(id, package) ⇒ Object
- #start_machine(id) ⇒ Object
- #stop_machine(id) ⇒ Object
Instance Method Details
#create_key ⇒ Object
72 73 74 75 76 77 |
# File 'bin/joyent', line 72 def create_key conn = get_connection key = conn.keys.create(["name"], get_rsa_key(["key"])) puts key.name puts key.key end |
#create_machine ⇒ Object
137 138 139 140 141 |
# File 'bin/joyent', line 137 def create_machine conn = get_connection(["datacenter"]) m = conn.machines.create() puts "#{m.name}: #{m.dataset} (#{m.state})" end |
#delete_key(name) ⇒ Object
80 81 82 83 84 85 |
# File 'bin/joyent', line 80 def delete_key(name) conn = get_connection key = conn.keys.get(name) key.delete puts "DELETED: #{key.name}" end |
#delete_machine(id) ⇒ Object
181 182 183 184 185 186 |
# File 'bin/joyent', line 181 def delete_machine(id) conn = get_connection(["datacenter"]) m = conn.machines.get(id) m.delete puts "#{m.name} [#{m.id}] DELETED" end |
#get_key(name) ⇒ Object
63 64 65 66 67 |
# File 'bin/joyent', line 63 def get_key(name) conn = get_connection key = conn.keys.get(name) puts key.key end |
#list_datacenters ⇒ Object
91 92 93 94 95 96 |
# File 'bin/joyent', line 91 def list_datacenters conn = get_connection conn.datacenters.list.each do |dc| puts "#{dc.name}: #{dc.url}" end end |
#list_datasets ⇒ Object
102 103 104 105 106 107 |
# File 'bin/joyent', line 102 def list_datasets conn = get_connection conn.datasets.list.each do |d| puts "#{d.name}: #{d.os} (#{d.urn})" end end |
#list_keys ⇒ Object
55 56 57 58 59 60 |
# File 'bin/joyent', line 55 def list_keys conn = get_connection conn.keys.list.each do |dc| puts dc.name end end |
#list_machines ⇒ Object
125 126 127 128 129 130 |
# File 'bin/joyent', line 125 def list_machines conn = get_connection(["datacenter"]) conn.machines.list.each do |m| puts "#{m.name} [#{m.id}]: #{m.dataset} (#{m.state})" end end |
#list_packages ⇒ Object
113 114 115 116 117 118 |
# File 'bin/joyent', line 113 def list_packages conn = get_connection conn.packages.list.each do |p| puts "#{p.name}: RAM-#{p.memory} HD-#{p.disk}" end end |
#reboot_machine(id) ⇒ Object
163 164 165 166 167 168 |
# File 'bin/joyent', line 163 def reboot_machine(id) conn = get_connection(["datacenter"]) m = conn.machines.get(id) m.reboot puts "#{m.name} [#{m.id}] REBOOTED" end |
#resize_machine(id, package) ⇒ Object
172 173 174 175 176 177 |
# File 'bin/joyent', line 172 def resize_machine(id, package) conn = get_connection(["datacenter"]) m = conn.machines.get(id) m.resize(package) puts "#{m.name} [#{m.id}] RESIZED to #{package}" end |
#start_machine(id) ⇒ Object
154 155 156 157 158 159 |
# File 'bin/joyent', line 154 def start_machine(id) conn = get_connection(["datacenter"]) m = conn.machines.get(id) m.start puts "#{m.name} [#{m.id}] STARTED" end |
#stop_machine(id) ⇒ Object
145 146 147 148 149 150 |
# File 'bin/joyent', line 145 def stop_machine(id) conn = get_connection(["datacenter"]) m = conn.machines.get(id) m.stop puts "#{m.name} [#{m.id}] STOPPED" end |