Class: Awscli::EC2::NetworkInterfaces

Inherits:
Object
  • Object
show all
Defined in:
lib/awscli/ec2.rb

Overview

> NetworkAcl

Instance Method Summary collapse

Constructor Details

#initialize(connection) ⇒ NetworkInterfaces

Returns a new instance of NetworkInterfaces.



799
800
801
# File 'lib/awscli/ec2.rb', line 799

def initialize(connection)
  @conn = connection
end

Instance Method Details

#attach(nic_id, instance_id, device_index) ⇒ Object



819
820
821
822
# File 'lib/awscli/ec2.rb', line 819

def attach(nic_id, instance_id, device_index)
  @conn.attach_network_interface(nic_id, instance_id, device_index)
  puts "Attached Network Interface: #{nic_id} to instance: #{instance_id}"
end

#create(options) ⇒ Object



807
808
809
810
# File 'lib/awscli/ec2.rb', line 807

def create(options)
  nic = @conn.network_interfaces.create(options)
  puts "Create network interface #{nic.network_interface_id}"
end

#deattach(attachement_id, force) ⇒ Object



824
825
826
827
# File 'lib/awscli/ec2.rb', line 824

def deattach(attachement_id, force)
  @conn.detach_network_interface attachement_id, force
  puts "Detached Network Interface with attachement_id: #{attachement_id}"
end

#delete(nic_id) ⇒ Object



812
813
814
815
816
817
# File 'lib/awscli/ec2.rb', line 812

def delete(nic_id)
  nic = @conn.network_interfaces.get(nic_id)
  abort "Cannot find nic with id: #{nic_id}" unless nic
  nic.destroy
  puts "Deleted network interface #{nic_id}"
end

#listObject



803
804
805
# File 'lib/awscli/ec2.rb', line 803

def list
  @conn.network_interfaces.table
end

#modify_attribute(options) ⇒ Object



829
830
831
832
833
834
835
836
837
838
839
840
841
842
# File 'lib/awscli/ec2.rb', line 829

def modify_attribute(options)
  case options[:attribute]
  when 'description'
    @conn.modify_network_interface_attribute(options[:network_interface_id], 'description', options[:description])
  when 'groupSet'
    @conn.modify_network_interface_attribute(options[:network_interface_id], 'groupSet', options[:group_set])
  when 'sourceDestCheck'
    @conn.modify_network_interface_attribute(options[:network_interface_id], 'sourceDestCheck', options[:source_dest_check])
  when 'attachment'
    @conn.modify_network_interface_attribute(options[:network_interface_id], 'attachment', options[:attachment])
  else
    abort "Invalid attribute: #{options[:attribute]}"
  end
end