Class: Dcmgr::NodeModules::OpenFlowNetwork

Inherits:
Object
  • Object
show all
Defined in:
lib/dcmgr/node_modules/openflow_controller.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id) ⇒ OpenFlowNetwork

Returns a new instance of OpenFlowNetwork.



736
737
738
739
740
741
742
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 736

def initialize id
  @id = id
  @ports = []
  @local_ports = []
  @virtual = false
  @prefix = 0
end

Instance Attribute Details

#dhcp_hwObject

Returns the value of attribute dhcp_hw.



731
732
733
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 731

def dhcp_hw
  @dhcp_hw
end

#dhcp_ipObject

Returns the value of attribute dhcp_ip.



732
733
734
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 732

def dhcp_ip
  @dhcp_ip
end

#idObject (readonly)

Returns the value of attribute id.



727
728
729
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 727

def id
  @id
end

#ipv4_networkObject

Returns the value of attribute ipv4_network.



733
734
735
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 733

def ipv4_network
  @ipv4_network
end

#local_portsObject (readonly)

Returns the value of attribute local_ports.



729
730
731
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 729

def local_ports
  @local_ports
end

#portsObject (readonly)

Returns the value of attribute ports.



728
729
730
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 728

def ports
  @ports
end

#prefixObject

Returns the value of attribute prefix.



734
735
736
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 734

def prefix
  @prefix
end

#virtualObject

Returns the value of attribute virtual.



730
731
732
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 730

def virtual
  @virtual
end

Instance Method Details

#add_port(port, is_local) ⇒ Object



744
745
746
747
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 744

def add_port port, is_local
  ports << port
  local_ports << port if is_local
end

#flood_flowsObject



773
774
775
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 773

def flood_flows
  @flood_flows ||= Array.new
end

#flood_local_flowsObject



777
778
779
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 777

def flood_local_flows
  @flood_local_flows ||= Array.new
end

#generate_flood_actions(template, use_ports) ⇒ Object



765
766
767
768
769
770
771
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 765

def generate_flood_actions template, use_ports
  actions = ""
  use_ports.each { |port|
    actions << ",#{template.gsub('<>', port.to_s)}"
  }
  actions
end

#generate_flood_flowsObject



754
755
756
757
758
759
760
761
762
763
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 754

def generate_flood_flows
  flows = []
  flood_flows.each { |flow|
    flows << [flow[0], "#{flow[1]}#{generate_flood_actions(flow[2], ports)}#{flow[3]}"]
  }
  flood_local_flows.each { |flow|
    flows << [flow[0], "#{flow[1]}#{generate_flood_actions(flow[2], local_ports)}#{flow[3]}"]
  }
  flows
end

#remove_port(port) ⇒ Object



749
750
751
752
# File 'lib/dcmgr/node_modules/openflow_controller.rb', line 749

def remove_port port
  ports.delete port
  local_ports.delete port
end