public string Run(string multicastPort = "")
{
string preScripts = "\"";
string postScripts = "\"";
foreach (var script in ImageProfileScript.SearchImageProfileScripts(_imageProfile.Id))
{
if (Convert.ToBoolean(script.RunPre))
preScripts += script.ScriptId + " ";
if (Convert.ToBoolean(script.RunPost))
postScripts += script.ScriptId + " ";
}
postScripts += "\"";
preScripts += "\"";
string sysprepTags = "\"";
foreach (var sysprepTag in ImageProfileSysprepTag.SearchImageProfileSysprepTags(_imageProfile.Id))
sysprepTags += sysprepTag.SysprepId + " ";
sysprepTags = sysprepTags.Trim();
sysprepTags += "\"";
var areFilesToCopy = ImageProfileFileFolder.SearchImageProfileFileFolders(_imageProfile.Id).Any();
//On demand computer may be null if not registered
if (_computer != null)
{
AppendString("computer_name=" + _computer.Name);
AppendString("computer_id=" + _computer.Id);
}
AppendString("image_name=" + _imageProfile.Image.Name);
AppendString("profile_id=" + _imageProfile.Id);
AppendString("server_ip=" + Settings.ServerIp);
AppendString(_direction == "multicast" ? "multicast=true" : "multicast=false");
AppendString("pre_scripts=" + preScripts);
AppendString("post_scripts=" + postScripts);
AppendString("file_copy=" + areFilesToCopy);
AppendString("sysprep_tags=" + sysprepTags);
if (Convert.ToBoolean(_imageProfile.SkipCore))
AppendString("skip_core_download=true");
if (Convert.ToBoolean(_imageProfile.SkipClock))
AppendString("skip_clock=true");
if (Convert.ToBoolean(_imageProfile.WebCancel))
AppendString("web_cancel=true");
AppendString("task_completed_action=" + "\"" + _imageProfile.TaskCompletedAction + "\"");
if (_direction == "pull")
{
//Upload currently only support going to the primary distribution point
AppendString("dp_id=" + DistributionPoint.GetPrimaryDistributionPoint().Id);
//Added for OSX NBI suppport
AppendString("image_direction=pull");
AppendString("osx_target_volume=" + "\"" + _imageProfile.OsxTargetVolume + "\"");
AppendString("image_type=" + _imageProfile.Image.Type);
if (Convert.ToBoolean(_imageProfile.RemoveGPT)) AppendString("remove_gpt_structures=true");
if (Convert.ToBoolean(_imageProfile.SkipShrinkVolumes)) AppendString("skip_shrink_volumes=true");
if (Convert.ToBoolean(_imageProfile.SkipShrinkLvm)) AppendString("skip_shrink_lvm=true");
AppendString("compression_algorithm=" + _imageProfile.Compression);
AppendString("compression_level=-" + _imageProfile.CompressionLevel);
if (Convert.ToBoolean(_imageProfile.UploadSchemaOnly)) AppendString("upload_schema_only=true");
if (_imageProfile.Image.Type == "File" && Convert.ToBoolean(_imageProfile.WimMulticastEnabled)) AppendString("web_wim_args=--pipable");
if (!string.IsNullOrEmpty(_imageProfile.CustomUploadSchema))
{
AppendString("custom_upload_schema=true");
SetCustomSchemaUpload();
}
}
else // push or multicast
{
//Support For on demand
if (_computer != null)
{
AppendString("dp_id=" + Computer.GetDistributionPoint(_computer).Id);
if(!string.IsNullOrEmpty(_computer.CustomAttribute1))
AppendString("cust_attr_1=" + "\"" + _computer.CustomAttribute1 + "\"");
if (!string.IsNullOrEmpty(_computer.CustomAttribute2))
AppendString("cust_attr_2=" + "\"" + _computer.CustomAttribute2 + "\"");
if (!string.IsNullOrEmpty(_computer.CustomAttribute3))
AppendString("cust_attr_3=" + "\"" + _computer.CustomAttribute3 + "\"");
if (!string.IsNullOrEmpty(_computer.CustomAttribute4))
AppendString("cust_attr_4=" + "\"" + _computer.CustomAttribute4 + "\"");
if (!string.IsNullOrEmpty(_computer.CustomAttribute5))
AppendString("cust_attr_5=" + "\"" + _computer.CustomAttribute5 + "\"");
}
else
AppendString("dp_id=" + DistributionPoint.GetPrimaryDistributionPoint().Id);
//Added for OSX NBI suppport
AppendString("image_direction=push");
if (Convert.ToBoolean(_imageProfile.OsxInstallMunki)) AppendString("install_munki=true");
AppendString("osx_target_volume=" + "\"" + _imageProfile.OsxTargetVolume + "\"");
AppendString("munki_repo_url=" + "\"" + _imageProfile.MunkiRepoUrl + "\"");
if(!string.IsNullOrEmpty(_imageProfile.MunkiAuthUsername) && !string.IsNullOrEmpty(_imageProfile.MunkiAuthPassword))
AppendString("munki_requires_auth=true");
if (Convert.ToBoolean(_imageProfile.ChangeName)) AppendString("change_computer_name=true");
if (Convert.ToBoolean(_imageProfile.SkipExpandVolumes)) AppendString("skip_expand_volumes=true");
if (Convert.ToBoolean(_imageProfile.FixBcd)) AppendString("fix_bcd=true");
if (Convert.ToBoolean(_imageProfile.FixBootloader)) AppendString("fix_bootloader=true");
if (Convert.ToBoolean(_imageProfile.ForceDynamicPartitions))
AppendString("force_dynamic_partitions=true");
AppendString(SetPartitionMethod());
if (!string.IsNullOrEmpty(_imageProfile.CustomSchema))
{
AppendString("custom_deploy_schema=true");
SetCustomSchemaDeploy();
}
if (_direction == "multicast")
{
if (Settings.MulticastDecompression == "client") AppendString("decompress_multicast_on_client=true");
AppendString("client_receiver_args=" + "\"" + _imageProfile.ReceiverArguments + "\"");
AppendString("multicast_port=" + multicastPort);
}
}
return _activeTaskArguments.ToString();
}