Commit ca8cb28a authored by Nikos Skalkotos's avatar Nikos Skalkotos

Merge branch 'release-0.9' into debian-release-0.9

parents 79ba1d5c f29b9240
2015-02-27, v0.9rc2
* Fix a typo that raised an AttributeError exception on *BSD systems
* Fix a bug that broke the VirtIO installation in some cases in Windows
2015-02-24, v0.9rc1
* Add Linux syspreps for disabling the IPv6 privacy extensions and for
changing the boot timeout
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -107,7 +107,7 @@ class Bsd(Unix):
def _get_passworded_users(self):
"""Returns a list of non-locked user accounts"""
if not self.g.is_file('/etc/master.passwd'):
if not self.image.g.is_file('/etc/master.passwd'):
self.out.warn("Unable to collect user info. "
"File: `/etc/master.passwd' is missing!")
return []
......
# -*- coding: utf-8 -*-
#
# Copyright (C) 2011-2014 GRNET S.A.
# Copyright (C) 2011-2015 GRNET S.A.
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
......@@ -235,8 +235,8 @@ class Windows(OSBase):
@add_sysprep_param(
'connection_retries', "posint", 5, DESCR['connection_retries'])
@add_sysprep_param(
'shutdown_timeout', "posint", 120, DESCR['shutdown_timeout'])
@add_sysprep_param('boot_timeout', "posint", 300, DESCR['boot_timeout'])
'shutdown_timeout', "posint", 300, DESCR['shutdown_timeout'])
@add_sysprep_param('boot_timeout', "posint", 600, DESCR['boot_timeout'])
@add_sysprep_param('virtio', 'dir', "", DESCR['virtio'],
check=virtio_dir_check, hidden=True)
@add_sysprep_param(
......@@ -863,7 +863,7 @@ class Windows(OSBase):
return collection
def install_virtio_drivers(self, upgrade=True):
"""Install new VirtIO drivers in the input media. If upgrade is True,
"""Install new VirtIO drivers on the input media. If upgrade is True,
then the old drivers found in the media will be removed.
"""
......@@ -878,9 +878,37 @@ class Windows(OSBase):
self.out.warn('No suitable driver found to install!')
return
remove = []
certs = []
install = []
add = []
# Check which drivers we need to install, which to add to the database
# and which to remove.
for dtype in valid_drvs:
versions = [v['DriverVer'] for k, v in valid_drvs[dtype].items()]
certs.extend([v['CatalogFile'] for k, v in
valid_drvs[dtype].items() if 'CatalogFile' in v])
installed = [(k, v['DriverVer']) for k, v in
self.virtio_state[dtype].items()]
found = [d[0] for d in installed if d[1] in versions]
not_found = [d[0] for d in installed if d[1] not in versions]
for drvr in found:
details = self.virtio_state[dtype][drvr]
self.out.warn('%s driver with version %s is already installed!'
% (dtype, details['DriverVer']))
if upgrade:
remove.extend(not_found)
if dtype == 'viostor':
install.extend([d for d in valid_drvs[dtype]])
else:
add.extend([d for d in valid_drvs[dtype]])
try:
self._upload_virtio_drivers(dirname, valid_drvs, upgrade)
self._boot_virtio_vm()
self._update_driver_database('virtio', upload=dirname, certs=certs,
add=add, install=install,
remove=remove)
finally:
with self.mount(readonly=False, silent=True, fatal=False):
if not self.ismounted:
......@@ -892,39 +920,57 @@ class Windows(OSBase):
self.out.success("VirtIO drivers were successfully installed")
self.out.info()
def _upload_virtio_drivers(self, dirname, drvs, delete_old=True):
"""Upload the VirtIO drivers and installation scripts to the media.
def _update_driver_database(self, namespace, **kwargs):
"""Upload a directory that contains the VirtIO drivers and add scripts
for installing and removing specific drivers.
Keyword arguments:
namespace -- namespace for the cleanup entries
upload -- Host directory that contains drivers to upload
add -- List of drivers to add to the driver database
install -- List of drivers to install to the system
remove -- List of drivers to remove from the system
"""
upload = kwargs['upload'] if 'upload' in kwargs else None
add = kwargs['add'] if 'add' in kwargs else []
install = kwargs['install'] if 'install' in kwargs else []
certs = kwargs['certs'] if 'certs' in kwargs else []
remove = kwargs['remove'] if 'remove' in kwargs else []
assert len(add) == 0 or upload is not None
assert len(install) == 0 or upload is not None
with self.mount(readonly=False, silent=True):
# Reset Password
self._add_cleanup('virtio', self.registry.reset_passwd,
# Reset admin password
self._add_cleanup(namespace, self.registry.reset_passwd,
self.vm.admin.rid,
self.registry.reset_passwd(self.vm.admin.rid))
# Enable admin account (if needed)
self._add_cleanup('virtio', self.registry.reset_account,
self._add_cleanup(namespace, self.registry.reset_account,
self.vm.admin.rid,
self.registry.reset_account(self.vm.admin.rid))
old = self.registry.update_uac(0)
if old != 0:
self._add_cleanup('virtio', self.registry.update_uac, old)
self._add_cleanup(namespace, self.registry.update_uac, old)
old = self.registry.update_noautoupdate(1)
if old != 1:
self._add_cleanup('virtio',
self._add_cleanup(namespace,
self.registry.update_noautoupdate, old)
old = self.registry.update_auoptions(1)
if old != 1:
self._add_cleanup('virtio',
self._add_cleanup(namespace,
self.registry.update_auoptions, old)
# We disable this with powershell scripts
self.registry.enable_autologon(self.vm.admin.name)
# Disable first logon animation (if needed)
self._add_cleanup('virtio',
self._add_cleanup(namespace,
self.registry.reset_first_logon_animation,
self.registry.reset_first_logon_animation(False))
......@@ -940,35 +986,34 @@ class Windows(OSBase):
def remove_tmp():
self.image.g.rm_rf("%s/%s" % (self.systemroot, tmp))
self._add_cleanup('virtio', remove_tmp)
self._add_cleanup(namespace, remove_tmp)
for fname in os.listdir(dirname):
full_path = os.path.join(dirname, fname)
if os.path.isfile(full_path):
self.image.g.upload(
full_path, "%s/%s/%s" % (self.systemroot, tmp, fname))
if upload is not None:
for fname in os.listdir(upload):
full_path = os.path.join(upload, fname)
if os.path.isfile(full_path):
self.image.g.upload(full_path, "%s/%s/%s" %
(self.systemroot, tmp, fname))
drvs_install = powershell.DRVINST_HEAD
for dtype in drvs:
drvs_install += "".join(
[powershell.ADD_CERTIFICATE % d['CatalogFile']
for d in drvs[dtype].values()])
cmd = powershell.ADD_DRIVER if dtype != 'viostor' \
else powershell.INSTALL_DRIVER
drvs_install += "".join([cmd % i for i in drvs[dtype]])
for cert in certs:
drvs_install += powershell.ADD_CERTIFICATE % cert
for driver in install:
drvs_install += powershell.INSTALL_DRIVER % driver
if delete_old:
# Add code to remove the old drivers
for dtype in drvs:
for oem in self.virtio_state[dtype]:
drvs_install += powershell.REMOVE_DRIVER % oem
for driver in add:
drvs_install += powershell.ADD_DRIVER % driver
for driver in remove:
drvs_install += powershell.REMOVE_DRIVER % driver
if self.check_version(6, 1) <= 0:
self._install_viostor_driver(dirname)
self._install_viostor_driver(upload)
old = self.registry.update_devices_dirs("%SystemRoot%\\" + tmp)
self._add_cleanup(
'virtio', self.registry.update_devices_dirs, old, False)
namespace, self.registry.update_devices_dirs, old, False)
drvs_install += powershell.DISABLE_AUTOLOGON
else:
# In newer windows, in order to reduce the boot process the
......@@ -999,6 +1044,9 @@ class Windows(OSBase):
# (*) to force the program to run even in Safe mode.
self.registry.runonce({'*InstallDrivers': cmd})
# Boot the Windows VM to update the driver's database
self._boot_virtio_vm()
def _boot_virtio_vm(self):
"""Boot the media and install the VirtIO drivers"""
......
__version__ = "0.9rc1"
__version__ = "0.9rc2"
__version_vcs_info__ = {
'branch': 'release-0.9',
'revid': '516f525',
'revno': 681}
'revid': '57e48a9',
'revno': 686}
__version_user_email__ = "skalkoto@grnet.gr"
__version_user_name__ = "Nikos Skalkotos"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment