示例#1
0
 def _build_ports(self):
     self._port_pairs = PortPairs(self.vnfd_helper.interfaces)
     self.networks = self._port_pairs.networks
     self.uplink_ports = self.vnfd_helper.port_nums(
         self._port_pairs.uplink_ports)
     self.downlink_ports = self.vnfd_helper.port_nums(
         self._port_pairs.downlink_ports)
     self.my_ports = self.vnfd_helper.port_nums(self._port_pairs.all_ports)
示例#2
0
 def _build_vnf_ports(self):
     self._port_pairs = PortPairs(self.vnfd_helper.interfaces)
     self.uplink_ports = self._port_pairs.uplink_ports
     self.downlink_ports = self._port_pairs.downlink_ports
     self.all_ports = self._port_pairs.all_ports
示例#3
0
 def __init__(self, *args, **kwargs):
     super(VnfdHelper, self).__init__(*args, **kwargs)
     self.port_pairs = PortPairs(self['vdu'][0]['external-interface'])
     # port num is not present until binding so we have to memoize
     self._port_num_map = {}
示例#4
0
 def get_default_flows(self):
     """Get default actions/rules
     Returns: (<actions>, <rules>)
         <actions>:
              { <action_id>: [ <list of actions> ]}
         Example:
              { 0 : [ "accept", "count", {"fwd" : "port": 0} ], ... }
         <rules>:
              [ {"src_ip": "x.x.x.x", "src_ip_mask", 24, ...}, ... ]
         Note:
             See `generate_rule_cmds()` to get list of possible map keys.
     """
     actions, rules = {}, []
     _port_pairs = PortPairs(self.vnfd_helper.interfaces)
     port_pair_list = _port_pairs.port_pair_list
     for src_intf, dst_intf in port_pair_list:
         # get port numbers of the interfaces
         src_port = self.vnfd_helper.port_num(src_intf)
         dst_port = self.vnfd_helper.port_num(dst_intf)
         # get interface addresses and prefixes
         src_net, src_prefix_len = self.get_network_and_prefixlen_from_ip_of_port(
             src_intf)
         dst_net, dst_prefix_len = self.get_network_and_prefixlen_from_ip_of_port(
             dst_intf)
         # ignore entries with empty values
         if all((src_net, src_prefix_len, dst_net, dst_prefix_len)):
             # flow: src_net:dst_net -> dst_port
             action_id = self.new_action_id
             actions[action_id] = self.DEFAULT_FWD_ACTIONS[:]
             actions[action_id].append({"fwd": {"port": dst_port}})
             rules.append({
                 "priority": 1,
                 'cmd': self.RULE_CMD,
                 "src_ip": src_net,
                 "src_ip_mask": src_prefix_len,
                 "dst_ip": dst_net,
                 "dst_ip_mask": dst_prefix_len,
                 "src_port_from": 0,
                 "src_port_to": 65535,
                 "dst_port_from": 0,
                 "dst_port_to": 65535,
                 "protocol": 0,
                 "protocol_mask": 0,
                 "action_id": action_id
             })
             # flow: dst_net:src_net -> src_port
             action_id = self.new_action_id
             actions[action_id] = self.DEFAULT_FWD_ACTIONS[:]
             actions[action_id].append({"fwd": {"port": src_port}})
             rules.append({
                 "cmd": self.RULE_CMD,
                 "priority": 1,
                 "src_ip": dst_net,
                 "src_ip_mask": dst_prefix_len,
                 "dst_ip": src_net,
                 "dst_ip_mask": src_prefix_len,
                 "src_port_from": 0,
                 "src_port_to": 65535,
                 "dst_port_from": 0,
                 "dst_port_to": 65535,
                 "protocol": 0,
                 "protocol_mask": 0,
                 "action_id": action_id
             })
     return actions, rules
示例#5
0
 def __init__(self, *args, **kwargs):
     super(VnfdHelper, self).__init__(*args, **kwargs)
     self.port_pairs = PortPairs(self['vdu'][0]['external-interface'])