Exemplo n.º 1
0
        static bool Services(IList <string> unparsed)
        {
            IVcapClient vc = new VcapClient();
            IEnumerable <SystemService> systemServices = vc.GetSystemServices();

            if (false == systemServices.IsNullOrEmpty())
            {
                Console.WriteLine(systemHeader);
                foreach (SystemService s in systemServices)
                {
                    Console.WriteLine("{0}     {1}     {2}", s.Vendor, s.Version, s.Description);
                }
            }

            IEnumerable <ProvisionedService> provisionedServices = vc.GetProvisionedServices();

            if (false == provisionedServices.IsNullOrEmpty())
            {
                Console.WriteLine();
                Console.WriteLine(provisionedHeader);
                foreach (ProvisionedService s in provisionedServices)
                {
                    Console.WriteLine("{0}     {1}", s.Name, s.Vendor);
                }
            }

            return(true);
        }
Exemplo n.º 2
0
        static bool Services(IList<string> unparsed)
        {
            IVcapClient vc = new VcapClient();
            IEnumerable<SystemService> systemServices = vc.GetSystemServices();
            if (false == systemServices.IsNullOrEmpty())
            {
                Console.WriteLine(systemHeader);
                foreach (SystemService s in systemServices)
                {
                    Console.WriteLine("{0}     {1}     {2}", s.Vendor, s.Version, s.Description);
                }
            }

            IEnumerable<ProvisionedService> provisionedServices = vc.GetProvisionedServices();
            if (false == provisionedServices.IsNullOrEmpty())
            {
                Console.WriteLine();
                Console.WriteLine(provisionedHeader);
                foreach (ProvisionedService s in provisionedServices)
                {
                    Console.WriteLine("{0}     {1}", s.Name, s.Vendor);
                }
            }

            return true;
        }
Exemplo n.º 3
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);
        }
        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;
        }