Ejemplo n.º 1
0
 def addEE(self, name, cls=None, **params):
     """Add an EE (Execution Environment).
     name: name of the EE to add
     cls: custom EE class/constructor
     params: optional parameters passed to the VNF
     Returns: added EE"""
     # Default IP and MAC addresses
     defaults = {
         'ip':
         ipAdd(self.nextIP,
               ipBaseNum=self.ipBaseNum,
               prefixLen=self.prefixLen) + '/%s' % self.prefixLen
     }
     if self.autoSetMacs:
         defaults['mac'] = macColonHex(self.nextIP)
     if self.autoPinCpus:
         defaults['cores'] = self.nextCore
         self.nextCore = (self.nextCore + 1) % self.numCores
     self.nextIP += 1
     defaults.update(params)
     if not cls:
         cls = self.ee
     ee = cls(name, **defaults)
     self.ees.append(ee)
     self.nameToNode[name] = ee
     return ee
Ejemplo n.º 2
0
 def addHost( self, name, cls=None, **params ):
     """Add host.  name: name of host to add cls: custom host
        class/constructor (optional) params: parameters for host
        returns: added host"""
     # Default IP and MAC addresses
     defaults = { 'ip': ipAdd( self.nextIP,
                               ipBaseNum=self.ipBaseNum,
                               prefixLen=self.prefixLen ) +
                               '/%s' % self.prefixLen }
     if self.autoSetMacs:
         defaults[ 'mac'] = macColonHex( self.nextIP )
     if self.autoPinCpus:
         defaults[ 'cores' ] = self.nextCore
         self.nextCore = ( self.nextCore + 1 ) % self.numCores
     self.nextIP += 1
     defaults.update( params )
     if not cls:
         cls = self.host
     h = cls( name, **defaults )
     self.hosts.append( h )
     self.nameToNode[ name ] = h
     return h
Ejemplo n.º 3
0
 def addHost(self, name, cls=None, **params):
     """Add host.  name: name of host to add cls: custom host
        class/constructor (optional) params: parameters for host
        returns: added host"""
     # Default IP and MAC addresses
     defaults = {
         'ip':
         ipAdd(self.nextIP,
               ipBaseNum=self.ipBaseNum,
               prefixLen=self.prefixLen) + '/%s' % self.prefixLen
     }
     if self.autoSetMacs:
         defaults['mac'] = macColonHex(self.nextIP)
     if self.autoPinCpus:
         defaults['cores'] = self.nextCore
         self.nextCore = (self.nextCore + 1) % self.numCores
     self.nextIP += 1
     defaults.update(params)
     if not cls:
         cls = self.host
     h = cls(name, **defaults)
     self.hosts.append(h)
     self.nameToNode[name] = h
     return h
Ejemplo n.º 4
0
 def addEE( self, name, cls=None, **params ):
     """Add an EE (Execution Environment).
     name: name of the EE to add
     cls: custom EE class/constructor
     params: optional parameters passed to the VNF
     Returns: added EE"""
     # Default IP and MAC addresses
     defaults = { 'ip': ipAdd( self.nextIP,
                               ipBaseNum=self.ipBaseNum,
                               prefixLen=self.prefixLen ) +
                               '/%s' % self.prefixLen }
     if self.autoSetMacs:
         defaults[ 'mac' ] = macColonHex( self.nextIP )
     if self.autoPinCpus:
         defaults[ 'cores' ] = self.nextCore
         self.nextCore = ( self.nextCore + 1 ) % self.numCores
     self.nextIP += 1
     defaults.update( params )
     if not cls:
         cls = self.ee
     ee = cls( name, **defaults )
     self.ees.append( ee )
     self.nameToNode[ name ] = ee
     return ee