Exemple #1
0
    public BootTemplate Read(string templateName)
    {
        BootTemplate template = new BootTemplate();

        try
        {
            using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
            {
                NpgsqlCommand cmd = new NpgsqlCommand("boottemplates_read", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new NpgsqlParameter("@templateName", templateName));
                conn.Open();
                NpgsqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    template.templateName    = (string)rdr["templatename"];
                    template.templateContent = (string)rdr["templatecontent"];
                }
            }
        }
        catch (Exception ex)
        {
            Utility.Message = "Could Not Read Boot Menu.  Check The Exception Log For More Info";
            Logger.Log(ex.ToString());
        }
        return(template);
    }
Exemple #2
0
 protected void btnUpdateTemplate_Click(object sender, EventArgs e)
 {
     BootTemplate template = new BootTemplate();
     template.templateName = txtModifyTemplate.Text;
     template.templateContent = txtAreaModifyTemplate.Text;
     template.Update(template);
     Master.Msgbox(Utility.Message);
 }
Exemple #3
0
 protected void btnDeleteTemplate_Click(object sender, EventArgs e)
 {
     BootTemplate template = new BootTemplate();
     template.Delete(txtModifyTemplate.Text);
     Master.Msgbox(Utility.Message);
     modifyTemplate.Visible = false;
     showTemplates_Click(sender, e);
 }
Exemple #4
0
    protected void btnUpdateTemplate_Click(object sender, EventArgs e)
    {
        BootTemplate template = new BootTemplate();

        template.templateName    = txtModifyTemplate.Text;
        template.templateContent = txtAreaModifyTemplate.Text;
        template.Update(template);
        Master.Msgbox(Utility.Message);
    }
Exemple #5
0
    protected void btnDeleteTemplate_Click(object sender, EventArgs e)
    {
        BootTemplate template = new BootTemplate();

        template.Delete(txtModifyTemplate.Text);
        Master.Msgbox(Utility.Message);
        modifyTemplate.Visible = false;
        showTemplates_Click(sender, e);
    }
Exemple #6
0
    protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {
        Utility settings  = new Utility();
        string  path      = null;
        string  mode      = settings.GetSettings("PXE Mode");
        string  proxyDHCP = settings.GetSettings("Proxy Dhcp");

        if (ddlTemplate.Text == "default")
        {
            if (proxyDHCP == "Yes")
            {
                string biosFile = settings.GetSettings("Proxy Bios File");

                if (biosFile.Contains("ipxe"))
                {
                    path = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + ddlEditProxyType.Text + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default.ipxe";
                }
                else
                {
                    path = settings.GetSettings("Tftp Path") + "proxy" + Path.DirectorySeparatorChar + ddlEditProxyType.Text + Path.DirectorySeparatorChar + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default";
                }
            }
            else
            {
                if (mode.Contains("ipxe"))
                {
                    path = settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default.ipxe";
                }
                else
                {
                    path = settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default";
                }
            }
            try
            {
                txtCustomBootMenu.Text = File.ReadAllText(path);
            }
            catch (Exception ex)
            {
                Master.Msgbox("Could Not Read Default Boot Menu.  Check The Exception Log For More Info");
                Logger.Log(ex.Message);
            }
        }
        else if (ddlTemplate.Text == "select template")
        {
            txtCustomBootMenu.Text = "";
        }
        else
        {
            BootTemplate template = new BootTemplate().Read(ddlTemplate.Text);
            txtCustomBootMenu.Text = template.templateContent;
        }
    }
Exemple #7
0
    public void btnNewTemplate_Click(object sender, EventArgs e)
    {
        if (Utility.NoSpaceNotEmpty(txtNewTemplate.Text))
        {
            BootTemplate template = new BootTemplate();
            template.templateName = txtNewTemplate.Text;
            template.templateContent = txtAreaNewTemplate.Text;
            template.Create(template);
            showTemplates_Click(sender, e);
            Master.Msgbox(Utility.Message);
        }

        else
            Master.Msgbox("Template Name Cannot Be Empty Or Contain Spaces");
    }
Exemple #8
0
    public void btnNewTemplate_Click(object sender, EventArgs e)
    {
        if (Utility.NoSpaceNotEmpty(txtNewTemplate.Text))
        {
            BootTemplate template = new BootTemplate();
            template.templateName    = txtNewTemplate.Text;
            template.templateContent = txtAreaNewTemplate.Text;
            template.Create(template);
            showTemplates_Click(sender, e);
            Master.Msgbox(Utility.Message);
        }

        else
        {
            Master.Msgbox("Template Name Cannot Be Empty Or Contain Spaces");
        }
    }
