Class: Yao::Resources::Port

Inherits:
Base
  • Object
show all
Includes:
NetworkAssociationable, ProjectAssociationable
Defined in:
lib/yao/resources/port.rb

Instance Attribute Summary

Attributes included from RestfullyAccessible

#service

Instance Method Summary collapse

Methods included from ProjectAssociationable

included, #project

Methods included from NetworkAssociationable

included, #network

Methods inherited from Base

#[], #[]=, add_instantiation_name_list, #destroy, friendly_attributes, #id, #initialize, instantiation?, map_attribute_to_attribute, map_attribute_to_resource, map_attribute_to_resources, map_attributes_to_time, #to_hash, #update

Methods included from RestfullyAccessible

#admin=, #api_version, #api_version=, #as_member, #client, #create, #destroy, extended, #find_by_name, #get, #get!, #list, #resources_path, #resources_path=, #return_single_on_querying, #return_single_on_querying=, #update

Constructor Details

This class inherits a constructor from Yao::Resources::Base

Instance Method Details

#floating_ipYao::FloatingIP

Returns:

  • (Yao::FloatingIP)


23
24
25
26
27
28
29
30
31
# File 'lib/yao/resources/port.rb', line 23

def floating_ip
  # notice: port が floating_ip を持たない場合has_floating_ip? を呼び出す度に
  # Yao::FloatingIP.list を評価しなくていいように defined? を入れている
  if defined?(@floating_ip)
    @floating_ip
  else
    @floating_ip = Yao::FloatingIP.list(port_id: id).first
  end
end

#has_floating_ip?Bool

Returns:

  • (Bool)


34
35
36
# File 'lib/yao/resources/port.rb', line 34

def has_floating_ip?
  !!floating_ip
end

#primary_ipString

Returns:

  • (String)


13
14
15
# File 'lib/yao/resources/port.rb', line 13

def primary_ip
  fixed_ips.first["ip_address"]
end

#primary_subnetYao::Resources::Subnet



18
19
20
# File 'lib/yao/resources/port.rb', line 18

def primary_subnet
  @subnet ||= Yao::Subnet.find fixed_ips.first["subnet_id"]
end