def get_curtin_image(node): """Return boot image that supports 'xinstall' for the given node.""" osystem = node.get_osystem() series = node.get_distro_series() arch, subarch = node.split_arch() rack_controller = node.get_boot_rack_controller() try: images = get_boot_images_for(rack_controller, osystem, arch, subarch, series) except (NoConnectionsAvailable, TimeoutError): logger.error( "Unable to get RPC connection for rack controller '%s' (%s)", rack_controller.hostname, rack_controller.system_id) raise ClusterUnavailable( "Unable to get RPC connection for rack controller '%s' (%s)" % (rack_controller.hostname, rack_controller.system_id)) for image in images: if image['purpose'] == 'xinstall': return image raise MissingBootImage( "Error generating the URL of curtin's image file. " "No image could be found for the given selection: " "os=%s, arch=%s, subarch=%s, series=%s, purpose=xinstall." % ( osystem, arch, subarch, series, ))
def test_returns_boot_images_matching_subarches_in_boot_resources(self): rack = factory.make_RackController() self.useFixture(RunningClusterRPCFixture()) params = self.make_boot_images() param = params.pop() subarches = [factory.make_name("subarch") for _ in range(3)] resource_name = "%s/%s" % (param["osystem"], param["release"]) resource_arch = "%s/%s" % ( param["architecture"], param["subarchitecture"], ) resource = factory.make_BootResource( rtype=BOOT_RESOURCE_TYPE.SYNCED, name=resource_name, architecture=resource_arch, ) extra = resource.extra.copy() extra["subarches"] = ",".join(subarches) resource.extra = extra resource.save() subarch = subarches.pop() self.assertItemsEqual( self.make_rpc_boot_images(param), get_boot_images_for( rack, param["osystem"], param["architecture"], subarch, param["release"], ), )
def get_curtin_image(node): """Return boot image that supports 'xinstall' for the given node.""" osystem = node.get_osystem() series = node.get_distro_series() arch, subarch = node.split_arch() rack_controller = node.get_boot_rack_controller() try: images = get_boot_images_for(rack_controller, osystem, arch, subarch, series) except (NoConnectionsAvailable, TimeoutError): logger.error( "Unable to get RPC connection for rack controller '%s' (%s)", rack_controller.hostname, rack_controller.system_id, ) raise ClusterUnavailable( "Unable to get RPC connection for rack controller '%s' (%s)" % (rack_controller.hostname, rack_controller.system_id)) # A matching subarch may be a newer subarch which contains support for # an older one. e.g Xenial hwe-16.04 will match for ga-16.04. First # try to find the subarch we are deploying, if that isn't found allow # a newer version. for image in images: if (image["purpose"] == "xinstall" and image["subarchitecture"] == subarch): return image for image in images: if image["purpose"] == "xinstall": return image raise MissingBootImage( "Error generating the URL of curtin's image file. " "No image could be found for the given selection: " "os=%s, arch=%s, subarch=%s, series=%s, purpose=xinstall." % (osystem, arch, subarch, series))
def test_returns_boot_images_matching_subarchitecture(self): rack = factory.make_RackController() self.useFixture(RunningClusterRPCFixture()) params = self.make_boot_images() param = params.pop() self.assertItemsEqual( self.make_rpc_boot_images(param), get_boot_images_for(rack, param['osystem'], param['architecture'], param['subarchitecture'], param['release']))