public ActionResult CreateContainer(int id)
        {
            MasterContainersManagement masterContainersManagement = new MasterContainersManagement();

            UpdateInProgressMessage(id, "Creating Master Container");
            AsynchronousCallback ContainerThread = new AsynchronousCallback(masterContainersManagement.CreateCloud);
            ContainerThread.BeginInvoke(id, null, null);

            return RedirectToAction("CloudDetails", "CloudManagement", new { id = id });
        }
        //Check this function in CosoleForm: private ContainerMetadata SaveOrUpdateContainer(Uri anekaDaemonServiceUrl, ContainerProperty property, int previousImageIndex)
        public void UpdateContainers(global::Aneka.PAL.Management.Model.Machine anekaDaemonMachine)
        {
            IDaemonProxy proxy = ProxyCreator.CreateDaemonProxy(anekaDaemonMachine.DaemonUri);
            ContainerProperty[] properties = proxy.QueryContainers(new string[] { });

            foreach (ContainerProperty property in properties)
            {
                string tmpConfig = Path.GetTempFileName();
                if (string.IsNullOrEmpty(property.ConfigurationBase64Content) == false)
                {
                    //write aneka xml to the tmp config file
                    IOUtil.WriteBase64EncodedToFile(tmpConfig, property.ConfigurationBase64Content);

                    //load the aneka clone from the tmp config
                    global::Aneka.Runtime.Configuration configure = global::Aneka.Runtime.Configuration.GetConfiguration(tmpConfig);

                    //create a new container metadata with updated clone properties
                    bool isMaster = configure.NodeType != global::Aneka.Runtime.NodeType.Worker;
                    if (isMaster)
                    {
                        MasterContainersManagement masterContainersManagement = new MasterContainersManagement();
                        masterContainersManagement.buildExistMaster(configure, property);
                    }
                    else
                    {
                        //Uri uri = new Uri(configure.IndexServerUri);
                        //CloudWebPortal.Areas.Aneka.Models.Machine machine = db.Machines.Where(x => x.IP == uri.Host).First();
                        //Cloud cloud = db.Clouds.Where(x => ).First();//MUST GET THE CLOUD
                        //Worker worker = new Worker();

                        //worker.Port = uri.Port;

                        //if (property.Status == ContainerStatus.Started)
                        //{
                        //    IContainerManagerProxy containerProxy = ProxyCreator.CreateContainerManagerProxy();
                        //    NodeInfo nodeInfo = containerProxy.GetNodeInfo(uri.ToString());

                        //    if (nodeInfo != null)
                        //    {
                        //        worker.isQuarantined = containerProxy.NodeQuarantined(nodeInfo.IndexServerUri, nodeInfo.Id);
                        //        //metadata.Services = nodeInfo.GetServices(); //MUST BE DONE
                        //    }

                        //}

                    }

                    //! metadata = new ContainerMetadata(string.Format("tcp://{0}:{1}/Aneka", anekaDaemonServiceUrl.Host, configure.Port));
                    //! metadata.InternalId = configure.Id;
                    //! metadata.AnekaDaemonServiceUrl = anekaDaemonServiceUrl;
                }
            }
        }
        public ActionResult RefreshMaster(int id)
        {
            MasterContainersManagement masterContainersManagement = new MasterContainersManagement();

            masterContainersManagement.RefreshMaster(id);

            return RedirectToAction("CloudDetails", "CloudManagement", new { id = id });
        }
        public ActionResult Details(int id)
        {
            MasterContainersManagement masterContainersManagement = new MasterContainersManagement();

            //Get the cloud entity from the database
            Cloud cloud = db.Clouds.Find(id);

            if (cloud == null)
            {
                cloud = new Cloud();
                cloud.CloudName = "Cloud could not be found";
                return PartialView();
            }

            //Pass the master machine entity to the view
            ViewBag.MasterMachine = masterContainersManagement.machineLookupFromMasterId(cloud.Master.MasterId);

            //Create and pass a Dictionary to the view, the key is the worker ID, and the value id the machine entity.
            Dictionary<int, Machine> WorkersMachines = new Dictionary<int, Machine>();
            List<Machine> AllMachines = db.Machines.ToList();
            foreach (Worker worker in cloud.Workers)
            {
                foreach (Machine machine in AllMachines)
                {
                    if(machine.Workers.Contains(worker))
                        WorkersMachines.Add(worker.WorkerId,machine);
                }
            }
            ViewBag.WorkersMachines = WorkersMachines;

            //Pass the cloud entity to the view
            return PartialView(cloud);
        }