Class: AWS::EC2::NetworkInterface
- Inherits:
-
Resource
- Object
- Core::Resource
- Resource
- AWS::EC2::NetworkInterface
- Includes:
- TaggedItem
- Defined in:
- lib/aws/ec2/network_interface.rb,
lib/aws/ec2/network_interface/attachment.rb
Overview
Represents a network interface in EC2.
Defined Under Namespace
Classes: Attachment
Instance Attribute Summary collapse
- #network_interface_id ⇒ String (also: #id) readonly
Instance Method Summary collapse
- #attach(instance, options = {}) ⇒ nil
- #attachment ⇒ Object
-
#delete ⇒ nil
Deletes this network interface.
-
#detach(options = {}) ⇒ nil
Detaches this network interface.
-
#exists? ⇒ Boolean
Returns true if this network interface exists.
-
#initialize(network_interface_id, options = {}) ⇒ NetworkInterface
constructor
A new instance of NetworkInterface.
-
#instance ⇒ Instance?
Returns the instance this network interface is attached to.
- #security_groups ⇒ Array<SecurityGroup>
- #set_security_groups(*groups) ⇒ nil (also: #security_groups=)
-
#subnet ⇒ Subnet
Returns the Subnet this network interface belongs to.
-
#vpc ⇒ VPC
Returns the VPC this network interface belongs to.
Methods included from TaggedItem
Constructor Details
#initialize(network_interface_id, options = {}) ⇒ NetworkInterface
Returns a new instance of NetworkInterface.
24 25 26 27 |
# File 'lib/aws/ec2/network_interface.rb', line 24 def initialize network_interface_id, = {} @network_interface_id = network_interface_id super end |
Instance Attribute Details
#network_interface_id ⇒ String (readonly) Also known as: id
30 31 32 |
# File 'lib/aws/ec2/network_interface.rb', line 30 def network_interface_id @network_interface_id end |
Instance Method Details
#attach(instance, options = {}) ⇒ nil
126 127 128 129 130 131 132 133 134 135 136 137 138 139 |
# File 'lib/aws/ec2/network_interface.rb', line 126 def attach instance, = {} instance_id = instance.is_a?(Instance) ? instance.instance_id : instance client_opts = {} client_opts[:network_interface_id] = network_interface_id client_opts[:instance_id] = instance_id client_opts[:device_index] = [:device_index] || 1 client.attach_network_interface(client_opts) nil end |
#attachment ⇒ Object
110 111 112 113 114 |
# File 'lib/aws/ec2/network_interface.rb', line 110 def if details = Attachment.new(self, details) end end |
#delete ⇒ nil
Deletes this network interface.
155 156 157 158 159 160 |
# File 'lib/aws/ec2/network_interface.rb', line 155 def delete client_opts = {} client_opts[:network_interface_id] = network_interface_id client.delete_network_interface(client_opts) nil end |
#detach(options = {}) ⇒ nil
Detaches this network interface.
145 146 147 148 149 150 151 |
# File 'lib/aws/ec2/network_interface.rb', line 145 def detach = {} if = self. .detach() else raise 'unable to detach network interface, no attachment present' end end |
#exists? ⇒ Boolean
Returns true if this network interface exists.
163 164 165 166 167 168 169 170 |
# File 'lib/aws/ec2/network_interface.rb', line 163 def exists? begin get_resource true rescue Errors::InvalidNetworkInterfaceID::NotFound false end end |
#instance ⇒ Instance?
Returns the instance this network interface is attached to. If it has not been attached, then nil is returned.
104 105 106 107 108 |
# File 'lib/aws/ec2/network_interface.rb', line 104 def instance if = self. .instance end end |
#security_groups ⇒ Array<SecurityGroup>
81 82 83 84 85 |
# File 'lib/aws/ec2/network_interface.rb', line 81 def security_groups groups.collect do |g| SecurityGroup.new(g.group_id, :name => g.group_name, :config => config) end end |
#set_security_groups(*groups) ⇒ nil Also known as: security_groups=
93 94 95 96 97 98 |
# File 'lib/aws/ec2/network_interface.rb', line 93 def set_security_groups *groups self.groups = [groups].flatten.collect do |g| g.is_a?(SecurityGroup) ? g.security_group_id : g end nil end |