VirtualBox

Changeset 79908 in vbox


Ignore:
Timestamp:
Jul 20, 2019 3:56:15 AM (6 years ago)
Author:
vboxsync
Message:

ValKit: Use IDHCPServer::findLeaseByMAC to resolve VM IP addresses when using host-only networking. This enables us to do unattended ubuntu installs w/o GAs. Reenabled newer ubuntu tests where GAs doesn't quite install yet, adding 19.04. bugref:9151

Location:
trunk/src/VBox/ValidationKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/common/utils.py

    r79279 r79908  
    13521352    return time.time();
    13531353
    1354 
    13551354def timestampNano():
    13561355    """
     
    13761375        return long(_winFloatTime());
    13771376    return long(time.time());
     1377
     1378def secondsSinceUnixEpoch():
     1379    """
     1380    Returns unix time, floating point second count since 1970-01-01T00:00:00Z
     1381    """
     1382    ## ASSUMES This returns unix epoch time on all systems we care about...
     1383    return time.time();
    13781384
    13791385def getTimePrefix():
  • trunk/src/VBox/ValidationKit/testdriver/vboxwrappers.py

    r79245 r79908  
    29582958    #
    29592959
    2960     def txsConnectViaTcp(self, cMsTimeout = 10*60000, sIpAddr = None, sMacAddr = None, fNatForwardingForTxs = False):
     2960    def txsConnectViaTcp(self, cMsTimeout = 10*60000, sIpAddr = None, fNatForwardingForTxs = False):
    29612961        """
    29622962        Connects to the TXS using TCP/IP as transport.  If no IP or MAC is
     
    29682968        fReversedSetup = False;
    29692969        fUseNatForTxs  = False;
     2970        sMacAddr       = None;
     2971        oIDhcpServer   = None;
    29702972        if sIpAddr is None:
    29712973            try:
    2972                 oNic = self.oVM.getNetworkAdapter(0);
    2973                 if oNic.attachmentType == vboxcon.NetworkAttachmentType_NAT:
     2974                oNic              = self.oVM.getNetworkAdapter(0);
     2975                enmAttachmentType = oNic.attachmentType;
     2976                if enmAttachmentType == vboxcon.NetworkAttachmentType_NAT:
    29742977                    fUseNatForTxs = True;
     2978                elif enmAttachmentType == vboxcon.NetworkAttachmentType_HostOnly and not sIpAddr:
     2979                    # Get the MAC address and find the DHCP server.
     2980                    sMacAddr      = oNic.MACAddress;
     2981                    sHostOnlyNIC  = oNic.hostOnlyInterface;
     2982                    oIHostOnlyIf  = self.oVBox.host.findHostNetworkInterfaceByName(sHostOnlyNIC);
     2983                    sHostOnlyNet  = oIHostOnlyIf.networkName;
     2984                    oIDhcpServer  = self.oVBox.findDHCPServerByNetworkName(sHostOnlyNet);
    29752985            except:
    29762986                reporter.errorXcpt();
    29772987                return None;
     2988
    29782989        if fUseNatForTxs:
    29792990            fReversedSetup = not fNatForwardingForTxs;
     
    29822993        # Kick off the task.
    29832994        try:
    2984             oTask = TxsConnectTask(self, cMsTimeout, sIpAddr, sMacAddr, fReversedSetup,
     2995            oTask = TxsConnectTask(self, cMsTimeout, sIpAddr, sMacAddr, oIDhcpServer, fReversedSetup,
    29852996                                   fnProcessEvents = self.oTstDrv.processPendingEvents);
    29862997        except:
     
    30523063
    30533064
    3054     def __init__(self, oSession, cMsTimeout, sIpAddr, sMacAddr, fReversedSetup, fnProcessEvents = None):
    3055         TdTaskBase.__init__(self, utils.getCallerName());
     3065    def __init__(self, oSession, cMsTimeout, sIpAddr, sMacAddr, oIDhcpServer, fReversedSetup, fnProcessEvents = None):
     3066        TdTaskBase.__init__(self, utils.getCallerName(), fnProcessEvents = fnProcessEvents);
    30563067        self.cMsTimeout         = cMsTimeout;
    30573068        self.fnProcessEvents    = fnProcessEvents;
     
    30593070        self.sNextIpAddr        = None;
    30603071        self.sMacAddr           = sMacAddr;
     3072        self.oIDhcpServer       = oIDhcpServer;
    30613073        self.fReversedSetup     = fReversedSetup;
    30623074        self.oVBoxEventHandler  = None;
    30633075        self.oTxsSession        = None;
    30643076
    3065         # Skip things we don't implement.
    3066         if sMacAddr is not None:
    3067             reporter.error('TxsConnectTask does not implement sMacAddr yet');
     3077        # Check that the input makes sense:
     3078        if   (sMacAddr is None) != (oIDhcpServer is None)  \
     3079          or (sMacAddr and fReversedSetup) \
     3080          or (sMacAddr and sIpAddr):
     3081            reporter.error('TxsConnectTask sMacAddr=%s oIDhcpServer=%s sIpAddr=%s fReversedSetup=%s'
     3082                           % (sMacAddr, oIDhcpServer, sIpAddr, fReversedSetup,));
    30683083            raise base.GenError();
    30693084
     
    31003115                if sIpAddr is not None:
    31013116                    self._setIp(sIpAddr);
     3117
     3118            #
     3119            # If the network adapter of the VM is host-only we can talk poll IDHCPServer
     3120            # for the guest IP, allowing us to detect it for VMs without guest additions.
     3121            # This will when we're polled.
     3122            #
     3123            if sMacAddr is not None:
     3124                assert self.oIDhcpServer is not None;
     3125
     3126
    31023127        # end __init__
    31033128
     
    32033228            self._deregisterEventHandler();
    32043229        return True;
     3230
     3231    def _pollDhcpServer(self):
     3232        """
     3233        Polls the DHCP server by MAC address in host-only setups.
     3234        """
     3235
     3236        if self.sIpAddr:
     3237            return False;
     3238
     3239        if self.oIDhcpServer is None or not self.sMacAddr:
     3240            return False;
     3241
     3242        try:
     3243            (sIpAddr, sState, secIssued, secExpire) = self.oIDhcpServer.findLeaseByMAC(self.sMacAddr, 0);
     3244        except:
     3245            reporter.log2Xcpt('sMacAddr=%s' % (self.sMacAddr,));
     3246            return False;
     3247
     3248        secNow = utils.secondsSinceUnixEpoch();
     3249        reporter.log2('dhcp poll: secNow=%s secExpire=%s secIssued=%s sState=%s sIpAddr=%s'
     3250                      % (secNow, secExpire, secIssued, sState, sIpAddr,));
     3251        if secNow > secExpire or sState != 'acked' or not sIpAddr:
     3252            return False;
     3253
     3254        reporter.log('dhcp poll: sIpAddr=%s secExpire=%s (%s TTL) secIssued=%s (%s ago)'
     3255                     % (sIpAddr, secExpire, secExpire - secNow, secIssued, secNow - secIssued,));
     3256        self._setIp(sIpAddr);
     3257        return True;
     3258
     3259    #
     3260    # Task methods
     3261    #
     3262
     3263    def pollTask(self, fLocked = False):
     3264        """
     3265        Overridden pollTask method.
     3266        """
     3267        self._pollDhcpServer();
     3268        return TdTaskBase.pollTask(self, fLocked);
    32053269
    32063270    #
  • trunk/src/VBox/ValidationKit/tests/installation/tdGuestOsUnattendedInst1.py

    r79475 r79908  
    6161    ## @name VM option flags (OR together).
    6262    ## @{
    63     kfUbuntuAvx2Crash       = 0x0001; ## < Disables AVX2 as ubuntu 16.04 think it means AVX512 is available and compiz crashes.
     63    kfUbuntuAvx2Crash       = 0x0001; ##< Disables AVX2 as ubuntu 16.04 think it means AVX512 is available and compiz crashes.
     64    kfNoGAs                 = 0x0002; ##< No guest additions installation possible.
    6465    kfIdeIrqDelay           = 0x1000;
    6566    kfUbuntuNewAmdBug       = 0x2000;
     
    113114        #
    114115        if self.fOptInstallAdditions:
    115             try:    oIUnattended.installGuestAdditions = True;
    116             except: return reporter.errorXcpt();
    117             try:    oIUnattended.additionsIsoPath      = oTestDrv.getGuestAdditionsIso();
    118             except: return reporter.errorXcpt();
    119             oTestDrv.processPendingEvents();
     116            if (self.fInstVmFlags & self.kfNoGAs) == 0:
     117                try:    oIUnattended.installGuestAdditions = True;
     118                except: return reporter.errorXcpt();
     119                try:    oIUnattended.additionsIsoPath      = oTestDrv.getGuestAdditionsIso();
     120                except: return reporter.errorXcpt();
     121                oTestDrv.processPendingEvents();
     122            else:
     123                reporter.log("Warning! Ignoring request to install Guest Additions as kfNoGAs is set!");
    120124
    121125        return True;
     
    405409            ## @todo ubuntu 17.10, 18.04 & 18.10 do not work.  They misses all the the build tools (make, gcc, perl, ++)
    406410            ##       and has signed kmods:
    407             ## @todo Mark these as no-install-additions for the time being?
    408             #UnattendedVm(oSet, 'tst-ubuntu-17.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-17.10-desktop-amd64.iso'), # >4.0Gib
    409             #UnattendedVm(oSet, 'tst-ubuntu-18.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.04-desktop-amd64.iso'), # >5.7GiB
    410             #UnattendedVm(oSet, 'tst-ubuntu-18.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.10-desktop-amd64.iso'),
     411            UnattendedVm(oSet, 'tst-ubuntu-17.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-17.10-desktop-amd64.iso', # >4.0Gib
     412                         UnattendedVm.kfNoGAs),
     413            UnattendedVm(oSet, 'tst-ubuntu-18.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.04-desktop-amd64.iso', # >5.7GiB
     414                         UnattendedVm.kfNoGAs),
     415            # 18.10 hangs reading install DVD during "starting partitioner..."
     416            #UnattendedVm(oSet, 'tst-ubuntu-18.10-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-18.10-desktop-amd64.iso',
     417            #             UnattendedVm.kfNoGAs),
     418            UnattendedVm(oSet, 'tst-ubuntu-19.04-64', 'Ubuntu_64', '6.0/uaisos/ubuntu-19.04-desktop-amd64.iso', # >5.6GiB
     419                         UnattendedVm.kfNoGAs),
    411420        ]);
    412421        self.oTestVmSet = oSet;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette