Class: Dcmgr::VNet::Tasks::TranslateMetadataAddress

Inherits:
Dcmgr::VNet::Task show all
Includes:
Netfilter
Defined in:
lib/dcmgr/vnet/tasks/translate_metadata_address.rb

Instance Attribute Summary collapse

Attributes inherited from Dcmgr::VNet::Task

#rules

Instance Method Summary collapse

Constructor Details

#initialize(vnic_id, metadata_ip, metadata_port, metadata_fake_ip = "169.254.169.254", metadata_fake_port = "80") ⇒ TranslateMetadataAddress

Returns a new instance of TranslateMetadataAddress.



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/dcmgr/vnet/tasks/translate_metadata_address.rb', line 15

def initialize(vnic_id,,, = "169.254.169.254", = "80")
  super()
  
  @metadata_ip = 
  @metadata_port = 
  @metadata_fake_ip = 
  @metadata_fake_port = 
  
  # Translate requests to the metadata server
  self.rules << IptablesRule.new(:nat,:prerouting,:tcp,:outgoing,"-m physdev --physdev-in #{vnic_id} -d #{self.} -p tcp --dport #{self.} -j DNAT --to-destination #{self.}:#{self.}")
  # Accept tcp traffic to the metadata server
  self.rules << IptablesRule.new(:filter,:forward,:tcp,:outgoing,"-p tcp -d #{self.} --dport #{self.} -j ACCEPT")
end

Instance Attribute Details

#metadata_fake_ipObject (readonly)

Returns the value of attribute metadata_fake_ip.



12
13
14
# File 'lib/dcmgr/vnet/tasks/translate_metadata_address.rb', line 12

def 
  @metadata_fake_ip
end

#metadata_fake_portObject (readonly)

Returns the value of attribute metadata_fake_port.



13
14
15
# File 'lib/dcmgr/vnet/tasks/translate_metadata_address.rb', line 13

def 
  @metadata_fake_port
end

#metadata_ipObject (readonly)

TODO: allow ARP traffic to metadata server



10
11
12
# File 'lib/dcmgr/vnet/tasks/translate_metadata_address.rb', line 10

def 
  @metadata_ip
end

#metadata_portObject (readonly)

Returns the value of attribute metadata_port.



11
12
13
# File 'lib/dcmgr/vnet/tasks/translate_metadata_address.rb', line 11

def 
  @metadata_port
end