public ImageSchemaFEServices(ImageSchemaRequestDTO schemaRequest) { string schema = null; //Only To display the main image specs file when not using a profile. if (schemaRequest.image != null) { schema = new FilesystemServices().ReadSchemaFile(schemaRequest.image.Name); } if (schemaRequest.imageProfile != null) { if (!string.IsNullOrEmpty(schemaRequest.imageProfile.CustomSchema) && schemaRequest.schemaType == "deploy") { schema = schemaRequest.imageProfile.CustomSchema; } else if (!string.IsNullOrEmpty(schemaRequest.imageProfile.CustomUploadSchema) && schemaRequest.schemaType == "upload") { schema = schemaRequest.imageProfile.CustomUploadSchema; } else { schema = new FilesystemServices().ReadSchemaFile(schemaRequest.imageProfile.Image.Name); } } if (!string.IsNullOrEmpty(schema)) { _imageSchema = JsonConvert.DeserializeObject <ImageSchemaGridView>(schema); } }
private void SetCustomSchemaUpload() { var imageSchemaRequest = new ImageSchemaRequestDTO(); imageSchemaRequest.imageProfile = _imageProfile; imageSchemaRequest.schemaType = "upload"; var customSchema = new ImageSchemaFEServices(imageSchemaRequest).GetImageSchema(); var customHardDrives = new StringBuilder(); customHardDrives.Append("custom_hard_drives=\""); var customPartitions = new StringBuilder(); customPartitions.Append("custom_partitions=\""); var customFixedPartitions = new StringBuilder(); customFixedPartitions.Append("custom_fixed_partitions=\""); var customLogicalVolumes = new StringBuilder(); customLogicalVolumes.Append("custom_logical_volumes=\""); var customFixedLogicalVolumes = new StringBuilder(); customFixedLogicalVolumes.Append("custom_fixed_logical_volumes=\""); foreach (var hd in customSchema.HardDrives.Where(x => x.Active)) { customHardDrives.Append(hd.Name + " "); foreach (var partition in hd.Partitions.Where(x => x.Active)) { customPartitions.Append(hd.Name + partition.Prefix + partition.Number + " "); if (partition.ForceFixedSize) { customFixedPartitions.Append(hd.Name + partition.Prefix + partition.Number + " "); } if (partition.VolumeGroup.LogicalVolumes != null) { foreach ( var logicalVolume in partition.VolumeGroup.LogicalVolumes.Where(x => x.Active)) { var vgName = partition.VolumeGroup.Name.Replace("-", "--"); var lvName = logicalVolume.Name.Replace("-", "--"); customLogicalVolumes.Append(vgName + "-" + lvName + " "); if (logicalVolume.ForceFixedSize) { customFixedLogicalVolumes.Append(vgName + "-" + lvName + " "); } } } } } customHardDrives.Append("\""); customPartitions.Append("\""); customFixedPartitions.Append("\""); customLogicalVolumes.Append("\""); customFixedLogicalVolumes.Append("\""); AppendString(customHardDrives.ToString()); AppendString(customPartitions.ToString()); AppendString(customFixedPartitions.ToString()); AppendString(customLogicalVolumes.ToString()); AppendString(customFixedLogicalVolumes.ToString()); }
public List <Partition> GetPartitions(ImageSchemaRequestDTO schemaRequest) { Request.Method = Method.POST; Request.Resource = string.Format("api/{0}/GetPartitions", Resource); Request.AddJsonBody(schemaRequest); var response = _apiRequest.Execute <ApiStringResponseDTO>(Request); return(JsonConvert.DeserializeObject <List <Partition> >(response.Value)); }
public ApiStringResponseDTO GetSchema(ImageSchemaRequestDTO schemaRequest) { var schema = new ImageSchemaFEServices(schemaRequest).GetImageSchema(); return(new ApiStringResponseDTO() { Value = JsonConvert.SerializeObject(schema) }); }
public ApiStringResponseDTO GetPartitions(ImageSchemaRequestDTO schemaRequest) { var partitions = new ImageSchemaFEServices(schemaRequest).GetPartitionsForGridView(schemaRequest.selectedHd); return(new ApiStringResponseDTO() { Value = JsonConvert.SerializeObject(partitions) }); }
public ApiStringResponseDTO GetLogicalVolumes(ImageSchemaRequestDTO schemaRequest) { var logicalVolumes = new ImageSchemaFEServices(schemaRequest).GetLogicalVolumesForGridView(schemaRequest.selectedHd); return(new ApiStringResponseDTO() { Value = JsonConvert.SerializeObject(logicalVolumes) }); }
public ApiStringResponseDTO GetHardDrives(ImageSchemaRequestDTO schemaRequest) { var hardDrives = new ImageSchemaFEServices(schemaRequest).GetHardDrivesForGridView(); return(new ApiStringResponseDTO() { Value = JsonConvert.SerializeObject(hardDrives) }); }
public ImageSchemaGridView GetSchema(ImageSchemaRequestDTO schemaRequest) { Request.Method = Method.POST; Request.Resource = string.Format("api/{0}/GetSchema", Resource); Request.AddJsonBody(schemaRequest); var response = _apiRequest.Execute <ApiStringResponseDTO>(Request); return(JsonConvert.DeserializeObject <ImageSchemaGridView>(response.Value)); }
protected void PopulateHardDrives() { var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "upload"; gvHDs.DataSource = Call.ImageSchemaApi.GetHardDrives(schemaRequestOptions); gvHDs.DataBind(); }
protected void btnHds_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var row = (GridViewRow)control.Parent.Parent; var gvHDs = (GridView)row.FindControl("gvHDs"); var btn = (LinkButton)row.FindControl("btnHDs"); if (gvHDs.Visible == false) { var td = row.FindControl("tdHds"); td.Visible = true; gvHDs.Visible = true; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = Call.ImageApi.Get(Image.Id); schemaRequestOptions.imageProfile = null; schemaRequestOptions.schemaType = "deploy"; gvHDs.DataSource = Call.ImageSchemaApi.GetHardDrives(schemaRequestOptions); gvHDs.DataBind(); btn.Text = "-"; } else { var td = row.FindControl("tdHds"); td.Visible = false; gvHDs.Visible = false; btn.Text = "+"; } foreach (GridViewRow hdrow in gvHDs.Rows) { var selectedHd = hdrow.RowIndex; var lblClient = hdrow.FindControl("lblHDSizeClient") as Label; if (lblClient != null) { var dataKey = gvProfiles.DataKeys[row.RowIndex]; if (dataKey == null) { continue; } lblClient.Text = Call.ImageProfileApi.GetMinimumClientSize(Convert.ToInt32(dataKey.Value), selectedHd); } } }
public List <LogicalVolume> GetLogicalVolumes(ImageSchemaRequestDTO schemaRequest) { Request.Method = Method.POST; Request.Resource = string.Format("api/{0}/GetLogicalVolumes", Resource); Request.AddJsonBody(schemaRequest); var response = _apiRequest.Execute <ApiStringResponseDTO>(Request); var result = JsonConvert.DeserializeObject <List <LogicalVolume> >(response.Value); if (result == null) { return(new List <LogicalVolume>()); } else { return(result); } }
protected void btnHds_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var row = (GridViewRow)control.Parent.Parent; var gvHDs = (GridView)row.FindControl("gvHDs"); var imageId = ((HiddenField)row.FindControl("HiddenID")).Value; var btn = (LinkButton)row.FindControl("btnHDs"); if (gvHDs.Visible == false) { var td = row.FindControl("tdHds"); td.Visible = true; gvHDs.Visible = true; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = Call.ImageApi.Get(Convert.ToInt32(imageId)); schemaRequestOptions.imageProfile = null; schemaRequestOptions.schemaType = "deploy"; gvHDs.DataSource = Call.ImageSchemaApi.GetHardDrives(schemaRequestOptions); gvHDs.DataBind(); btn.Text = "-"; } else { var td = row.FindControl("tdHds"); td.Visible = false; gvHDs.Visible = false; btn.Text = "+"; } foreach (GridViewRow hdrow in gvHDs.Rows) { var selectedHd = hdrow.RowIndex; var lbl = hdrow.FindControl("lblHDSize") as Label; if (lbl != null) { lbl.Text = Call.ImageApi.GetImageSizeOnServer(row.Cells[5].Text, selectedHd.ToString()); } } }
private void SetCustomSchemaDeploy() { var imageSchemaRequest = new ImageSchemaRequestDTO(); imageSchemaRequest.imageProfile = _imageProfile; imageSchemaRequest.schemaType = "deploy"; var customSchema = new ImageSchemaFEServices(imageSchemaRequest).GetImageSchema(); var customHardDrives = new StringBuilder(); customHardDrives.Append("custom_hard_drives=\""); foreach (var hd in customSchema.HardDrives.Where(x => x.Active && !string.IsNullOrEmpty(x.Destination))) { customHardDrives.Append(hd.Destination + " "); } customHardDrives.Append("\""); AppendString(customHardDrives.ToString()); }
protected void btnVG_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var gvRow = (GridViewRow)control.Parent.Parent; var gv = (GridView)gvRow.FindControl("gvLVS"); var selectedHd = (string)ViewState["selectedHD"]; var btn = (LinkButton)gvRow.FindControl("vgClick"); if (gv.Visible == false) { gv.Visible = true; var td = gvRow.FindControl("tdLVS"); td.Visible = true; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "upload"; schemaRequestOptions.selectedHd = selectedHd; gv.DataSource = Call.ImageSchemaApi.GetLogicalVolumes(schemaRequestOptions); gv.DataBind(); btn.Text = "-"; } else { gv.Visible = false; var td = gvRow.FindControl("tdLVS"); td.Visible = false; btn.Text = "+"; } }
protected string SetCustomUploadSchema() { var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "upload"; var schema = Call.ImageSchemaApi.GetSchema(schemaRequestOptions); var rowCounter = 0; foreach (GridViewRow row in gvHDs.Rows) { var box = row.FindControl("chkHDActive") as CheckBox; if (box != null) { schema.HardDrives[rowCounter].Active = box.Checked; } var gvParts = (GridView)row.FindControl("gvParts"); var partCounter = 0; foreach (GridViewRow partRow in gvParts.Rows) { var boxPart = partRow.FindControl("chkPartActive") as CheckBox; if (boxPart != null) { schema.HardDrives[rowCounter].Partitions[partCounter].Active = boxPart.Checked; } var chkFixed = partRow.FindControl("chkFixed") as CheckBox; if (chkFixed != null) { schema.HardDrives[rowCounter].Partitions[partCounter].ForceFixedSize = chkFixed.Checked; } var gvVg = (GridView)partRow.FindControl("gvVG"); foreach (GridViewRow vg in gvVg.Rows) { var gvLvs = (GridView)vg.FindControl("gvLVS"); var lvCounter = 0; foreach (GridViewRow lv in gvLvs.Rows) { var lvBoxPart = lv.FindControl("chkPartActive") as CheckBox; if (lvBoxPart != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .Active = lvBoxPart.Checked; } var lvChkFixed = lv.FindControl("chkFixed") as CheckBox; if (lvChkFixed != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .ForceFixedSize = lvChkFixed.Checked; } lvCounter++; } } partCounter++; } rowCounter++; } return(JsonConvert.SerializeObject(schema)); }
protected string SetCustomSchema() { var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "deploy"; var schema = Call.ImageSchemaApi.GetSchema(schemaRequestOptions); var rowCounter = 0; foreach (GridViewRow row in gvHDs.Rows) { var box = row.FindControl("chkHDActive") as CheckBox; if (box != null) { schema.HardDrives[rowCounter].Active = box.Checked; } var txtDestination = row.FindControl("txtDestination") as TextBox; if (txtDestination != null) { schema.HardDrives[rowCounter].Destination = txtDestination.Text; } var gvParts = (GridView)row.FindControl("gvParts"); var partCounter = 0; foreach (GridViewRow partRow in gvParts.Rows) { var boxPart = partRow.FindControl("chkPartActive") as CheckBox; if (boxPart != null) { schema.HardDrives[rowCounter].Partitions[partCounter].Active = boxPart.Checked; } var txtCustomSize = partRow.FindControl("txtCustomSize") as TextBox; if (txtCustomSize != null) { schema.HardDrives[rowCounter].Partitions[partCounter].CustomSize = txtCustomSize.Text; } var ddlUnit = partRow.FindControl("ddlUnit") as DropDownList; if (ddlUnit != null) { schema.HardDrives[rowCounter].Partitions[partCounter].CustomSizeUnit = ddlUnit.Text; } var chkFixed = partRow.FindControl("chkFixed") as CheckBox; if (chkFixed != null) { schema.HardDrives[rowCounter].Partitions[partCounter].ForceFixedSize = chkFixed.Checked; } var gvVg = (GridView)partRow.FindControl("gvVG"); foreach (GridViewRow vg in gvVg.Rows) { var gvLvs = (GridView)vg.FindControl("gvLVS"); var lvCounter = 0; foreach (GridViewRow lv in gvLvs.Rows) { var lvBoxPart = lv.FindControl("chkPartActive") as CheckBox; if (lvBoxPart != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .Active = lvBoxPart.Checked; } var lvTxtCustomSize = lv.FindControl("txtCustomSize") as TextBox; if (lvTxtCustomSize != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .CustomSize = lvTxtCustomSize.Text; } var lvDdlUnit = lv.FindControl("ddlUnit") as DropDownList; if (lvDdlUnit != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .CustomSizeUnit = lvDdlUnit.Text; } var lvChkFixed = lv.FindControl("chkFixed") as CheckBox; if (lvChkFixed != null) { schema.HardDrives[rowCounter].Partitions[partCounter].VolumeGroup.LogicalVolumes[ lvCounter] .ForceFixedSize = lvChkFixed.Checked; } lvCounter++; } } partCounter++; } rowCounter++; } return(JsonConvert.SerializeObject(schema, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore })); }
protected void btnVG_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var gvRow = (GridViewRow)control.Parent.Parent; var gv = (GridView)gvRow.FindControl("gvLVS"); var selectedHd = (string)ViewState["selectedHD"]; var btn = (LinkButton)gvRow.FindControl("vgClick"); if (gv.Visible == false) { gv.Visible = true; var td = gvRow.FindControl("tdLVS"); td.Visible = true; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "deploy"; schemaRequestOptions.selectedHd = selectedHd; gv.DataSource = Call.ImageSchemaApi.GetLogicalVolumes(schemaRequestOptions); gv.DataBind(); btn.Text = "-"; } else { gv.Visible = false; var td = gvRow.FindControl("tdLVS"); td.Visible = false; btn.Text = "+"; } if (ddlObject.Text != "Dynamic") { foreach (GridViewRow lv in gv.Rows) { var lvTxtCustomSize = lv.FindControl("txtCustomSize") as TextBox; if (lvTxtCustomSize != null) { lvTxtCustomSize.Enabled = false; } var lvDdlUnit = lv.FindControl("ddlUnit") as DropDownList; if (lvDdlUnit != null) { lvDdlUnit.Enabled = false; } var lvChkFixed = lv.FindControl("chkFixed") as CheckBox; if (lvChkFixed != null) { lvChkFixed.Enabled = false; } } } }
protected void btnHd_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var gvRow = (GridViewRow)control.Parent.Parent; var gv = (GridView)gvRow.FindControl("gvParts"); var selectedHd = gvRow.Cells[2].Text; ViewState["selectedHD"] = gvRow.RowIndex.ToString(); ViewState["selectedHDName"] = selectedHd; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "deploy"; schemaRequestOptions.selectedHd = selectedHd; var partitions = Call.ImageSchemaApi.GetPartitions(schemaRequestOptions); var btn = (LinkButton)gvRow.FindControl("btnHd"); if (gv.Visible == false) { gv.Visible = true; var td = gvRow.FindControl("tdParts"); td.Visible = true; gv.DataSource = partitions; gv.DataBind(); btn.Text = "-"; } else { gv.Visible = false; var td = gvRow.FindControl("tdParts"); td.Visible = false; btn.Text = "+"; } foreach (GridViewRow row in gv.Rows) { if (ddlObject.Text != "Dynamic") { foreach (GridViewRow partRow in gv.Rows) { var txtCustomSize = partRow.FindControl("txtCustomSize") as TextBox; if (txtCustomSize != null) { txtCustomSize.Enabled = false; } var ddlUnit = partRow.FindControl("ddlUnit") as DropDownList; if (ddlUnit != null) { ddlUnit.Enabled = false; } var chkFixed = partRow.FindControl("chkFixed") as CheckBox; if (chkFixed != null) { chkFixed.Enabled = false; } } } if (partitions[row.RowIndex].VolumeGroup == null) { continue; } if (partitions[row.RowIndex].VolumeGroup.Name == null) { continue; } var gvVg = (GridView)row.FindControl("gvVG"); gvVg.DataSource = new List <VolumeGroup> { partitions[row.RowIndex].VolumeGroup }; gvVg.DataBind(); gvVg.Visible = true; var td = row.FindControl("tdVG"); td.Visible = true; } }
protected void btnHd_Click(object sender, EventArgs e) { var control = sender as Control; if (control == null) { return; } var gvRow = (GridViewRow)control.Parent.Parent; var gv = (GridView)gvRow.FindControl("gvParts"); var selectedHd = gvRow.Cells[2].Text; ViewState["selectedHD"] = gvRow.RowIndex.ToString(); ViewState["selectedHDName"] = selectedHd; var schemaRequestOptions = new ImageSchemaRequestDTO(); schemaRequestOptions.image = null; schemaRequestOptions.imageProfile = ImageProfile; schemaRequestOptions.schemaType = "upload"; schemaRequestOptions.selectedHd = selectedHd; var partitions = Call.ImageSchemaApi.GetPartitions(schemaRequestOptions); var btn = (LinkButton)gvRow.FindControl("btnHd"); if (gv.Visible == false) { gv.Visible = true; var td = gvRow.FindControl("tdParts"); td.Visible = true; gv.DataSource = partitions; gv.DataBind(); btn.Text = "-"; } else { gv.Visible = false; var td = gvRow.FindControl("tdParts"); td.Visible = false; btn.Text = "+"; } foreach (GridViewRow row in gv.Rows) { if (partitions[row.RowIndex].VolumeGroup == null) { continue; } if (partitions[row.RowIndex].VolumeGroup.Name == null) { continue; } var gvVg = (GridView)row.FindControl("gvVG"); gvVg.DataSource = new List <VolumeGroup> { partitions[row.RowIndex].VolumeGroup }; gvVg.DataBind(); gvVg.Visible = true; var td = row.FindControl("tdVG"); td.Visible = true; } }