class AwsPocketknife::Cli::Ec2
Public Instance Methods
find_by_id(instance_id)
click to toggle source
# File lib/aws_pocketknife/cli/ec2.rb, line 29 def find_by_id(instance_id) instance = AwsPocketknife::Ec2.find_by_id(instance_id: instance_id) if instance.nil? puts "Instance #{instance_id} not found" else AwsPocketknife::Ec2.nice_print(object: instance.to_h) end end
find_by_name(name)
click to toggle source
# File lib/aws_pocketknife/cli/ec2.rb, line 9 def find_by_name(name) instances = AwsPocketknife::Ec2.find_by_name(name: name) headers = ["name", "id", "image", "state", "private ip", "public ip", "type", "key name", "launch time"] data = [] if instances.length > 0 instances.each do |instance| name = AwsPocketknife::Ec2.get_tag_value(tags: instance.tags, tag_key: "Name") data << [name, instance.instance_id, instance.image_id, instance.state.name, instance.private_ip_address, instance.public_ip_address, instance.instance_type, instance.key_name, instance.launch_time] end AwsPocketknife::Ec2.pretty_table(headers: headers, data: data) else puts "No instance(s) found for name #{name}" end end
get_windows_password(instance_id)
click to toggle source
# File lib/aws_pocketknife/cli/ec2.rb, line 39 def get_windows_password(instance_id) instance = AwsPocketknife::Ec2.get_windows_password(instance_id: instance_id) headers = ["instance id", "password", "private ip", "public ip"] data = [[instance.instance_id, instance.password, instance.private_ip_address, instance.public_ip_address]] AwsPocketknife::Ec2.pretty_table(headers: headers, data: data) end
start(instance_id)
click to toggle source
# File lib/aws_pocketknife/cli/ec2.rb, line 55 def start(instance_id) AwsPocketknife::Ec2.start_instance_by_id(instance_id) end
stop(instance_id)
click to toggle source
# File lib/aws_pocketknife/cli/ec2.rb, line 50 def stop(instance_id) AwsPocketknife::Ec2.stop_instance_by_id(instance_id) end