You are viewing documentation for version 1 of the AWS SDK for Ruby. Version 2 documentation can be found here.
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
-
#association ⇒ Hash?
readonly
Returns a hash of details about the association between this network interface and an elastic ip address.
-
#availability_zone_name ⇒ String
readonly
The current value of availability_zone_name.
-
#description ⇒ String
The current value of description.
-
#mac_address ⇒ String
readonly
The current value of mac_address.
-
#network_interface_id ⇒ String
(also: #id)
readonly
-
#owner_id ⇒ String
readonly
The current value of owner_id.
-
#private_dns_name ⇒ String
readonly
The current value of private_dns_name.
-
#private_ip_address ⇒ String
readonly
The current value of private_ip_address.
-
#private_ip_addresses ⇒ Array<Hash>
readonly
Returns an array of private ip addresses with the following keys: *
:private_ip_address
(String) *:primary
(boolean). -
#requester_managed ⇒ Boolean
(also: #requester_managed?)
The current value of requester_managed.
-
#source_dest_check ⇒ Boolean
(also: #source_dest_check?)
The current value of source_dest_check.
-
#status ⇒ Symbol
readonly
The current value of status.
-
#subnet_id ⇒ String
readonly
The current value of subnet_id.
-
#vpc_id ⇒ String
readonly
The current value of vpc_id.
Instance Method Summary collapse
-
#attach(instance, options = {}) ⇒ nil
-
#attachment ⇒ Attachment?
-
#availability_zone ⇒ AvailabilityZone
-
#delete ⇒ nil
Deletes this network interface.
-
#detach(options = {}) ⇒ nil
Detaches this network interface.
-
#elastic_ip ⇒ ElasticIp?
-
#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
56 57 58 59 |
# File 'lib/aws/ec2/network_interface.rb', line 56 def initialize network_interface_id, = {} @network_interface_id = network_interface_id super end |
Instance Attribute Details
#association ⇒ Hash? (readonly)
Returns a hash of details about the association between this network interface and an elastic ip address.
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def association @association end |
#availability_zone_name ⇒ String (readonly)
Returns the current value of availability_zone_name
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def availability_zone_name @availability_zone_name end |
#description ⇒ String
Returns the current value of description
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def description @description end |
#mac_address ⇒ String (readonly)
Returns the current value of mac_address
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def mac_address @mac_address end |
#network_interface_id ⇒ String (readonly) Also known as: id
62 63 64 |
# File 'lib/aws/ec2/network_interface.rb', line 62 def network_interface_id @network_interface_id end |
#owner_id ⇒ String (readonly)
Returns the current value of owner_id
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def owner_id @owner_id end |
#private_dns_name ⇒ String (readonly)
Returns the current value of private_dns_name
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def private_dns_name @private_dns_name end |
#private_ip_address ⇒ String (readonly)
Returns the current value of private_ip_address
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def private_ip_address @private_ip_address end |
#private_ip_addresses ⇒ Array<Hash> (readonly)
Returns an array
of private ip addresses with the following keys:
* :private_ip_address
(String)
* :primary
(boolean)
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def private_ip_addresses @private_ip_addresses end |
#requester_managed ⇒ Boolean Also known as: requester_managed?
Returns the current value of requester_managed
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def requester_managed @requester_managed end |
#source_dest_check ⇒ Boolean Also known as: source_dest_check?
Returns the current value of source_dest_check
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def source_dest_check @source_dest_check end |
#status ⇒ Symbol (readonly)
Returns the current value of status
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def status @status end |
#subnet_id ⇒ String (readonly)
Returns the current value of subnet_id
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def subnet_id @subnet_id end |
#vpc_id ⇒ String (readonly)
Returns the current value of vpc_id
52 53 54 |
# File 'lib/aws/ec2/network_interface.rb', line 52 def vpc_id @vpc_id end |
Instance Method Details
#attach(instance, options = {}) ⇒ nil
189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'lib/aws/ec2/network_interface.rb', line 189 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 ⇒ Attachment?
173 174 175 176 177 |
# File 'lib/aws/ec2/network_interface.rb', line 173 def if details = Attachment.new(self, details) end end |
#availability_zone ⇒ AvailabilityZone
138 139 140 |
# File 'lib/aws/ec2/network_interface.rb', line 138 def availability_zone AvailabilityZone.new(availability_zone_name, :config => config) end |
#delete ⇒ nil
Deletes this network interface.
218 219 220 221 222 223 |
# File 'lib/aws/ec2/network_interface.rb', line 218 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.
208 209 210 211 212 213 214 |
# File 'lib/aws/ec2/network_interface.rb', line 208 def detach = {} if = self. .detach() else raise 'unable to detach network interface, no attachment present' end end |
#elastic_ip ⇒ ElasticIp?
130 131 132 133 134 135 |
# File 'lib/aws/ec2/network_interface.rb', line 130 def elastic_ip if association = self.association opts = association.merge(:config => config) ElasticIp.new(association[:public_ip], opts) end end |
#exists? ⇒ Boolean
Returns true if this network interface exists.
226 227 228 229 230 231 232 233 |
# File 'lib/aws/ec2/network_interface.rb', line 226 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.
166 167 168 169 170 |
# File 'lib/aws/ec2/network_interface.rb', line 166 def instance if = self. .instance end end |
#security_groups ⇒ Array<SecurityGroup>
143 144 145 146 147 |
# File 'lib/aws/ec2/network_interface.rb', line 143 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=
155 156 157 158 159 160 |
# File 'lib/aws/ec2/network_interface.rb', line 155 def set_security_groups *groups self.groups = [groups].flatten.collect do |g| g.is_a?(SecurityGroup) ? g.security_group_id : g end nil end |
#subnet ⇒ Subnet
Returns the Subnet this network interface belongs to.
125 126 127 |
# File 'lib/aws/ec2/network_interface.rb', line 125 def subnet Subnet.new(subnet_id, :vpc_id => vpc_id, :config => config) end |
#vpc ⇒ VPC
Returns the VPC this network interface belongs to.
119 120 121 |
# File 'lib/aws/ec2/network_interface.rb', line 119 def vpc VPC.new(vpc_id, :config => config) end |