def _StartInstance(self, instance_name, role):

    logging.info('Starting instance: %s', instance_name)

    rpckey = str(uuid.uuid4())

    metadata = {
        'startup-script-url': '%s/%s' % (
            self._GetTmpCloudStorage(), self.COMPUTE_STARTUP_SCRIPT),
        'rpckey': rpckey,
        'hostname-prefix': self.prefix,
        'num-workers': self.num_workers,
        'hadoop-master': self.master_name,
        'hadoop-worker-template': self.worker_name_template,
        'tmp-cloud-storage': self._GetTmpCloudStorage(),
        'custom-command': self.custom_command,
        'hadoop-patch': self.HADOOP_PATCH,
    }

    if role not in self.INSTANCE_ROLES:
      raise ClusterSetUpError('Invalid instance role name: %s' % role)
    for command in self.INSTANCE_ROLES[role]:
      metadata[command] = 1

    logging.info('Create instance: %s', instance_name)
    if not self._GetApi().CreateInstanceWithNewPersistentBootDisk(
        instance_name,
        self.network,
        self.machinetype,
        self.image,
        # startup_script=self.startup_script,
        service_accounts=[
            'https://www.googleapis.com/auth/devstorage.full_control'],
        metadata=metadata):
      raise ClusterSetUpError('Failed to start instance %s' % instance_name)
    instance_status = datastore.InstanceInfo(
        parent=self.cluster_info.key, name=instance_name, role=role,
        rpckey=rpckey)
    instance_status.put()
    if role == 'master':
      self.cluster_info.SetMasterInstance(instance_status)
    self.instances[instance_name] = instance_status
Starts single Compute Engine instance with a new persistent boot disk.
dataset/ETHPy150Open GoogleCloudPlatform/Data-Pipeline/app/src/hadoop/hadoop_cluster.py/HadoopCluster._StartInstance