Ignore:
Timestamp:
Mar 10, 2014 11:12:49 AM (11 years ago)
Author:
Ted Faber <faber@…>
Branches:
master
Children:
a2ca699
Parents:
26821ac (diff), dffa585 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' into shared_nat

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_segment.py

    rdffa585 r4a02274  
    181181            self.do_operation(op, l, p, param, top)
    182182        return True
     183
     184class exports_segment(ssh_emulab_segment, xmlrpc_emulab_segment):
     185    '''
     186    Class to export parameters from this segment.  For a standard segment these
     187    are calculated, so there is no testbed interaction.  For shared-NAT DETER
     188    installations, this is more involved.  This class is a hook for that more
     189    involved setup.
     190    '''
     191    def __init__(self, log=None, keyfile=None, debug=False, boss=None,
     192            ops=None, cert=None):
     193        ssh_emulab_segment.__init__(self, log=log, keyfile=keyfile, debug=debug)
     194        xmlrpc_emulab_segment.__init__(self, boss=boss, ops=ops, cert=cert)
     195
     196    def __call__(self, parent, eid, pid, user, connInfo, tmpdir, timeout=0,
     197            gid=None):
     198        '''
     199        Install the parameter values into each output parameter in each
     200        connInfo entry.  This class understands peer and ssh_port output
     201        variables.
     202        '''
     203
     204        for c in connInfo:
     205            for p in c.get('parameter', []):
     206                # Only set output parameters
     207                if  p.get('type', '') != 'output':
     208                    continue
     209                name = p.get('name', '')
     210                # Debugging output
     211                k = p.get('key', None)
     212                if name == 'peer':
     213                    if parent.nat_portal:
     214                        value = parent.nat_portal
     215                    elif k and k.index('/') != -1:
     216                        value = "%s.%s.%s%s" % \
     217                            (k[k.index('/')+1:], eid, pid, parent.domain)
     218                    else:
     219                        self.log.error("Bad export request: %s" % p)
     220                        continue
     221                    p['value'] = value
     222                    self.log.debug("Assigning %s to %s" % (k, value))
     223                elif name == 'ssh_port':
     224                    value = parent.ssh_port
     225                    p['value'] = value
     226                    self.log.debug("Assigning %s to %s" % (k, value))
     227                else:
     228                    self.log.error("Unknown export parameter: %s" % \
     229                            p.get('name'))
     230                    continue
     231        return True
Note: See TracChangeset for help on using the changeset viewer.