Esempio n. 1
0
        public async Task <IActionResult> StartInstancesAsync()
        {
            string reqBody      = "";
            string instanceType = "";

            // string cmd ="";
            try
            {
                //read request body
                using (var reader = new StreamReader(Request.Body))
                {
                    var body = await reader.ReadToEndAsync();

                    reqBody = body.ToString();
                }
                //
                IList <InstanceResponse> getAllInstances = InstancePayload.Get();
                //
                JObject jObj = JObject.Parse(reqBody);
                instanceType = jObj["type"].ToString();

                switch (instanceType)
                {
                case "ZMK":
                    #region start ZMK instances
                    try
                    {
                        string unassigned = ZMKDockerCmdHelper.GetUnassignedZMKInstance();
                        if (!string.IsNullOrEmpty(unassigned))
                        {
                            ZMKDockerCmdHelper.StartZMKInstance(unassigned);
                        }
                    }
                    catch (Exception ex)
                    {
                        return(BadRequest(new { message = "starting instance failed.", exception = ex.StackTrace }));
                    }
                    #endregion

                    break;
                }
            }
            catch (Exception ex)
            {
                return(BadRequest(new { message = "starting instance failed.", exception = ex.StackTrace }));
            }

            return(Ok());
        }