Exemple #9
0
 public void Update(BootTemplate template)
 {
     try
     {
         using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
         {
             NpgsqlCommand cmd = new NpgsqlCommand("boottemplates_update", conn);
             cmd.CommandType = CommandType.StoredProcedure;
             cmd.Parameters.Add(new NpgsqlParameter("@templateName", template.templateName));
             cmd.Parameters.Add(new NpgsqlParameter("@templateContent", template.templateContent));
             conn.Open();
             Utility.Message = cmd.ExecuteScalar() as string;
         }
     }
     catch (Exception ex)
     {
         Utility.Message = "Could Not Update Template.  Check The Exception Log For More Info";
         Logger.Log(ex.ToString());
     }
 }
Exemple #10
0
    public void Create(BootTemplate template)
    {
        try
        {
            using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
            {
                NpgsqlCommand cmd = new NpgsqlCommand("boottemplates_create", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new NpgsqlParameter("@templateName", template.templateName));
                cmd.Parameters.Add(new NpgsqlParameter("@templatecontent", template.templateContent));
                conn.Open();
                Utility.Message = cmd.ExecuteScalar() as string;
            }
        }

        catch (Exception ex)
        {
            Utility.Message = "Could Not Create Template.  Check The Exception Log For More Info";
            Logger.Log(ex.ToString());
        }
    }
Exemple #11
0
    protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {
        Utility utility = new Utility();
        if (ddlTemplate.Text == "default")
        {

            createNewTemplate.Visible = false;
            modifyTemplate.Visible = false;

            string proxyDHCP = utility.GetSettings("Proxy Dhcp");

            if (proxyDHCP == "Yes")
            {
                divProxyDHCP.Visible = true;
                string biosFile = utility.GetSettings("Proxy Bios File");
                string efi32File = utility.GetSettings("Proxy Efi32 File");
                string efi64File = utility.GetSettings("Proxy Efi64 File");
                if (biosFile.Contains("linux") || efi32File.Contains("linux") || efi64File.Contains("linux"))
                {
                    proxyPassBoxes.Visible = true;
                }

                try
                {
                    ddlBiosKernel.DataSource = Utility.GetKernels();
                    ddlBiosKernel.DataBind();
                    ddlEfi32Kernel.DataSource = Utility.GetKernels();
                    ddlEfi32Kernel.DataBind();
                    ddlEfi64Kernel.DataSource = Utility.GetKernels();
                    ddlEfi64Kernel.DataBind();

                    ListItem itemKernel = ddlBiosKernel.Items.FindByText("3.18.1-WDS");
                    if (itemKernel != null)
                    {
                        ddlBiosKernel.SelectedValue = "3.18.1-WDS";
                        ddlEfi32Kernel.SelectedValue = "3.18.1-WDS";
                    }
                    else
                    {
                        ddlBiosKernel.Items.Insert(0, "Select Kernel");
                        ddlEfi32Kernel.Items.Insert(0, "Select Kernel");
                    }

                    ListItem itemKernel64 = ddlEfi64Kernel.Items.FindByText("3.18.1x64-WDS");
                    if(itemKernel64 != null)
                        ddlEfi64Kernel.SelectedValue = "3.18.1x64-WDS";
                    else
                        ddlEfi64Kernel.Items.Insert(0, "Select Kernel");

                    ddlBiosBootImage.DataSource = Utility.GetBootImages();
                    ddlBiosBootImage.DataBind();
                    ddlEfi32BootImage.DataSource = Utility.GetBootImages();
                    ddlEfi32BootImage.DataBind();
                    ddlEfi64BootImage.DataSource = Utility.GetBootImages();
                    ddlEfi64BootImage.DataBind();

                    ListItem itemBootImage = ddlBiosBootImage.Items.FindByText("initrd.gz");
                    if (itemBootImage != null)
                    {
                        ddlBiosBootImage.SelectedValue = "initrd.gz";
                        ddlEfi32BootImage.SelectedValue = "initrd.gz";
                    }
                    else
                    {
                        ddlBiosBootImage.Items.Insert(0, "Select Boot Image");
                        ddlEfi32BootImage.Items.Insert(0, "Select Boot Image");
                    }

                    ListItem itemBootImage64 = ddlEfi64BootImage.Items.FindByText("initrd64.gz");
                    if (itemBootImage != null)
                        ddlEfi64BootImage.SelectedValue = "initrd64.gz";
                    else
                        ddlEfi64BootImage.Items.Insert(0, "Select Boot Image");
                }
                catch { }
            }
            else
            {
                bootPasswords.Visible = true;
                divPXEMode.Visible = true;
                string pxeMode = utility.GetSettings("PXE Mode");
                if (pxeMode.Contains("ipxe"))
                {
                    passboxes.Visible = false;
                    btnSubmitDefault.Visible = false;
                    btnSubmitIPXE.Visible = true;
                }
                try
                {
                    ddlHostKernel.DataSource = Utility.GetKernels();
                    ddlHostKernel.DataBind();
                    ListItem itemKernel = ddlHostKernel.Items.FindByText("3.18.1-WDS");
                    if (itemKernel != null)
                        ddlHostKernel.SelectedValue = "3.18.1-WDS";
                    else
                        ddlHostKernel.Items.Insert(0, "Select Kernel");
                }
                catch { }

                try
                {
                    ddlHostBootImage.DataSource = Utility.GetBootImages();
                    ddlHostBootImage.DataBind();
                    ListItem itemBootImage = ddlHostBootImage.Items.FindByText("initrd.gz");
                    if (itemBootImage != null)
                        ddlHostBootImage.SelectedValue = "initrd.gz";
                    else
                        ddlHostBootImage.Items.Insert(0, "Select Boot Image");
                }
                catch { }
            }
        }

        else if (ddlTemplate.Text == "new template")
        {
            createNewTemplate.Visible = true;
            bootPasswords.Visible = false;
            modifyTemplate.Visible = false;
        }

        else if (ddlTemplate.Text == "select template")
        {
            createNewTemplate.Visible = false;
            bootPasswords.Visible = false;
            modifyTemplate.Visible = false;
        }
        else if (ddlTemplate.Text == "---------------")
        {
            //do nothing
        }
        else
        {
            modifyTemplate.Visible = true;
            createNewTemplate.Visible = false;
            bootPasswords.Visible = false;
            txtModifyTemplate.ReadOnly = true;
            BootTemplate template = new BootTemplate().Read(ddlTemplate.Text);
            txtModifyTemplate.Text = template.templateName;
            txtAreaModifyTemplate.Text = template.templateContent;
        }
    }
