Changeset 5b74b63


Ignore:
Timestamp:
Feb 20, 2010 12:07:17 PM (14 years ago)
Author:
Ted Faber <faber@…>
Branches:
axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
Children:
39ee3cc
Parents:
2fdf4b3
Message:

Initial commit of support for transit connection info

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/experiment_control.py

    r2fdf4b3 r5b74b63  
    923923            try:
    924924                self.log.debug("Calling StartSegment at %s " % uri)
     925                print req
    925926                r = self.caller(uri, req, self.cert_file, self.cert_pwd,
    926927                        self.trusted_certs)
     
    13241325
    13251326    def new_portal_node(self, st, dt, tbparams, master, eid, myname, desthost,
    1326             portal_type, iface_desc=()):
     1327            portal_type, iface_desc=(), conn_type="ssh", conn_attrs=[]):
    13271328        """
    13281329        Return a new internet portal node and a dict with the connectionInfo to
     
    13441345        for sub, attrs in iface_desc:
    13451346            inf = topdl.Interface(
     1347                    name="inf%03d" % len(ifaces),
    13461348                    substrate=sub,
    13471349                    attribute=[
     
    13541356            ifaces.append(inf)
    13551357        info = {
    1356                 "type" : "ssh",
     1358                "type" : conn_type,
    13571359                "portal": myname,
    1358                 'peer': "%s.%s.%s%s" %  (desthost.lower(), eid.lower(),
    1359                             dproject.lower(), ddomain.lower()),
     1360                'peer': desthost,
    13601361                'fedAttr': [
    13611362                        { 'attribute': 'masterdomain', 'value': mdomain},
     
    13681369                    ],
    13691370                }
     1371
     1372        if conn_type == 'transit':
     1373            info['member'] = [ { 'element': myname, 'interface': 'inf000'} ]
     1374        if conn_attrs:
     1375            info['fedAttr'].extend(con_attrs)
     1376
    13701377        return (topdl.Computer(
    13711378                name=myname,
     
    14471454                        )
    14481455
    1449     def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid):
     1456    def create_dragon_substrate(self, sub, topo, tbs, tbparams, master, eid,
     1457            connInfo):
    14501458        """
    14511459        Add attribiutes to the various elements indicating that they are to be
    1452         dragon connected and create a dragon segment in tops to be
     1460        dragon connected and create a dragon segment in topo to be
    14531461        instantiated.
    14541462        """
     
    14591467            else: return None
    14601468
     1469        # dn is the number of previously created dragon nets.  This routine
     1470        # creates a net numbered by dn
    14611471        dn = len([x for x in topo.keys() if x.startswith('dragon')])
    1462         elements = [ i.element for i in sub.interfaces ]
     1472        # Count the number of interfaces on this substrate in each testbed from
     1473        # the global topology
    14631474        count = { }
    1464         for e in elements:
     1475        for e in [ i.element for i in sub.interfaces ]:
    14651476            tb = e.get_attribute('testbed')
    14661477            count[tb] = count.get(tb, 0) + 1
    14671478
     1479        # Set the attributes in the copies that will allow setup of dragon
     1480        # connections.
    14681481        for tb in tbs.keys():
    14691482            s = get_substrate_from_topo(sub.name, topo[tb])
    14701483            if s:
    1471                 for i in s.interfaces:
    1472                     i.set_attribute('dragon_vlan', 'unassigned%d' % dn)
    1473                     if count[tb] > 1: i.set_attribute('dragon_type', 'lan')
    1474                     else: i.set_attribute('dragon_type', 'link')
     1484                if not connInfo.has_key(tb):
     1485                    connInfo[tb] = [ ]
     1486                info = {
     1487                        'type': 'transit',
     1488                        'member': [ {
     1489                            'element': i.element.name[0],
     1490                            'interface': i.name
     1491                            } for i in s.interfaces ],
     1492                        'fedAttr': [ {
     1493                            'attribute': 'vlan_id',
     1494                            'value': 'unassigned%d' % dn
     1495                            } ]
     1496                        }
     1497                connInfo[tb].append(info)
    14751498            else:
    14761499                raise service_error(service_error.internal,
     
    15301553                        portal_type = "experiment"
    15311554                        myname = "%stunnel%d" % (dt, len(portals[st][dt]))
    1532                         desthost = "%stunnel%d" % (st, len(portals[st][dt]))
     1555                        desthost = "%stunnel%d.%s.%s%s" % (st,
     1556                                len(portals[st][dt]), eid.lower(),
     1557                                dproject.lower(), ddomain.lower())
    15331558                    else:
    15341559                        new_i = topdl.Interface(
     
    15471572                    portals[st][dt] = [ ]
    15481573                    myname = "%stunnel%d" % (dt, len(portals[st][dt]))
    1549                     desthost = "%stunnel%d" % (st, len(portals[st][dt]))
     1574                    desthost = "%stunnel%d.%s.%s%s" % (st.lower(),
     1575                            len(portals[st][dt]), eid.lower(),
     1576                            dproject.lower(), ddomain.lower())
    15501577
    15511578                    if dt == master or st == master: portal_type = "both"
     
    15991626        desthost = "%s" % ip_addr(dip)
    16001627
    1601         portal = self.new_portal_node(st, dt, tbparams, master,
     1628        portal, info = self.new_portal_node(st, dt, tbparams, master,
    16021629                eid, myname, desthost, "control",
    16031630                ((substrate.name,(
    16041631                    ('portal','true'),
    1605                     ('ip4_address', "%s" % ip_addr(myip)),
    1606                     ('dragon_vlan', 'unassigned%d' % idx),
    1607                     ('dragon_type', 'link'),)),))
     1632                    ('ip4_address', "%s" % ip_addr(myip)),)),),
     1633                conn_type="transit",
     1634                conn_attrs = [ {
     1635                    'attribute': 'vlan_id', 'value': 'unassigned%d' % idx
     1636                    }])
    16081637        if self.fedkit:
    16091638            self.add_kit(portal, self.fedkit)
     
    16111640            self.add_kit(portal, self.gatewaykit)
    16121641
    1613         return portal
     1642        return portal, info
    16141643
    16151644    def add_portals(self, top, topo, eid, master, tbparams, ip_allocator,
     
    16401669                    all([tbparams[x].has_key('dragon') for x in tbs]):
    16411670                self.create_dragon_substrate(s, topo, tbs, tbparams,
    1642                         master, eid)
     1671                        master, eid, connInfo)
    16431672            else:
    16441673                self.insert_internet_portals(s, topo, tbs, tbparams, master,
     
    16921721                                ],
    16931722                            )
     1723                    portal, info = self.new_dragon_portal(tb, master,
     1724                            master, eid, dip, mip, idx, csub, tbparams)
    16941725                    topo[tb].substrates.append(csub)
    1695                     topo[tb].elements.append(
    1696                             self.new_dragon_portal(tb, master, master, eid,
    1697                                 dip, mip, idx, csub, tbparams))
     1726                    topo[tb].elements.append(portal)
    16981727                    topo[tb].elements.append(seg)
     1728                    if not connInfo.has_key(tb):
     1729                        connInfo[tb] = [info]
     1730                    else:
     1731                        connInfo[tb].append(info)
    16991732
    17001733                    mcsub = csub.clone()
     
    17191752                                ],
    17201753                            )
     1754                    portal, info = self.new_dragon_portal(master, tb, master,
     1755                            eid, mip, dip, idx, mcsub, tbparams)
    17211756                    topo[master].substrates.append(mcsub)
    1722                     topo[master].elements.append(
    1723                             self.new_dragon_portal(master, tb, master, eid,
    1724                                 mip, dip, idx, mcsub, tbparams))
     1757                    topo[master].elements.append(portal)
    17251758                    topo[master].elements.append(seg)
     1759                    if not connInfo.has_key(master):
     1760                        connInfo[master] = [info]
     1761                    else:
     1762                        connInfo[master].append(info)
    17261763
    17271764                    self.create_dragon_substrate(csub, topo,
  • fedd/federation/topdl.py

    r2fdf4b3 r5b74b63  
    5555
    5656class ConsistencyError(RuntimeError): pass
     57class NamespaceError(RuntimeError): pass
    5758
    5859class Attribute(base):
     
    199200
    200201class Interface(base):
    201     def __init__(self, substrate, capacity=None, latency=None, attribute=[],
    202             element=None):
     202    def __init__(self, substrate, name=None, capacity=None, latency=None,
     203            attribute=[], element=None):
     204        self.name = name
    203205        self.substrate = self.make_list(substrate)
    204206        self.capacity = self.init_class(Capacity, capacity)
     
    216218        else: l = None
    217219
    218         return Interface(substrate=self.substrate,
     220        return Interface(substrate=self.substrate, name=self.name,
    219221                capacity=c, latency=l,
    220222                attribute = [ a.clone() for a in self.attribute])
    221223
    222224    def to_dict(self):
    223         rv = { 'substrate': self.substrate }
     225        rv = { 'substrate': self.substrate, 'name': self.name }
    224226        if self.capacity:
    225227            rv['capacity'] = self.capacity.to_dict()
     
    403405        self.incorporate_elements()
    404406
     407    @staticmethod
     408    def name_element_interfaces(e):
     409        names = set([i.name for i in e.interface if i.name])
     410        inum = 0
     411        for i in [ i for i in e.interface if not i.name]:
     412            while inum < 1000:
     413                n = "inf%03d" % inum
     414                inum += 1
     415                if n not in names:
     416                    i.name = n
     417                    break
     418            else:
     419                raise NamespaceError("Cannot make new interface name")
     420
     421
     422
     423    def name_interfaces(self):
     424        """
     425        For any interface without a name attribute, assign a unique one within
     426        its element.
     427        """
     428
     429        for e in self.elements:
     430            self.name_element_interfaces(e)
     431
     432
    405433    def incorporate_elements(self):
    406434
     
    416444
    417445        for e in self.elements:
     446            self.name_element_interfaces(e)
    418447            for i in e.interface:
    419448                i.element = e
     
    781810        out += '\t\t<node_type type_name="%s" slots="%s"/>\n' % (hw, slots)
    782811        for i, ii in enumerate(e.interface):
    783             iname = "if%03d" % i
    784             out += '\t\t<interface virtual_id="%s"/>\n' % iname
    785             ifname[ii] = iname
     812            out += '\t\t<interface virtual_id="%s"/>\n' % ii.name
    786813            ifnode[ii] = name
    787814        for f in filters:
     
    797824        for ii in s.interfaces:
    798825            out += ('\t\t<interface_ref virtual_node_id="%s"' + \
    799                     'virtual_interface_id="%s"/>\n') % (ifnode[ii], ifname[ii])
     826                    'virtual_interface_id="%s"/>\n') % (ifnode[ii], ii.name)
    800827        for f in filters:
    801828            out += f(s)
  • wsdl/fedd_types.xsd

    r2fdf4b3 r5b74b63  
    355355  </xsd:simpleType>
    356356
     357  <xsd:complexType name="memberType">
     358    <xsd:annotation>
     359      <xsd:documentation>
     360        A member of a set of nodes for which transit is being provided
     361      </xsd:documentation>
     362    </xsd:annotation>
     363    <xsd:sequence>
     364      <xsd:element name="element" type="xsd:string"/>
     365      <xsd:element name="interface" type="xsd:string" minOccurs="0"
     366        maxOccurs="1"/>
     367    </xsd:sequence>
     368  </xsd:complexType>
     369
    357370  <xsd:complexType name="connectionInfoType">
    358371    <xsd:annotation>
     
    367380      <xsd:element name="portal" type="xsd:string" minOccurs="0" maxOccurs="1"/>
    368381      <xsd:element name="peer" type="xsd:string" minOccurs="0" maxOccurs="1"/>
     382      <xsd:element name="member" type="tns:memberType" minOccurs="0"
     383        maxOccurs="unbounded" />
    369384      <xsd:element name="fedAttr" type="tns:fedAttrType" minOccurs="0"
    370385        maxOccurs="unbounded"/>
  • wsdl/topdl.xsd

    r2fdf4b3 r5b74b63  
    167167      <xsd:element name="substrate" type="xsd:string" minOccurs="1"
    168168        maxOccurs="unbounded"/>
     169      <xsd:element name="name" type="xsd:string" />
    169170      <xsd:element name="capacity" type="tns:capacityType"
    170171        minOccurs="0" maxOccurs="1"/>
Note: See TracChangeset for help on using the changeset viewer.