protected void btnAdd_Click(Object Sender, EventArgs e) { int intModel = 0; if (Request.Form[hdnModel.UniqueID] != "") { intModel = Int32.Parse(Request.Form[hdnModel.UniqueID]); } int intMaximum = 0; if (Int32.TryParse(txtMaximum.Text, out intMaximum) == false) { intMaximum = 99999; } int intDatastoreLeft = 0; Int32.TryParse(txtDatastoreLeft.Text, out intDatastoreLeft); int intDatastoreSize = 0; Int32.TryParse(txtDatastoreSize.Text, out intDatastoreSize); if (intID == 0) { oVMWare.AddCluster(Int32.Parse(ddlParent.SelectedItem.Value), intModel, txtName.Text, Int32.Parse(ddlVersion.SelectedItem.Value), Int32.Parse(ddlAntiAffinity.SelectedItem.Value), intMaximum, txtResourcePool.Text, txtDatastoreNotify.Text, intDatastoreLeft, intDatastoreSize, (chkPNC.Checked ? 1 : 0), (chkFull.Checked ? 1 : 0), (chkAPoff.Checked ? 1 : 0), (chkAPoffDR.Checked ? 1 : 0), (chkDell.Checked ? 1 : 0), Int32.Parse(ddlResiliency.SelectedItem.Value), (chkOracle.Checked ? 1 : 0), (chkOracleCluster.Checked ? 1 : 0), (chkSQL.Checked ? 1 : 0), (chkSQLCluster.Checked ? 1 : 0), (chkCluster.Checked ? 1 : 0), 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, (chkEnabled.Checked ? 1 : 0)); } else { oVMWare.UpdateCluster(intID, Int32.Parse(ddlParent.SelectedItem.Value), intModel, txtName.Text, Int32.Parse(ddlVersion.SelectedItem.Value), Int32.Parse(ddlAntiAffinity.SelectedItem.Value), intMaximum, txtResourcePool.Text, txtDatastoreNotify.Text, intDatastoreLeft, intDatastoreSize, (chkPNC.Checked ? 1 : 0), (chkFull.Checked ? 1 : 0), (chkAPoff.Checked ? 1 : 0), (chkAPoffDR.Checked ? 1 : 0), (chkDell.Checked ? 1 : 0), Int32.Parse(ddlResiliency.SelectedItem.Value), (chkOracle.Checked ? 1 : 0), (chkOracleCluster.Checked ? 1 : 0), (chkSQL.Checked ? 1 : 0), (chkSQLCluster.Checked ? 1 : 0), (chkCluster.Checked ? 1 : 0), double.Parse(txtFailures.Text), double.Parse(txtCPUUtilization.Text), double.Parse(txtRAMUtilization.Text), double.Parse(txtMaxRAM.Text), double.Parse(txtAvgUtilization.Text), double.Parse(txtLunSize.Text), double.Parse(txtLunUtilization.Text), double.Parse(txtVMsPerLun.Text), double.Parse(txtTimeLUN.Text), double.Parse(txtTimeCluster.Text), double.Parse(txtMaxVMsServer.Text), double.Parse(txtMaxVMsLUN.Text), (chkEnabled.Checked ? 1 : 0)); } Response.Redirect(Request.Path); }
protected void btnUpdateC_Click(object sender, EventArgs e) { int intMaximum = 0; if (Int32.TryParse(txtCMaximum.Text, out intMaximum) == false) { intMaximum = 99999; } int c = 0; if (Int32.TryParse(Request.QueryString["c"], out c) == true) { oVMWare.UpdateCluster(c, Int32.Parse(lblCParent.ToolTip), 0, txtCName.Text, Int32.Parse(ddlVersion.SelectedItem.Value), Int32.Parse(ddlAntiAffinity.SelectedItem.Value), intMaximum, txtResourcePool.Text, txtDatastoreNotify.Text, Int32.Parse(txtDatastoreLeft.Text), Int32.Parse(txtDatastoreSize.Text), 1, (chkFull.Checked ? 1 : 0), (chkAPoff.Checked ? 1 : 0), (chkAPoffDR.Checked ? 1 : 0), (chkDell.Checked ? 1 : 0), Int32.Parse(ddlResiliency.SelectedItem.Value), (chkOracle.Checked ? 1 : 0), (chkOracleCluster.Checked ? 1 : 0), (chkSQL.Checked ? 1 : 0), (chkSQLCluster.Checked ? 1 : 0), (chkCluster.Checked ? 1 : 0), double.Parse(txtFailures.Text), double.Parse(txtCPUUtilization.Text), double.Parse(txtRAMUtilization.Text), double.Parse(txtMaxRAM.Text), double.Parse(txtAvgUtilization.Text), double.Parse(txtLunSize.Text), double.Parse(txtLunUtilization.Text), double.Parse(txtVMsPerLun.Text), double.Parse(txtTimeLUN.Text), double.Parse(txtTimeCluster.Text), double.Parse(txtMaxVMsServer.Text), double.Parse(txtMaxVMsLUN.Text), (chkCEnabled.Checked ? 1 : 0)); } else { oVMWare.AddCluster(Int32.Parse(lblCParent.ToolTip), 0, txtCName.Text, Int32.Parse(ddlVersion.SelectedItem.Value), Int32.Parse(ddlAntiAffinity.SelectedItem.Value), intMaximum, txtResourcePool.Text, txtDatastoreNotify.Text, Int32.Parse(txtDatastoreLeft.Text), Int32.Parse(txtDatastoreSize.Text), 1, (chkFull.Checked ? 1 : 0), (chkAPoff.Checked ? 1 : 0), (chkAPoffDR.Checked ? 1 : 0), (chkDell.Checked ? 1 : 0), Int32.Parse(ddlResiliency.SelectedItem.Value), (chkOracle.Checked ? 1 : 0), (chkOracleCluster.Checked ? 1 : 0), (chkSQL.Checked ? 1 : 0), (chkSQLCluster.Checked ? 1 : 0), (chkCluster.Checked ? 1 : 0), 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, 0.00, (chkCEnabled.Checked ? 1 : 0)); } Response.Redirect(FormURL("")); }
protected void CreateClusterAndAddHostsToServer() { ServerName oServerName = new ServerName(0, dsn); Servers oServer = new Servers(0, dsn); Cluster oCluster = new Cluster(0, dsn); int intClass = Int32.Parse(ddlClass.SelectedValue); int intEnv = Int32.Parse(ddlEnvironment.SelectedValue); int intAddress = Int32.Parse(hdnLocation.Value); int intRequestId = Int32.Parse(hdnRequestId.Value); int intVMWareClusterId = 0; int intClusterID = 0; int intSelectedCount = 0; int intSelectedDRCount = 0; DataSet dsAssets = oAsset.GetAssetsByOrder(Int32.Parse(hdnOrderId.Value)); intSelectedCount = dsAssets.Tables[0].Rows.Count; intSelectedDRCount = dsAssets.Tables[0].Rows.Count; intModel = Int32.Parse(ddlModel.SelectedValue); if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster)//for Cluster -Add record in Cluster Table { string strPrefix = "XCV"; string strDatastoreNotify = "xassa3x"; int intServerName = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, "VMWARE_CLUSTER_IM", 1, dsnServiceEditor); string strClusterName = oServerName.GetName(intServerName, 0); intVMWareClusterId = oVMWare.AddCluster(intParent, intModel, strClusterName, 0, 0, 10000, "", strDatastoreNotify, 1, 500, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 100, 2, 100, 500, 100, 10, 10, 10, 1, 1, 1); foreach (ListItem lstOS in chkFunctionVMWARE.Items) { if (lstOS.Selected) { oVMWare.AddClusterOS(intVMWareClusterId, Int32.Parse(lstOS.Value)); } } intClusterID = oCluster.Add(intRequestId, strClusterName, intSelectedCount, intSelectedDRCount, 0); } else if (intOrderType == (int)AssetSharedEnvOrderType.AddHost) { intVMWareClusterId = Int32.Parse(hdnParentId.Value); } //For Cluster OR Host -Add Server Assets Table if (intOrderType == (int)AssetSharedEnvOrderType.AddCluster || intOrderType == (int)AssetSharedEnvOrderType.AddHost) { int intNumber = 0; int intDomain = 0; int intOS = 0; int intSP = 0; string strNodePrefix = "XNV"; foreach (DataRow drAsset in dsAssets.Tables[0].Rows) { //Mark the Asset to Instock //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now); intNumber++; int intserverId = oServer.Add(intRequestId, 0, intModel, 0, intClusterID, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0); int intAsset = Int32.Parse(drAsset["id"].ToString()); oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0); //oServer.UpdateStep(intserverId, 1); oAsset.Update(intAsset, (int)AssetAttribute.Reserve); //string strHostName = ""; //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.Reserved, intProfile, DateTime.Now); //Based on the asset selection create name for hosts //intServerName = oServerName.Add(intClass, intEnv, intAddress, strNodePrefix, intProfile, oAsset.Get(intAsset, "serial"), 1); //string strHostName = oServerName.GetName(intServerName, 0); // } //Set the server step to one DataSet dsServer = oServer.GetRequests(intRequestId, 1); foreach (DataRow dr in dsServer.Tables[0].Rows) { oServer.UpdateStep(Int32.Parse(dr["id"].ToString()), 1); } } ////if (Int32.Parse(rblASEOrderType.SelectedValue) == (int)AssetSharedEnvOrderType.AddHost)//for Host -Add record in Host Table ////{ //// intVMWareClusterId = 123456789; //// int intNumber = 0; //// int intDomain = 0; // josh //// int intOS = 0; // josh //// int intSP = 0; // josh //// string strPrefix = "XNV"; //// int intSelectedDRCount = 0; //// foreach (DataListItem dlItem in dlAssetsSelection.Items) //// { //// HiddenField hdnAssetId = (HiddenField)dlItem.FindControl("hdnAssetId"); //// CheckBox chkSelectAsset = (CheckBox)dlItem.FindControl("chkSelectAsset"); //// if (chkSelectAsset.Checked == true) //// { //// //Mark the Asset to Instock //// //oAsset.UpdateStatus(Int32.Parse(hdnAssetId.Value), "", (int)AssetStatus.InStock, intProfile, DateTime.Now); //// intNumber++; //// int intserverId = oServer.Add(intRequestId, 0, intModel, 0, 0, intNumber, intOS, intSP, 0, intDomain, 0, 1, 0, (intSelectedDRCount > 0 ? 1 : 0), 0, "", 0, 0, 1, 1, 1, 1, 0, (oClass.Get(intClass, "pnc") == "1" ? 1 : 0), intVMWareClusterId, 0); //// int intAsset = Int32.Parse(hdnAssetId.Value); //// oServer.AddAsset(intserverId, intAsset, intClass, intEnvironment, 0, 0); //// //Based on the asset selection create name for hosts //// //intServerName = oServerName.Add(intClass, intEnv, intAddress, strPrefix, intProfile, oAsset.Get(intAsset, "serial"), 1); //// //string strHostName = oServerName.GetName(intServerName, 0); //// //oAsset.AddStatus(intAsset, strHostName, (int)AssetStatus.InUse, intProfile, DateTime.Now); //// } //// } ////} }