def install_guest_additions(self): """ Installs guest additions into the VM. """ log.info('Installing guest additions...') manage.load_dvd(self._vbox.name, manage.guest_additions_iso) mount_point = '/media/cdrom' sudo(clom.mkdir(mount_point, p=True)) with settings(warn_only=True): r = sudo(clom.mountpoint(mount_point)) if r.return_code == 0: sudo(clom.umount(mount_point)) sudo(clom.mount('/dev/cdrom', mount_point)) with cd(mount_point): sudo(clom.sh('VBoxLinuxAdditions.run')) sudo(clom.umount(mount_point)) log.warn('It is OK if "Installing the Window System" failed.') manage.eject_dvd(self._vbox.name)
def install_guest_additions(self, **kwargs): """ Installs guest additions into the VM. """ puts('Installing guest additions...') dvd = manage.load_dvd(self.id, manage.guest_additions_iso, **kwargs) mount_point = '/media/cdrom' sudo(clom.mkdir(mount_point, p=True)) with settings(warn_only=True): # See if the directory is mounted r = sudo(clom.mountpoint(mount_point)) if r.return_code == 0: # Directory is mounted, unmount sudo(clom.umount(mount_point)) with settings(warn_only=True): tries = 0 while tries < 3: r = sudo(clom.mount('/dev/cdrom', mount_point)) if r.return_code == 0: # Mounted break else: # cdrom busy, try again tries +=1 time.sleep(5) with cd(mount_point): with settings(warn_only=True): # We ignore errors because X11 install may fail if X11 isn't availible # TODO Ignore certain failures but not all sudo(clom.sh()['VBoxLinuxAdditions.run']('force')) puts('It is OK if "Installing the Window System" failed.') sudo(clom.umount(mount_point)) dvd.eject() # Fix it so the correct version is reported when VM starts # see https://groups.google.com/forum/?fromgroups=#!topic/vagrant-up/L2wEF5dHP9g product = manage.guestproperty(self.id, '/VirtualBox/GuestInfo/OS/Product') manage.guestproperty(self.id, '/VirtualBox/GuestInfo/OS/Product', product)