class Swa::CLI::Ec2Command
Public Instance Methods
created_after=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 74 def created_after=(datetime_string) min_creation_date = parse_datetime(datetime_string).max selector.add do |image| Time.parse(image.creation_date) > min_creation_date end end
created_before=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 81 def created_before=(datetime_string) max_creation_date = parse_datetime(datetime_string).min selector.add do |image| Time.parse(image.creation_date) < max_creation_date end end
execute()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 27 def execute image.delete end
image()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 40 def image ec2_image = ec2.image(image_id) signal_error "No such image '#{image_id}'" unless ec2_image.exists? Swa::EC2::Image.new(ec2_image) end
images()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 88 def images query_options[:owners] = [owned_by] query_for(:images, Swa::EC2::Image) end
instance()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 123 def instance Swa::EC2::Instance.new(ec2.instance(instance_id)) end
instances()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 193 def instances add_filter("instance-state-name", state) query_for(:instances, Swa::EC2::Instance) end
key_pair()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 216 def key_pair Swa::EC2::KeyPair.new(ec2.key_pair(name)) end
key_pairs()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 234 def key_pairs query_for(:key_pairs, Swa::EC2::KeyPair) end
launched_after=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 177 def launched_after=(datetime_string) min_launch_time = parse_datetime(datetime_string).max selector.add do |instance| instance.launch_time > min_launch_time end end
launched_before=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 184 def launched_before=(datetime_string) max_launch_time = parse_datetime(datetime_string).min selector.add do |instance| instance.launch_time < max_launch_time end end
named=(name_pattern)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 70 def named=(name_pattern) add_filter("name", name_pattern) end
security_group()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 250 def security_group Swa::EC2::SecurityGroup.new(ec2.security_group(group_id)) end
security_groups()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 265 def security_groups query_for(:security_groups, Swa::EC2::SecurityGroup) end
snapshot()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 287 def snapshot Swa::EC2::Snapshot.new(ec2.snapshot(snapshot_id)) end
snapshots()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 333 def snapshots query_options[:owner_ids] = [owned_by] query_for(:snapshots, Swa::EC2::Snapshot) end
started_after=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 319 def started_after=(datetime_string) min_start_time = parse_datetime(datetime_string).max selector.add do |image| image.start_time > min_start_time end end
started_before=(datetime_string)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 326 def started_before=(datetime_string) max_start_time = parse_datetime(datetime_string).min selector.add do |image| image.start_time < max_start_time end end
subnet()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 350 def subnet Swa::EC2::Subnet.new(ec2.subnet(subnet_id)) end
subnets()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 365 def subnets query_for(:subnets, Swa::EC2::Subnet) end
volume()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 381 def volume Swa::EC2::Volume.new(ec2.volume(volume_id)) end
volume=(volume_id)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 315 def volume=(volume_id) add_filter("volume-id", volume_id) end
volumes()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 400 def volumes query_for(:volumes, Swa::EC2::Volume) end
vpc()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 416 def vpc Swa::EC2::Vpc.new(ec2.vpc(vpc_id)) end
vpcs()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 435 def vpcs query_for(:vpcs, Swa::EC2::Vpc) end
Protected Instance Methods
ec2()
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 445 def ec2 ::Aws::EC2::Resource.new(aws_config) end
query_for(query_method, resource_model)
click to toggle source
# File lib/swa/cli/ec2_command.rb, line 449 def query_for(query_method, resource_model) aws_resources = ec2.public_send(query_method, query_options) wrapped_resources = resource_model.list(aws_resources) selector.apply(wrapped_resources) end