def extract_packing_plan(self, topology):
packingPlan = {<EOL>"<STR_LIT:id>": "<STR_LIT>",<EOL>"<STR_LIT>": []<EOL>}<EOL>if not topology.packing_plan:<EOL><INDENT>return packingPlan<EOL><DEDENT>container_plans = topology.packing_plan.container_plans<EOL>containers = []<EOL>for container_plan in container_plans:<EOL><INDENT>instances = []<EOL>for instance_plan in container_plan.instance_plans:<EOL><INDENT>instance_resources = {"<STR_LIT>": instance_plan.resource.cpu,<EOL>"<STR_LIT>": instance_plan.resource.ram,<EOL>"<STR_LIT>": instance_plan.resource.disk}<EOL>instance = {"<STR_LIT>" : instance_plan.component_name,<EOL>"<STR_LIT>" : instance_plan.task_id,<EOL>"<STR_LIT>": instance_plan.component_index,<EOL>"<STR_LIT>": instance_resources}<EOL>instances.append(instance)<EOL><DEDENT>required_resource = {"<STR_LIT>": container_plan.requiredResource.cpu,<EOL>"<STR_LIT>": container_plan.requiredResource.ram,<EOL>"<STR_LIT>": container_plan.requiredResource.disk}<EOL>scheduled_resource = {}<EOL>if container_plan.scheduledResource:<EOL><INDENT>scheduled_resource = {"<STR_LIT>": container_plan.scheduledResource.cpu,<EOL>"<STR_LIT>": container_plan.scheduledResource.ram,<EOL>"<STR_LIT>": container_plan.scheduledResource.disk}<EOL><DEDENT>container = {"<STR_LIT:id>": container_plan.id,<EOL>"<STR_LIT>": instances,<EOL>"<STR_LIT>": required_resource,<EOL>"<STR_LIT>": scheduled_resource}<EOL>containers.append(container)<EOL><DEDENT>packingPlan["<STR_LIT:id>"] = topology.packing_plan.id<EOL>packingPlan["<STR_LIT>"] = containers<EOL>return json.dumps(packingPlan)<EOL>
Returns the representation of packing plan that will
be returned from Tracker.