Esempio n. 1
0
        public ProviderResponse <Cloud> Connect(Cloud cloud)
        {
            var response = new ProviderResponse <Cloud>();

            if (cloud.IsDataComplete)
            {
                Cloud       local  = cloud.DeepCopy();
                IVcapClient client = new VcapClient(local);
                try
                {
                    VcapClientResult result = client.Login();
                    if (false == result.Success)
                    {
                        response.Response = null;
                        response.Message  = result.Message;
                    }
                    else
                    {
                        local.AccessToken = client.CurrentToken;
                        var applications        = client.GetApplications();
                        var provisionedServices = client.GetProvisionedServices();
                        var availableServices   = client.GetSystemServices();
                        local.Applications.Synchronize(new SafeObservableCollection <Application>(applications), new ApplicationEqualityComparer());
                        local.Services.Synchronize(new SafeObservableCollection <ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer());
                        local.AvailableServices.Synchronize(new SafeObservableCollection <SystemService>(availableServices), new SystemServiceEqualityComparer());
                        foreach (Application app in local.Applications)
                        {
                            var instances = GetInstances(local, app);
                            if (instances.Response != null)
                            {
                                app.InstanceCollection.Synchronize(new SafeObservableCollection <Instance>(instances.Response), new InstanceEqualityComparer());
                            }
                        }
                        response.Response = local;
                    }
                }
                catch (Exception ex)
                {
                    response.Message = ex.Message;
                }
            }
            else
            {
                response.Message = Resources.CloudFoundryProvider_ConnectIncompleteData_Message;
            }

            return(response);
        }
Esempio n. 2
0
 public void Get_All_Users_And_Apps()
 {
     var client = new VcapClient("http://api.ironfoundry.me");
     client.Login("*****@*****.**", "password");
     var users = client.GetUsers();
     Assert.NotEmpty(users);
     foreach (var user in users)
     {
         Console.WriteLine("User: {0}", user.Email);
         client.ProxyAs(user);
         var apps = client.GetApplications();
         foreach (var app in apps)
         {
             Console.WriteLine("\t\tApp: {0}", app.Name);
         }
     }
 }
Esempio n. 3
0
        private static void ConnectToCloudFoundry(string url, string login, string password)
        {
            if (String.IsNullOrEmpty(url))
            {
                throw new ArgumentNullException("url");
            }

            if (String.IsNullOrEmpty(login))
            {
                throw new ArgumentNullException("login");
            }

            if (String.IsNullOrEmpty(password))
            {
                throw new ArgumentNullException("password");
            }

            var client = new VcapClient(new Uri(url), new StableDataStorage());

            client.Login(login, password);


            Console.WriteLine("--- Organizations: ---");
            foreach (var organization in client.GetOrganizations())
            {
                Console.WriteLine(organization.Entity.Name);
            }
            Console.WriteLine();

            Console.WriteLine("--- Spaces: ---");
            foreach (var space in client.GetSpaces())
            {
                Console.WriteLine(space.Entity.Name);
            }
            Console.WriteLine();

            Console.WriteLine("--- Apps: ---");
            foreach (var app in client.GetApplications())
            {
                Console.WriteLine(app.Entity.Name);
            }
            Console.WriteLine();

            Console.WriteLine("Everything is OK.");
            Console.ReadLine();
        }
Esempio n. 4
0
        public void Get_All_Users_And_Apps()
        {
            var client = new VcapClient("http://api.ironfoundry.me");

            client.Login("*****@*****.**", "password");
            var users = client.GetUsers();

            Assert.NotEmpty(users);
            foreach (var user in users)
            {
                Console.WriteLine("User: {0}", user.Email);
                client.ProxyAs(user);
                var apps = client.GetApplications();
                foreach (var app in apps)
                {
                    Console.WriteLine("\t\tApp: {0}", app.Name);
                }
            }
        }
Esempio n. 5
0
        static bool Apps(IList <string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [apps]");
                Console.Error.WriteLine("Usage: vmc apps");
                return(false);
            }
            IVcapClient vc = new VcapClient();
            IEnumerable <Application> apps = vc.GetApplications();

            if (false == apps.IsNullOrEmpty())
            {
                foreach (Application a in apps)
                {
                    Console.WriteLine("App name: {0} Instances: {1} State: {2} Services: {3}",
                                      a.Name, a.RunningInstances, a.State, String.Join(", ", a.Services));
                }
            }
            return(true);
        }
Esempio n. 6
0
 static bool Apps(IList<string> unparsed)
 {
     // TODO match ruby argument parsing
     if (unparsed.Count != 0)
     {
         Console.Error.WriteLine("Too many arguments for [apps]");
         Console.Error.WriteLine("Usage: vmc apps"); // TODO usage statement standardization
         return false;
     }
     IVcapClient vc = new VcapClient();
     IEnumerable<Application> apps = vc.GetApplications();
     if (false == apps.IsNullOrEmpty())
     {
         foreach (Application a in apps)
         {
             Console.WriteLine("App name: {0} Instances: {1} State: {2} Services: {3}",
                 a.Name, a.RunningInstances, a.State, String.Join(", ", a.Services));
         }
     }
     return true;
 }
        public ProviderResponse<Cloud> Connect(Cloud cloud)
        {
            var response = new ProviderResponse<Cloud>();

            if (cloud.IsDataComplete)
            {
                Cloud local = cloud.DeepCopy();
                IVcapClient client = new VcapClient(local);
                try
                {
                    client.Login();
                    local.AccessToken = client.CurrentToken;
                    var applications = client.GetApplications();
                    var provisionedServices = client.GetProvisionedServices();
                    var availableServices = client.GetSystemServices();
                    local.Applications.Synchronize(new SafeObservableCollection<Application>(applications), new ApplicationEqualityComparer());
                    local.Services.Synchronize(new SafeObservableCollection<ProvisionedService>(provisionedServices), new ProvisionedServiceEqualityComparer());
                    local.AvailableServices.Synchronize(new SafeObservableCollection<SystemService>(availableServices), new SystemServiceEqualityComparer());
                    foreach (Application app in local.Applications)
                    {
                        var instances = GetInstances(local, app);
                        if (instances.Response != null)
                            app.InstanceCollection.Synchronize(new SafeObservableCollection<Instance>(instances.Response), new InstanceEqualityComparer());
                    }
                    response.Response = local;
                }
                catch (Exception ex)
                {
                    response.Response = null;
                    response.Message = ex.Message;
                }
            }
            else
            {
                response.Message = Resources.CloudFoundryProvider_ConnectIncompleteData_Message;
            }

            return response;
        }