Beispiel #1
0
        private void OnCmdRebootInstance(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerRebootInstance args   = msg.DeserializeAs <ManagerRebootInstance>();
            MasterCommandLogger   logger = new MasterCommandLogger(msg);

            //Find instance
            ManagerInstance instance = session.GetInstanceById(long.Parse(args.instance_id));

            if (instance == null)
            {
                logger.FinishFail("Could not find that instance on the server.");
                return;
            }

            //Run
            try
            {
                //Shut down instance
                logger.Log("REBOOT", "Shutting down instance...");
                bool graceful = instance.StopInstance();
                if (!graceful)
                {
                    logger.Log("REBOOT", "Instance was shut down forcefully!");
                }

                //Start
                instance.StartInstance(session);
            }
            catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }
Beispiel #2
0
        private void OnCmdAssignSite(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerAssignSite   args   = msg.DeserializeAs <ManagerAssignSite>();
            MasterCommandLogger logger = new MasterCommandLogger(msg);

            //Update if it was supposed to be null
            if (args.site_id == "")
            {
                args.site_id = null;
            }

            //Find instance
            ManagerInstance instance = session.GetInstanceById(long.Parse(args.instance_id));

            if (instance == null)
            {
                logger.FinishFail("Could not find that instance on the server.");
                return;
            }

            //Run
            try
            {
                //Update
                instance.site_id = args.site_id;
                session.Save();
                session.RefreshSites();
            }
            catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }
Beispiel #3
0
        private void OnCmdRemoveInstance(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerUpdateInstance args   = msg.DeserializeAs <ManagerUpdateInstance>();
            MasterCommandLogger   logger = new MasterCommandLogger(msg);

            //Find instance
            ManagerInstance instance = session.GetInstanceById(long.Parse(args.instance_id));

            if (instance == null)
            {
                logger.FinishFail("Could not find that instance on the server.");
                return;
            }

            //Run
            try
            {
                instance.DestoryInstance(session, logger);
            }
            catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }
Beispiel #4
0
        private void OnCmdAddPackage(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerAddPackage   args   = msg.DeserializeAs <ManagerAddPackage>();
            MasterCommandLogger logger = new MasterCommandLogger(msg);

            //Run
            try
            {
                session.AddPackage(args, logger);
            } catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }
Beispiel #5
0
        private void OnCmdDeleteVersion(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerDeleteVersion args   = msg.DeserializeAs <ManagerDeleteVersion>();
            MasterCommandLogger  logger = new MasterCommandLogger(msg);

            //Find package
            if (!session.versions.ContainsKey(args.version_id))
            {
                logger.FinishFail("Could not find that version on the server.");
                return;
            }
            ManagerVersion version = session.versions[args.version_id];

            //Run
            try
            {
                version.DeleteVersion(session, logger);
            }
            catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }
Beispiel #6
0
        private void OnCmdAddInstance(RouterMessage msg)
        {
            //Decode arguments and create logger
            ManagerAddInstance  args   = msg.DeserializeAs <ManagerAddInstance>();
            MasterCommandLogger logger = new MasterCommandLogger(msg);

            //Find package
            if (!session.packages.ContainsKey(args.package_name))
            {
                logger.FinishFail("Could not find that package on the server.");
                return;
            }
            ManagerPackage package = session.packages[args.package_name];

            //Run
            try
            {
                session.CreateNewInstance(package, logger, args.count, true);
            }
            catch (Exception ex)
            {
                logger.FinishFail($"Unexpected error: {ex.Message}{ex.StackTrace}");
            }
        }