Exemple #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string webhookURL            = (WebConfigurationManager.ConnectionStrings["StartVMWebhookURL"]).ConnectionString;
            string ManageAzureVMsFuncURL = (WebConfigurationManager.ConnectionStrings["ManageAzureVMsFunc"]).ConnectionString;

            using (WebClient webClient = new WebClient())
            {
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
                Response.Write("Manage the K8S VMs <br>");

                //post data to webhooker
                Response.Write("Starting K8S VMs but send request to runbook web hooker <br>");
                webClient.Headers[HttpRequestHeader.ContentType] = "application/x-www-form-urlencoded";
                webClient.UploadString(webhookURL, "");

                // post data to function url to stop three vms.
                Uri functionUri = new Uri(ManageAzureVMsFuncURL);
                for (int i = 1; i <= 3; i++)
                {
                    VMControl vmControl = new VMControl("kangxhvmseaoss" + i.ToString(), "az-rg-kangxh-oss", "deallocate", 5);
                    string    manageAzureVMsFuncContent = JsonConvert.SerializeObject(vmControl);
                    webClient.Headers[HttpRequestHeader.ContentType] = "application/json";
                    webClient.UploadString(ManageAzureVMsFuncURL, manageAzureVMsFuncContent);

                    Response.Write("queue tasks to Functions so that " + vmControl.VMName + " will be turn off after 5min <br>");
                }
            }

            Response.Redirect("http://www.kangxh.com:83");
        }
Exemple #2
0
        public Sandbox(Configuration config)
        {
            this.config = config;
            var v = config.DynamicAnalysis.Virtualization;

            vmcontrol = ModuleLoader <VMControl> .LoadModule(v.VMControlAssembly, v.VMControlClass, v.VMName, v.Username, v.Password, v.Domain);

            dal          = new SandboxDAL();
            objExtracted = dal.addObject;
        }