|
| 1 | +# Copyright (C) 2023 Canonical |
| 2 | +# |
| 3 | +# This program is free software: you can redistribute it and/or modify |
| 4 | +# it under the terms of the GNU General Public License as published by |
| 5 | +# the Free Software Foundation, either version 3 of the License. |
| 6 | +# |
| 7 | +# This program is distributed in the hope that it will be useful, |
| 8 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 10 | +# GNU General Public License for more details. |
| 11 | +# |
| 12 | +# You should have received a copy of the GNU General Public License |
| 13 | +# along with this program. If not, see <http://www.gnu.org/licenses/>. |
| 14 | + |
| 15 | +""" |
| 16 | +Ubuntu OEM Recovery Provisioning for HP OEM devices |
| 17 | +Use this for systems that can use the oem recovery-from-iso.sh script |
| 18 | +for provisioning, but require the --ubr flag in order to use the |
| 19 | +"ubuntu recovery" method. |
| 20 | +""" |
| 21 | + |
| 22 | +import logging |
| 23 | + |
| 24 | +import yaml |
| 25 | + |
| 26 | +import testflinger_device_connectors |
| 27 | +from testflinger_device_connectors import logmsg |
| 28 | +from testflinger_device_connectors.devices import ( |
| 29 | + DefaultDevice, |
| 30 | + RecoveryError, |
| 31 | + catch, |
| 32 | +) |
| 33 | +from .hp_oemscript import HPOemScript |
| 34 | + |
| 35 | +device_name = "hp_oemscript" |
| 36 | + |
| 37 | + |
| 38 | +class DeviceConnector(DefaultDevice): |
| 39 | + |
| 40 | + """Tool for provisioning HP OEM devices with an oem image.""" |
| 41 | + |
| 42 | + @catch(RecoveryError, 46) |
| 43 | + def provision(self, args): |
| 44 | + """Method called when the command is invoked.""" |
| 45 | + with open(args.config) as configfile: |
| 46 | + config = yaml.safe_load(configfile) |
| 47 | + testflinger_device_connectors.configure_logging(config) |
| 48 | + device = HPOemScript(args.config, args.job_data) |
| 49 | + logmsg(logging.INFO, "BEGIN provision") |
| 50 | + logmsg(logging.INFO, "Provisioning device") |
| 51 | + device.provision() |
| 52 | + logmsg(logging.INFO, "END provision") |
0 commit comments