Esempio n. 1
0
  def create_NETCONF_EE (self, name, type=TYPE_EE_LOCAL, **params):
    """
    Create and add a new EE to Mininet network.

    The type of EE can be {local|remote} NETCONF-based.

    :param name: name of the EE: switch: name, agent: agt_+'name'
    :type name: str
    :param type: type of EE {local|remote}
    :type type: str
    :param opts: additional options for the switch in EE
    :type opts: str
    :param dpid: remote switch DPID (remote only)
    :param username: NETCONF username (remote only)
    :param passwd: NETCONF password (remote only)
    :param ip: control Interface for the agent (optional)
    :param agentPort: port to listen on for NETCONF connections, (else set \
    automatically)
    :param minPort: first VNF control port which can be used (else set \
    automatically)
    :param cPort: number of VNF control ports (and VNFs) which can be used ( \
    default: 10)
    :return: tuple of newly created :class:`mininet.node.Agent` and \
    :class:`mininet.node.Switch` object
    :rtype: tuple
    """
    type = type.upper()
    cfg = CONFIG.get_EE_params()
    cfg.update(params)
    cfg['dpid'] = self.__get_new_dpid()
    if type == self.TYPE_EE_LOCAL:
      # create local NETCONF-based
      log.debug("Create local NETCONF EE with name: %s" % name)
      sw = self.mn.addSwitch(name, **cfg)
    elif type == self.TYPE_EE_REMOTE:
      # create remote NETCONF-based
      log.debug("Create remote NETCONF EE with name: %s" % name)
      cfg["inNamespace"] = False
      sw = self.mn.addRemoteSwitch(name, cls=None, **cfg)
    else:
      raise TopologyBuilderException(
        "Unsupported NETCONF-based EE type: %s!" % type)
    agt = self.mn.addAgent('agt_' + name, cls=None, **cfg)
    agt.setSwitch(sw)
    return agt, sw
Esempio n. 2
0
  def create_static_EE (self, name, cls=None, **params):
    """
    Create and add a new EE to Mininet in the static way.

    This function is for only backward compatibility.

    .. warning::
      Not tested yet!

    :param name: name of the Execution Environment
    :type name: str
    :param cls: custom EE class/constructor (optional)
    :type cls: :class:`mininet.node.EE`
    :param cores: Specify (real) cores that our cgroup can run on (optional)
    :type cores: list
    :param frac: Set overall CPU fraction for this EE (optional)
    :type frac: list
    :param vlanif: set vlan interfaces (optional)
    :type vlanif: list
    :return: newly created EE object
    :rtype: :class:`mininet.node.EE`
    """
    # create static EE
    cfg = CONFIG.get_EE_params()
    cfg.update(params)
    cfg['dpid'] = self.__get_new_dpid()
    log.debug("Create static EE with name: %s" % name)
    ee = self.mn.addEE(name=name, cls=cls, **cfg)
    if 'cores' in cfg:
      ee.setCPUs(**cfg['cores'])
    if 'frac' in cfg:
      ee.setCPUFrac(**cfg['frac'])
    if 'vlanif' in cfg:
      for vif in cfg['vlaninf']:
        ee.cmdPrint('vconfig add ' + name + '-eth0 ' + vif[1])
        ee.cmdPrint('ifconfig ' + name + '-eth0.' + vif[1] + ' ' + vif[0])
    return ee