def create_machines()

in hostfactory/host_provider/src/cyclecloud_provider.py [0:0]


    def create_machines(self, input_json):
        """
        input:
        {'rc_account': 'default',
         'template': {'machineCount': 1, 'templateId': 'execute0'},
         'user_data': {}}

        output:
        {'message': 'Request VM from Azure CycleCloud successful.',
         'requestId': 'req-123'}
        """ 
        request_id = str(uuid.uuid4())
        logger.info("Creating requestId %s", request_id)
        if not self.dry_run:
            try:
                # save the request so we can time it out
                with self.creation_json as requests_store:
                    requests_store[request_id] = {"requestTime": calendar.timegm(self.clock()),
                                                "completedNodes": [],
                                                "allNodes": None,
                                                "completed": False}
            except:
                logger.exception("Could not open creation_json")
                sys.exit(1)    
        try:            
            use_weighted_templates = False
            vmTypes = {}
            if self.config.get("symphony.enable_weighted_templates", True):
                pro_conf_dir = os.getenv('PRO_CONF_DIR', os.getcwd())
                conf_path = os.path.join(pro_conf_dir, "conf", "azureccprov_templates.json")
                with open(conf_path, 'r') as json_file:
                    templates_json = json.load(json_file)
                vmTypes = self.weighted_template.parse_weighted_template(input_json, templates_json["templates"])
                logger.debug("Current weightings: %s", ", ".join([f"{x}={y}" for x,y in vmTypes.items()]))
                use_weighted_templates = True 
                request_set = { 'count': input_json["template"]["machineCount"],
                                 'definition':{'templateId':input_json["template"]["templateId"]}} 
            
            # We are grabbing the lock to serialize this call.
            try:
                with self.creation_json as requests_store:
                    template_id = request_set['definition']['templateId']                    
                    requested_slot_count = request_set['count']
                    add_nodes_response = self.cluster.add_nodes(request_id, template_id, requested_slot_count,
                                                                use_weighted_templates, vmTypes,
                                                                self.capacity_limit_timeout,
                                                                self.autoscaling_strategy, self.dry_run)
                if self.dry_run and add_nodes_response:
                    print("Dry run succeeded")
                    exit(0)
            finally:
                request_set['requestId'] = request_id
                self.request_tracker.add_request(request_set) 
            
            if not add_nodes_response:
                raise ValueError("No nodes were created")
            
            logger.info("Create nodes response status: %s  nodes: %s", add_nodes_response.status, [(n.name, n.vm_size) for n in add_nodes_response.nodes])
            
            with self.creation_json as requests_store:
                requests_store[request_id]["allNodes"] = [self.cluster.get_node_id(x) for x in add_nodes_response.nodes]
            
            return self.stdout_handler.handle({"requestId": request_id, "status": RequestStates.running,
                                               "message": "Request instances success from Azure CycleCloud."})

        except (ValueError, UserError) as e:
            logger.exception("Azure CycleCloud experienced an error and the node creation request failed. %s", e)
            return self.stdout_handler.handle({"requestId": request_id, "status": RequestStates.complete_with_error,
                                               "message": "Azure CycleCloud experienced an error: %s" % str(e)})
        except Exception as e:
            logger.exception("Azure CycleCloud experienced an error, though it may have succeeded: %s", e)
            return self.stdout_handler.handle({"requestId": request_id, "status": RequestStates.running,
                                               "message": "Azure CycleCloud experienced an error, though it may have succeeded: %s" % str(e)})