Exemple #12
0
    protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {
        Utility settings = new Utility();
        string path = null;
        string mode = settings.GetSettings("PXE Mode");

        if (ddlTemplate.Text == "default")
        {
            if (mode.Contains("ipxe"))
                path = settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default.ipxe";
            else
                path = settings.GetSettings("Tftp Path") + "pxelinux.cfg" + Path.DirectorySeparatorChar + "default";

            try
            {
                txtCustomBootMenu.Text = File.ReadAllText(path);
            }
            catch (Exception ex)
            {
                Master.Msgbox("Could Not Read Default Boot Menu.  Check The Exception Log For More Info");
                Logger.Log(ex.Message);
            }
        }
        else if (ddlTemplate.Text == "select template")
        {
            txtCustomBootMenu.Text = "";

        }
        else
        {
            BootTemplate template = new BootTemplate().Read(ddlTemplate.Text);
            txtCustomBootMenu.Text = template.templateContent;
        }
    }
Exemple #13
0
    protected void ddlTemplate_SelectedIndexChanged(object sender, EventArgs e)
    {
        Utility utility = new Utility();

        if (ddlTemplate.Text == "default")
        {
            createNewTemplate.Visible = false;
            modifyTemplate.Visible    = false;

            string proxyDHCP = utility.GetSettings("Proxy Dhcp");

            if (proxyDHCP == "Yes")
            {
                divProxyDHCP.Visible = true;
                string biosFile  = utility.GetSettings("Proxy Bios File");
                string efi32File = utility.GetSettings("Proxy Efi32 File");
                string efi64File = utility.GetSettings("Proxy Efi64 File");
                if (biosFile.Contains("linux") || efi32File.Contains("linux") || efi64File.Contains("linux"))
                {
                    proxyPassBoxes.Visible = true;
                }

                try
                {
                    ddlBiosKernel.DataSource = Utility.GetKernels();
                    ddlBiosKernel.DataBind();
                    ddlEfi32Kernel.DataSource = Utility.GetKernels();
                    ddlEfi32Kernel.DataBind();
                    ddlEfi64Kernel.DataSource = Utility.GetKernels();
                    ddlEfi64Kernel.DataBind();

                    ListItem itemKernel = ddlBiosKernel.Items.FindByText("3.18.1-WDS");
                    if (itemKernel != null)
                    {
                        ddlBiosKernel.SelectedValue  = "3.18.1-WDS";
                        ddlEfi32Kernel.SelectedValue = "3.18.1-WDS";
                    }
                    else
                    {
                        ddlBiosKernel.Items.Insert(0, "Select Kernel");
                        ddlEfi32Kernel.Items.Insert(0, "Select Kernel");
                    }

                    ListItem itemKernel64 = ddlEfi64Kernel.Items.FindByText("3.18.1x64-WDS");
                    if (itemKernel64 != null)
                    {
                        ddlEfi64Kernel.SelectedValue = "3.18.1x64-WDS";
                    }
                    else
                    {
                        ddlEfi64Kernel.Items.Insert(0, "Select Kernel");
                    }


                    ddlBiosBootImage.DataSource = Utility.GetBootImages();
                    ddlBiosBootImage.DataBind();
                    ddlEfi32BootImage.DataSource = Utility.GetBootImages();
                    ddlEfi32BootImage.DataBind();
                    ddlEfi64BootImage.DataSource = Utility.GetBootImages();
                    ddlEfi64BootImage.DataBind();

                    ListItem itemBootImage = ddlBiosBootImage.Items.FindByText("initrd.gz");
                    if (itemBootImage != null)
                    {
                        ddlBiosBootImage.SelectedValue  = "initrd.gz";
                        ddlEfi32BootImage.SelectedValue = "initrd.gz";
                    }
                    else
                    {
                        ddlBiosBootImage.Items.Insert(0, "Select Boot Image");
                        ddlEfi32BootImage.Items.Insert(0, "Select Boot Image");
                    }

                    ListItem itemBootImage64 = ddlEfi64BootImage.Items.FindByText("initrd64.gz");
                    if (itemBootImage != null)
                    {
                        ddlEfi64BootImage.SelectedValue = "initrd64.gz";
                    }
                    else
                    {
                        ddlEfi64BootImage.Items.Insert(0, "Select Boot Image");
                    }
                }
                catch { }
            }
            else
            {
                bootPasswords.Visible = true;
                divPXEMode.Visible    = true;
                string pxeMode = utility.GetSettings("PXE Mode");
                if (pxeMode.Contains("ipxe"))
                {
                    passboxes.Visible        = false;
                    btnSubmitDefault.Visible = false;
                    btnSubmitIPXE.Visible    = true;
                }
                try
                {
                    ddlHostKernel.DataSource = Utility.GetKernels();
                    ddlHostKernel.DataBind();
                    ListItem itemKernel = ddlHostKernel.Items.FindByText("3.18.1-WDS");
                    if (itemKernel != null)
                    {
                        ddlHostKernel.SelectedValue = "3.18.1-WDS";
                    }
                    else
                    {
                        ddlHostKernel.Items.Insert(0, "Select Kernel");
                    }
                }
                catch { }

                try
                {
                    ddlHostBootImage.DataSource = Utility.GetBootImages();
                    ddlHostBootImage.DataBind();
                    ListItem itemBootImage = ddlHostBootImage.Items.FindByText("initrd.gz");
                    if (itemBootImage != null)
                    {
                        ddlHostBootImage.SelectedValue = "initrd.gz";
                    }
                    else
                    {
                        ddlHostBootImage.Items.Insert(0, "Select Boot Image");
                    }
                }
                catch { }
            }
        }

        else if (ddlTemplate.Text == "new template")
        {
            createNewTemplate.Visible = true;
            bootPasswords.Visible     = false;
            modifyTemplate.Visible    = false;
        }

        else if (ddlTemplate.Text == "select template")
        {
            createNewTemplate.Visible = false;
            bootPasswords.Visible     = false;
            modifyTemplate.Visible    = false;
        }
        else if (ddlTemplate.Text == "---------------")
        {
            //do nothing
        }
        else
        {
            modifyTemplate.Visible     = true;
            createNewTemplate.Visible  = false;
            bootPasswords.Visible      = false;
            txtModifyTemplate.ReadOnly = true;
            BootTemplate template = new BootTemplate().Read(ddlTemplate.Text);
            txtModifyTemplate.Text     = template.templateName;
            txtAreaModifyTemplate.Text = template.templateContent;
        }
    }
Exemple #14
0
    public BootTemplate Read(string templateName)
    {
        BootTemplate template = new BootTemplate();
        try
        {
            using (NpgsqlConnection conn = new NpgsqlConnection(Utility.DBString))
            {
                NpgsqlCommand cmd = new NpgsqlCommand("boottemplates_read", conn);
                cmd.CommandType = CommandType.StoredProcedure;
                cmd.Parameters.Add(new NpgsqlParameter("@templateName", templateName));
                conn.Open();
                NpgsqlDataReader rdr = cmd.ExecuteReader();
                while (rdr.Read())
                {
                    template.templateName = (string)rdr["templatename"];
                    template.templateContent = (string)rdr["templatecontent"];

                }
            }
        }
        catch (Exception ex)
        {
            Utility.Message = "Could Not Read Boot Menu.  Check The Exception Log For More Info";
            Logger.Log(ex.ToString());
        }
        return template;
    }