| OLD | NEW |
| 1 import logging | 1 import logging |
| 2 import socket | 2 import socket |
| 3 from urlparse import urljoin | 3 from urlparse import urljoin |
| 4 | 4 |
| 5 from autotest_lib.client.common_lib import error | 5 from autotest_lib.client.common_lib import error |
| 6 from autotest_lib.server import autoserv_parser | 6 from autotest_lib.server import autoserv_parser |
| 7 from autotest_lib.server.hosts import base_classes | 7 from autotest_lib.server.hosts import base_classes |
| 8 | 8 |
| 9 | 9 |
| 10 parser = autoserv_parser.autoserv_parser | 10 parser = autoserv_parser.autoserv_parser |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 Construct a ChromiumOSHost object | 27 Construct a ChromiumOSHost object |
| 28 | 28 |
| 29 Args: | 29 Args: |
| 30 hostname: network hostname or address of remote machine | 30 hostname: network hostname or address of remote machine |
| 31 """ | 31 """ |
| 32 super(ChromiumOSHost, self)._initialize(hostname, *args, **dargs) | 32 super(ChromiumOSHost, self)._initialize(hostname, *args, **dargs) |
| 33 | 33 |
| 34 | 34 |
| 35 def machine_install(self, update_url=None, biosflash=None): | 35 def machine_install(self, update_url=None, biosflash=None): |
| 36 image = parser.options.image | 36 image = parser.options.image |
| 37 version_string = None |
| 37 if image: | 38 if image: |
| 38 #TODO(seano): set version, deal with blank version elsewhere | 39 #TODO(seano): set version, deal with blank version elsewhere |
| 39 logging.info('Install %s to host: %s' % (image, self.hostname)) | 40 logging.info('Install %s to host: %s' % (image, self.hostname)) |
| 40 version_string = image | 41 version_string = image |
| 41 else: | 42 else: |
| 42 logging.info('Install %s to host: %s' % ('latest', self.hostname)) | 43 logging.info('Install %s to host: %s' % ('latest', self.hostname)) |
| 43 | 44 |
| 44 if not update_url: | 45 if not update_url: |
| 45 # Assume we're running the mock autoupdate server on the | 46 # Assume we're running the mock autoupdate server on the |
| 46 # autotest host. | 47 # autotest host. |
| 47 update_url = 'http://%s:8080/update/' % socket.gethostname() | 48 update_url = 'http://%s:8080/update' % socket.gethostname() |
| 48 # The mock autoupdater in devserver has been modified to | 49 # The mock autoupdater in devserver has been modified to |
| 49 # accept an additional url under /update/VERSION | 50 # accept an additional url under /update/VERSION |
| 50 update_url = urljoin(update_url, version_string) | 51 if version_string: |
| 52 update_url = urljoin(update_url, 'update/%s' % version_string) |
| 51 | 53 |
| 52 # Prepare to host a update image. | 54 # Prepare to host a update image. |
| 53 # Check that a devserver is available on our preferred URL. | 55 # Check that a devserver is available on our preferred URL. |
| 54 # Check that requested image version exists. | 56 # Check that requested image version exists. |
| 55 | 57 |
| 56 # Run autoupdate command. This tells the autoupdate process on | 58 # Run autoupdate command. This tells the autoupdate process on |
| 57 # the host to look for an update at a specific URL and version | 59 # the host to look for an update at a specific URL and version |
| 58 # string. | 60 # string. |
| 59 | 61 |
| 60 # TODO(seano): remove reconfig_cmd, change autoupdate_cmd to use | 62 # TODO(seano): remove reconfig_cmd, change autoupdate_cmd to use |
| 61 # memento_updater's flags | 63 # memento_updater's flags |
| 62 reconfig_cmd = ('sudo mount -o remount,rw /;' | 64 autoupdate_cmd = [UPDATER_BIN, '--omaha_url=%s' % update_url, |
| 63 'echo "CHROMEOS_AUSERVER=%s" >> %s; ' % | 65 '--force_update'] |
| 64 (update_url, UPDATER_CONFIG)) | |
| 65 | |
| 66 autoupdate_cmd = [reconfig_cmd, UPDATER_BIN, '-f'] | |
| 67 if version_string: | |
| 68 autoupdate_cmd += ['-v', version_string] | |
| 69 try: | 66 try: |
| 70 cmd = ' '.join(autoupdate_cmd) | 67 cmd = ' '.join(autoupdate_cmd) |
| 71 logging.info(cmd) | 68 logging.info(cmd) |
| 72 self.run(cmd) | 69 self.run(cmd) |
| 73 except error.AutoservRunError, e: | 70 except error.AutoservRunError, e: |
| 74 raise ChromiumOSError('OS Updater failed on %s', self.hostname) | 71 raise ChromiumOSError('OS Updater failed on %s', self.hostname) |
| 75 | |
| 76 # Now, check that the installer completed as expected. | 72 # Now, check that the installer completed as expected. |
| 77 try: | 73 try: |
| 78 cmd = '' | 74 cmd = '' |
| 79 #self.run(cmd) | 75 #self.run(cmd) |
| 80 except error.AutoservRunError, e: | 76 except error.AutoservRunError, e: |
| 81 raise ChromiumOSError('Failed to install OS image to host %s', | 77 raise ChromiumOSError('Failed to install OS image to host %s', |
| 82 self.hostname) | 78 self.hostname) |
| 83 | |
| 84 # Updater has returned. reboot. | 79 # Updater has returned. reboot. |
| 85 self.reboot(timeout=30, wait=True) | 80 self.reboot(timeout=30, wait=True) |
| 86 # TODO(seano): verify that image version is in fact installed, | 81 # TODO(seano): verify that image version is in fact installed, |
| 87 # after reboot. | 82 # after reboot. |
| 88 | 83 |
| 89 | 84 |
| 90 def reset(self): | 85 def reset(self): |
| 91 """Reboots the machine.""" | 86 """Reboots the machine.""" |
| 92 try: | 87 try: |
| 93 self.reboot(wait=False) | 88 self.reboot(wait=False) |
| 94 except error.AutoservRunError: | 89 except error.AutoservRunError: |
| 95 # TODO(seano): figure out possible hard resets. | 90 # TODO(seano): figure out possible hard resets. |
| 96 raise | 91 raise |
| OLD | NEW |