Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();

            WebApiConfig.Register(GlobalConfiguration.Configuration);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            AuthConfig.RegisterAuth();

            // Add the DesktopManagerFactory
            CtxTrace.Initialize("self-service-desktops-webapp");
            IDesktopManagerFactory factory = new DesktopManagerFactory();
            //            IDesktopManagerFactory factory = new MockDesktopManagerFactory();
            HttpContext.Current.Application.Add("IDesktopManagerFactory", factory);
        }
Ejemplo n.º 2
0
        public void TestSsoLocal(Account user)
        {
            try {
                SessionDefinition session = GetSession(user);

                IDesktopManagerFactory factory = new DesktopManagerFactory();
                string sessionKey = session.SessionKey;
                string jsessionId = session.SessionCookie.Value;
                Console.WriteLine("Create desktop manager with sessionkey {0}, jsessionid {1}", sessionKey, jsessionId );
                IDesktopManager manager = factory.CreateManager(user.Name, sessionKey, jsessionId, user.Domain);
                IEnumerable<IDesktop> desktops = manager.ListDesktops();
                Console.WriteLine("Enumerated desktops");

            } catch (Exception e) {
                Console.WriteLine(e);
            }
        }
Ejemplo n.º 3
0
        public void TestDesktopManager(Account user)
        {
            DesktopManagerFactory factory = new DesktopManagerFactory();
            IDesktopManager manager = (user.Domain == null) ?
                factory.CreateManager(user.Name, user.Password) : factory.CreateManager(user.Name, user.Password, user.Domain);

            IEnumerable<IDesktopOffering> offerings = manager.ListDesktopOfferings();
            DisplayOfferings(offerings);

            IEnumerable<IDesktop> desktops = manager.ListDesktops();
            DisplayDesktops(desktops);
            int count = desktops.Count();

            IDesktop newDesktop = manager.CreateDesktop(offerings.First().Name);
            Console.WriteLine("New desktop is {0}", newDesktop);

            // Check the new desktop appears in the list
            desktops = manager.ListDesktops();
            if (desktops.Count() != count + 1) {
                Console.WriteLine("Error: Got {0} desktops in list; expected {1}", desktops.Count(), count + 1);
                throw new ApplicationException("DesktopManager fail");
            }

            operationsInProgress = new List<string>();

            // Try delete operation on a desktop
            desktops = manager.ListDesktops();
            foreach (IDesktop d in desktops) {
                if (!operationInPogress(d.Id) && d.State == VirtualMachineState.Running) {
                    Console.WriteLine("Attempting to destroy {0}", d);
                    manager.DestroyDesktop(d.Id);
                    operationsInProgress.Add(d.Id);
                    break;
                }
            }

            // Try start operation on a desktop
            foreach (IDesktop d in desktops) {
                if (!operationInPogress(d.Id) && d.State == VirtualMachineState.Stopped) {
                    Console.WriteLine("Attempting start of {0}", d);
                    manager.StartDesktop(d.Id);
                    operationsInProgress.Add(d.Id);
                    break;
                }
            }

            // Try stop operation on a desktop
            foreach (IDesktop d in desktops) {
                if (!operationInPogress(d.Id) && d.State == VirtualMachineState.Running) {
                    Console.WriteLine("Attempting stop of {0}", d);
                    manager.StopDesktop(d.Id);
                    operationsInProgress.Add(d.Id);
                    break;
                }
            }

            // Try restart operation on a desktop
            foreach (IDesktop d in desktops) {
                if (!operationInPogress(d.Id) && d.State == VirtualMachineState.Running) {
                    Console.WriteLine("Attempting restart of {0}", d);
                    manager.RestartDesktop(d.Id);
                    operationsInProgress.Add(d.Id);
                    break;
                }
            }

            desktops = manager.ListDesktops();
            DisplayDesktops(desktops);
        }