~doanac/utah/bug1190775

« back to all changes in this revision

Viewing changes to utah/provisioning/vm.py

  • Committer: Max Brustkern
  • Date: 2013-06-12 08:22:52 UTC
  • mfrom: (932.1.17 image-handling)
  • Revision ID: max@canonical.com-20130612082252-75zu6lf6dqtnrqlp
Merged image handling changes

Show diffs side-by-side

added added

removed removed

Lines of Context:
176
176
        if self.image is None:
177
177
            raise UTAHVMProvisioningException(
178
178
                'Image file required for VM installation')
179
 
        self._custominit()
 
179
        self._cmdlinesetup()
180
180
        if autoname:
181
181
            self._namesetup()
182
182
            self._loggerunsetup()
304
304
            'Setting type to qemu in case no hardware virtualization present')
305
305
        xmlt.getroot().set('type', self.emulator)
306
306
        ose = xmlt.find('os')
307
 
        if self.arch == ('i386'):
 
307
        if self.image.arch == ('i386'):
308
308
            ose.find('type').set('arch', 'i686')
309
 
        elif self.arch == ('amd64'):
 
309
        elif self.image.arch == ('amd64'):
310
310
            ose.find('type').set('arch', 'x86_64')
311
311
        else:
312
 
            ose.find('type').set('arch', self.arch)
 
312
            ose.find('type').set('arch', self.image.arch)
313
313
        self.logger.debug('Setting up boot info')
314
314
        for kernele in list(ose.iterfind('kernel')):
315
315
            ose.remove(kernele)
553
553
        self.rsyslog.wait_for_booted(config.boot_steps, self.uuid)
554
554
        try:
555
555
            self.logger.info(
556
 
                'Waiting %d seconds for ping response', self.boottimeout)
557
 
            self.pingpoll(timeout=self.boottimeout)
 
556
                'Waiting %d seconds for ping response', config.boottimeout)
 
557
            self.pingpoll(timeout=config.boottimeout)
558
558
        except UTAHTimeout:
559
559
            # Ignore timeout for ping, since depending on the network
560
560
            # configuration ssh might still work despite of the ping failure.
561
561
            self.logger.warning('Network connectivity (ping) failure')
562
 
        self.sshpoll(timeout=self.boottimeout)
 
562
        self.sshpoll(timeout=config.boottimeout)
563
563
        self.active = True
564
564
 
565
565
 
614
614
        self.execute(
615
615
            "UPDATE machines SET state='destroyed' ""WHERE machineid=?",
616
616
            [machineid])
 
617
 
 
618
 
 
619
def get_vm(**kw):
 
620
    """Return a Machine object for a VM with the passed in arguments.
 
621
 
 
622
    :param kw: All parameters are passed to the Machine constructor
 
623
    :type kw: dict
 
624
 
 
625
    :returns: Appropriately constructed Machine object
 
626
    :rtype: object
 
627
 
 
628
    """
 
629
    inventory = TinySQLiteInventory()
 
630
    return inventory.request(**kw)