Ignore:
Timestamp:
Dec 1, 2011 5:10:32 PM (12 years ago)
Author:
Ted Faber <faber@…>
Branches:
compt_changes, info-ops, master
Children:
7f57435
Parents:
32b4536
Message:

Track initial state image name; move attributes into emulab_access:
namespace

File:
1 edited

Legend:

Unmodified
Added
Removed
  • fedd/federation/emulab_access.py

    r32b4536 rcebcdce  
    10321032                if a not in attr: attr.append(a)
    10331033
     1034        def merge_os(os, e):
     1035            if len(e.os) == 0:
     1036                # No OS at all:
     1037                if os.get_attribute('emulab_access:image'):
     1038                    os.set_attribute('emulab_access:initial_image',
     1039                            os.get_attribute('emulab_access:image'))
     1040                e.os = [ os ]
     1041            elif len(e.os) == 1:
     1042                # There's one OS, copy the initial image and replace
     1043                eos = e.os[0]
     1044                initial = eos.get_attribute('emulab_access:initial_image')
     1045                if initial:
     1046                    os.set_attribute('emulab_access:initial_image', initial)
     1047                e.os = [ os]
     1048            else:
     1049                # Multiple OSes, replace or append
     1050                for eos in e.os:
     1051                    if os.name == eos.name:
     1052                        eos.version = os.version
     1053                        eos.version = os.distribution
     1054                        eos.version = os.distributionversion
     1055                        for a in os.attribute:
     1056                            if eos.get_attribute(a.attribute):
     1057                                eos.remove_attribute(a.attribute)
     1058                            eos.set_attribute(a.attribute, a.value)
     1059                        break
     1060                else:
     1061                    e.os.append(os)
     1062
     1063
     1064        if t is None: return
    10341065        # Copy the assigned names into the return topology
    10351066        for e in t.elements:
     
    10421073                        e.status = info.node[e.name].status
    10431074                        os = info.node[e.name].getOS()
    1044                         if os: e.os = [ os ]
     1075                        if os: merge_os(os, e)
    10451076                else:
    10461077                    # Simple debugging assignment
Note: See TracChangeset for help on using the changeset viewer.