def request_commissioning_results(pod): """Request commissioning results from machines associated with the Pod.""" nodes = yield deferToDatabase(lambda: list(pod.hints.nodes.all())) # Intel RSD and libvirt Pods don't create machines for the host. if not nodes: return pod client_identifiers = yield deferToDatabase(pod.get_client_identifiers) client = yield getClientFromIdentifiers(client_identifiers) for node in nodes: token = yield deferToDatabase(NodeKey.objects.get_token_for_node, node) try: yield send_pod_commissioning_results( client, pod.id, pod.name, pod.power_type, node.system_id, pod.power_parameters, token.consumer.key, token.key, token.secret, urlparse(absolute_reverse("metadata-version", args=["latest"])), ) except PodProblem as e: yield deferToDatabase( Event.objects.create_node_event, node, EVENT_TYPES.NODE_COMMISSIONING_EVENT_FAILED, event_description=str(e), ) return pod
def wrap_compose_machine( client_idents, pod_type, parameters, request, pod_id, name): """Wrapper to get the client.""" d = getClientFromIdentifiers(client_idents) d.addCallback( compose_machine, pod_type, parameters, request, pod_id=pod_id, name=name) return d
def wrap_compose_machine(client_idents, pod_type, parameters, request, pod_id, name): """Wrapper to get the client.""" d = getClientFromIdentifiers(client_idents) d.addCallback( partial(deferToDatabase, transactional(check_over_commit_ratios))) d.addCallback(compose_machine, pod_type, parameters, request, pod_id=pod_id, name=name) return d
def decompose(result): (pod_id, pod_name, pod_type, client_idents, decompose, pre_existing) = result decomposed, updated_hints, error = [], None, None for machine_id, parameters in decompose: # Get a new client for every decompose because we might lose # a connection to a rack during this operation. client = yield getClientFromIdentifiers(client_idents) try: updated_hints = yield decompose_machine(client, pod_type, parameters, pod_id=pod_id, name=pod_name) except PodProblem as exc: error = exc break else: decomposed.append(machine_id) return pod_id, decomposed, pre_existing, error, updated_hints
def decompose(result): (pod_id, pod_name, pod_type, client_idents, decompose, pre_existing) = result decomposed = [] for machine_id, parameters in decompose: # Get a new client for every decompose because we might lose # a connection to a rack during this operation. client = yield getClientFromIdentifiers(client_idents) try: yield decompose_machine(client, pod_type, parameters, pod_id=pod_id, name=pod_name) except PodProblem as exc: # Catch all errors and continue. break finally: # Set the machine to decomposed regardless # if it actually decomposed or not. decomposed.append(machine_id) return pod_id, decomposed, pre_existing