示例#1
0
        private void SetCustomSchemaUpload()
        {
            var imageSchemaRequest = new DtoImageSchemaRequest();

            imageSchemaRequest.imageProfile = _imageProfile;
            imageSchemaRequest.schemaType   = "upload";
            var customSchema     = new ServiceImageSchemaFE(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());
        }
示例#2
0
        public ServiceImageSchemaFE(DtoImageSchemaRequest 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.imageProfile.CustomSchema != "{}" &&
                    schemaRequest.schemaType == "deploy")
                {
                    schema = schemaRequest.imageProfile.CustomSchema;
                }
                else if (!string.IsNullOrEmpty(schemaRequest.imageProfile.CustomUploadSchema) && schemaRequest.imageProfile.CustomSchema != "{}" &&
                         schemaRequest.schemaType == "upload")
                {
                    schema = schemaRequest.imageProfile.CustomUploadSchema;
                }
                else
                {
                    schema = new FilesystemServices().ReadSchemaFile(schemaRequest.imageProfile.Image.Name);
                }
            }

            if (!string.IsNullOrEmpty(schema))
            {
                _imageSchema = JsonConvert.DeserializeObject <DtoImageSchemaGridView>(schema);
            }
        }
示例#3
0
        public DtoApiStringResponse GetSchema(DtoImageSchemaRequest schemaRequest)
        {
            var schema = new ServiceImageSchemaFE(schemaRequest).GetImageSchema();

            return(new DtoApiStringResponse()
            {
                Value = JsonConvert.SerializeObject(schema)
            });
        }
示例#4
0
        public DtoApiStringResponse GetPartitions(DtoImageSchemaRequest schemaRequest)
        {
            var partitions = new ServiceImageSchemaFE(schemaRequest).GetPartitionsForGridView(schemaRequest.selectedHd);

            return(new DtoApiStringResponse()
            {
                Value = JsonConvert.SerializeObject(partitions)
            });
        }
示例#5
0
        public DtoApiStringResponse GetLogicalVolumes(DtoImageSchemaRequest schemaRequest)
        {
            var logicalVolumes = new ServiceImageSchemaFE(schemaRequest).GetLogicalVolumesForGridView(schemaRequest.selectedHd);

            return(new DtoApiStringResponse()
            {
                Value = JsonConvert.SerializeObject(logicalVolumes)
            });
        }
示例#6
0
        public DtoApiStringResponse GetHardDrives(DtoImageSchemaRequest schemaRequest)
        {
            var hardDrives = new ServiceImageSchemaFE(schemaRequest).GetHardDrivesForGridView();

            return(new DtoApiStringResponse()
            {
                Value = JsonConvert.SerializeObject(hardDrives)
            });
        }
示例#7
0
        protected void PopulateHardDrives()
        {
            var schemaRequestOptions = new DtoImageSchemaRequest();

            schemaRequestOptions.image        = null;
            schemaRequestOptions.imageProfile = ImageProfile;
            schemaRequestOptions.schemaType   = "upload";
            gvHDs.DataSource = Call.ImageSchemaApi.GetHardDrives(schemaRequestOptions);
            gvHDs.DataBind();
        }
示例#8
0
        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 DtoImageSchemaRequest();
                schemaRequestOptions.image        = Call.ImageApi.Get(ImageEntity.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);
                }
            }
        }
示例#9
0
        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 DtoImageSchemaRequest();

                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());
                }
            }
        }
示例#10
0
        private void SetCustomSchemaDeploy()
        {
            var imageSchemaRequest = new DtoImageSchemaRequest();

            imageSchemaRequest.imageProfile = _imageProfile;
            imageSchemaRequest.schemaType   = "deploy";
            var customSchema     = new ServiceImageSchemaFE(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());
        }
示例#11
0
        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 DtoImageSchemaRequest();
                schemaRequestOptions.image        = ImageEntity;
                schemaRequestOptions.imageProfile = null;
                schemaRequestOptions.schemaType   = null;
                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   = "+";
            }
        }
示例#12
0
        public DtoImageSchemaGridView GetSchema(DtoImageSchemaRequest schemaRequest)
        {
            Request.Method   = Method.POST;
            Request.Resource = string.Format("{0}/GetSchema", Resource);
            Request.AddJsonBody(schemaRequest);
            var response = _apiRequest.Execute <DtoApiStringResponse>(Request);

            if (response == null)
            {
                return(new DtoImageSchemaGridView());
            }
            var result = JsonConvert.DeserializeObject <DtoImageSchemaGridView>(response.Value);

            if (result == null)
            {
                return(new DtoImageSchemaGridView());
            }
            else
            {
                return(result);
            }
        }
示例#13
0
        public List <DtoPartition> GetPartitions(DtoImageSchemaRequest schemaRequest)
        {
            Request.Method   = Method.POST;
            Request.Resource = string.Format("{0}/GetPartitions", Resource);
            Request.AddJsonBody(schemaRequest);
            var response = _apiRequest.Execute <DtoApiStringResponse>(Request);

            if (response == null)
            {
                return(new List <DtoPartition>());
            }
            var result = JsonConvert.DeserializeObject <List <DtoPartition> >(response.Value);

            if (result == null)
            {
                return(new List <DtoPartition>());
            }
            else
            {
                return(result);
            }
        }
示例#14
0
        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[1].Text;

            ViewState["selectedHD"]     = gvRow.RowIndex.ToString();
            ViewState["selectedHDName"] = selectedHd;

            var schemaRequestOptions = new DtoImageSchemaRequest();

            schemaRequestOptions.image        = ImageEntity;
            schemaRequestOptions.imageProfile = null;
            schemaRequestOptions.schemaType   = null;
            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 <DtoVolumeGroup>
                {
                    partitions[row.RowIndex].VolumeGroup
                };
                gvVg.DataBind();

                gvVg.Visible = true;
                var td = row.FindControl("tdVG");
                td.Visible = true;
            }
        }
示例#15
0
        protected string SetCustomSchema()
        {
            var schemaRequestOptions = new DtoImageSchemaRequest();

            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
            }));
        }
示例#16
0
        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 DtoImageSchemaRequest();

            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 <Toems_Common.Dto.imageschemafe.DtoVolumeGroup>
                {
                    partitions[row.RowIndex].VolumeGroup
                };
                gvVg.DataBind();

                gvVg.Visible = true;
                var td = row.FindControl("tdVG");
                td.Visible = true;
            }
        }
示例#17
0
        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 DtoImageSchemaRequest();
                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;
                    }
                }
            }
        }
示例#18
0
        protected string SetCustomUploadSchema()
        {
            var schemaRequestOptions = new DtoImageSchemaRequest();

            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));
        }