Previous Topic: Creating a Software ContainerNext Topic: Sealing and Activating a Job


Creating a Software Job

You are now ready to create a software job designed to deliver your software package. You need to know the UUID of the new container, the UUID of the package procedure, and the UUIDs of all the units and groups to which you wish to deliver the job.

Example 10: Creating an Installation Job

//This method sets up the software job for the package's procedure in
//the newly created container, ready to go!
private int createJob() throws Exception
{
	CreateSoftwareJobOrderProperties props = new CreateSoftwareJobOrderProperties();
		
	//set the boot mask for the job
	SoftwareJobBootMask mask = new SoftwareJobBootMask();
	mask.setNoReboot(true);
	props.setBootAfterMask(mask);
	props.setBootBeforeMask(mask);
	props.setBootAfterMaskSupplied(true);
	props.setBootBeforeMaskSupplied(true);
		
	//set the job's own properties
	props.setJobName(cfg.getJobName());
	props.setJobNameSupplied(true);
		
	//set the operation mask
	SoftwareJobOperationMask opMsk = new SoftwareJobOperationMask();
	opMsk.setAutoDeliverItem(true);
	opMsk.setOffline(false);
	props.setOperationMask(opMsk);
	props.setOperationMaskSupplied(true);
		
	//additional set-up properties mainly to do with execution time
	props.setPromptTimeoutHours(21l);
	props.setPromptTimeoutHoursSupplied(true);
	props.setStartWhenSupplied(true);
	props.setStartWhen(SoftwareJobStartupTime.value2);//local-time
	props.setTimeoutHours(21l);
	props.setTimeoutHoursSupplied(true);
	props.setUserParametersSupplied(false);
	props.setDeliveryDateTime(getADateTime());
	props.setDeliveryDateTimeSupplied(true);
	DateTime dt = getADateTime();
	dt.setMinute(dt.getMinute()+10);
	props.setExecutionDate(dt);
	props.setExecutionDateSupplied(true);
	props.setUserParametersSupplied(false);
		
	String unitIds[] = new String[1];
	String groupIds[] = new String[1];
	String instIds[] = { "" };
		
	// target is a single unit
	unitIds[0] = computerId;
	groupIds[0] = "";
		
	jobId =.wsAPIconnector.createInstallSoftwareJob(
			getSessionId(),
			packager.getProcedureID(),
			props,
			containerId,
			unitIds,
			groupIds);
		
	if(jobId.equals(""))
		return UDSMWebService.JOB_CREATION_ERROR;
			
	return UDSMWebService.RESULT_OK;
}