コード例 #1
0
        static bool AddUser(IList <string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [add_user]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc add-user"); // TODO usage statement standardization
                return(false);
            }

            Console.Write("Email: ");
            string email = Console.ReadLine();

            Console.Write("Password: "******"Verify Password: "******"Creating New User: "******"OK");
                return(true);
            }
            else
            {
                Console.Error.WriteLine("Passwords did not match!");
                return(false);
            }
        }
コード例 #2
0
        static bool Files(IList <string> unparsed)
        {
            if (unparsed.Count > 2)
            {
                Console.Error.WriteLine("Too many arguments for [files]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc files <appname> <path>");
                return(false);
            }
            if (unparsed.Count < 1)
            {
                Console.Error.WriteLine("Not enough arguments for [files]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc files <appname> <path (optional)>");
                return(false);
            }

            string appname = unparsed[0];
            string path    = String.Empty;

            if (unparsed.Count == 2)
            {
                path = unparsed[1];
            }

            IVcapClient vc = new VcapClient();

            byte[] output = vc.FilesSimple(appname, path, 0);
            if (false == output.IsNullOrEmpty())
            {
                Stream stdout = Console.OpenStandardOutput();
                stdout.Write(output, 0, output.Length);
                stdout.Flush();
            }
            return(true);
        }
コード例 #3
0
ファイル: Services.cs プロジェクト: chandermani/ironfoundry
        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);
        }
コード例 #4
0
ファイル: Services.cs プロジェクト: ademar/ironfoundry
        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;
        }
コード例 #5
0
ファイル: AddUser.cs プロジェクト: ademar/ironfoundry
        static bool AddUser(IList<string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [add_user]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc add-user"); // TODO usage statement standardization
                return false;
            }

            Console.Write("Email: ");
            string email = Console.ReadLine();

            Console.Write("Password: "******"Verify Password: "******"Creating New User: "******"OK");
                return true;
            }
            else
            {
                Console.Error.WriteLine("Passwords did not match!");
                return false;
            }
        }
コード例 #6
0
 public void with_known_good_cloud_target()
 {
     CloudActive = new VcapClient(TestAccountInformation.GoodUri.ToString());
     CloudActive.Login(
         TestAccountInformation.Username,
         TestAccountInformation.Password);
 }
コード例 #7
0
ファイル: Update.cs プロジェクト: ademar/ironfoundry
        static bool Update(IList<string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc update <appname> <path>"); // TODO usage statement standardization
                return false;
            }

            string appname = unparsed[0];
            string path    = unparsed[1];

            DirectoryInfo di = null;
            if (Directory.Exists(path))
            {
                di = new DirectoryInfo(path);
            }
            else
            {
                Console.Error.WriteLine(String.Format("Directory '{0}' does not exist."));
                return false;
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rv = vc.Update(appname, di);
            if (false == rv.Success)
            {
                Console.Error.WriteLine(rv.Message);
            }
            return rv.Success;
        }
コード例 #8
0
ファイル: Passwd.cs プロジェクト: ademar/ironfoundry
        static bool Passwd(IList<string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [change_password]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc passwd"); // TODO usage statement standardization
                return false;
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Info();
            Info info = rslt.GetResponseMessage<Info>();

            Console.WriteLine("Changing password for '{0}'", info.User);

            Console.Write("New Password: "******"Verify Password: "******"Passwords did not match!");
                return false;
            }
        }
コード例 #9
0
        static bool Passwd(IList <string> unparsed)
        {
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Too many arguments for [change_password]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc passwd"); // TODO usage statement standardization
                return(false);
            }

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.Info();
            Info             info = rslt.GetResponseMessage <Info>();

            Console.WriteLine("Changing password for '{0}'", info.User);

            Console.Write("New Password: "******"Verify Password: "******"Passwords did not match!");
                return(false);
            }
        }
コード例 #10
0
ファイル: Update.cs プロジェクト: techpitts/ironfoundry
        static bool Update(IList <string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc update <appname> <path>"); // TODO usage statement standardization
                return(false);
            }

            string appname = unparsed[0];
            string path    = unparsed[1];

            DirectoryInfo di = null;

            if (Directory.Exists(path))
            {
                di = new DirectoryInfo(path);
            }
            else
            {
                Console.Error.WriteLine(String.Format("Directory '{0}' does not exist."));
                return(false);
            }

            IVcapClient      vc = new VcapClient();
            VcapClientResult rv = vc.Update(appname, di);

            if (false == rv.Success)
            {
                Console.Error.WriteLine(rv.Message);
            }
            return(rv.Success);
        }
コード例 #11
0
ファイル: UserTests.cs プロジェクト: kirannadell/ironfoundry
 public void Stop_App_As_User()
 {
     IVcapClient client = new VcapClient("http://api.ironfoundry.me");
     client.Login("*****@*****.**", "password");
     VcapUser user = client.GetUser("otheruser");
     client.ProxyAs(user);
     client.Stop("appname");
 }
コード例 #12
0
ファイル: Info.cs プロジェクト: techpitts/ironfoundry
        static bool Info(IList <string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Usage: vmc info"); // TODO usage statement standardization
                return(false);
            }

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.Info();

            if (rslt.Success)
            {
                var info = rslt.GetResponseMessage <Info>();
                if (result_as_json || result_as_rawjson)
                {
                    if (result_as_rawjson)
                    {
                        Console.WriteLine(info.RawJson);
                    }
                    if (result_as_json)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(info, Formatting.Indented));
                    }
                }
                else
                {
                    Version ver = Assembly.GetExecutingAssembly().GetName().Version;

                    Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_1_Fmt,
                                                    info.Description, info.Support, vc.CurrentUri, info.Version, ver));

                    if (false == info.User.IsNullOrEmpty())
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_2_Fmt, info.User));
                    }

                    if (null != info.Usage && null != info.Limits)
                    {
                        string tmem = pretty_size(info.Limits.Memory * 1024 * 1024);
                        string mem  = pretty_size(info.Usage.Memory * 1024 * 1024);

                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_3_Fmt,
                                                        mem, tmem,
                                                        info.Usage.Services, info.Limits.Services,
                                                        info.Usage.Apps, info.Limits.Apps));
                    }
                }
            }
            else
            {
                // TODO standardize errors
                Console.Error.WriteLine(String.Format("Error: {0}", rslt.Message));
            }

            return(rslt.Success);
        }
コード例 #13
0
ファイル: Tests.cs プロジェクト: ademar/ironfoundry
 static bool TestStats(IList<string> unparsed)
 {
     string appname = unparsed[0];
     IVcapClient vc = new VcapClient();
     Application app = vc.GetApplication(appname);
     IEnumerable<StatInfo> result = vc.GetStats(app);
     Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
     return true;
 }
コード例 #14
0
ファイル: Tests.cs プロジェクト: ademar/ironfoundry
 static bool TestFiles(IList<string> unparsed)
 {
     string appname = unparsed[0];
     string path = unparsed[1];
     IVcapClient vc = new VcapClient();
     VcapFilesResult result = vc.Files(appname, path, 0);
     Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
     return true;
 }
コード例 #15
0
ファイル: Info.cs プロジェクト: ademar/ironfoundry
        static bool Info(IList<string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 0)
            {
                Console.Error.WriteLine("Usage: vmc info"); // TODO usage statement standardization
                return false;
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Info();
            if (rslt.Success)
            {
                var info = rslt.GetResponseMessage<Info>();
                if (result_as_json || result_as_rawjson)
                {
                    if (result_as_rawjson)
                    {
                        Console.WriteLine(info.RawJson);
                    }
                    if (result_as_json)
                    {
                        Console.WriteLine(JsonConvert.SerializeObject(info, Formatting.Indented));
                    }
                }
                else
                {
                    Version ver = Assembly.GetExecutingAssembly().GetName().Version;

                    Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_1_Fmt,
                        info.Description, info.Support, vc.CurrentUri, info.Version, ver));

                    if (false == info.User.IsNullOrEmpty())
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_2_Fmt, info.User));
                    }

                    if (null != info.Usage && null != info.Limits)
                    {
                        string tmem = pretty_size(info.Limits.Memory * 1024 * 1024);
                        string mem = pretty_size(info.Usage.Memory * 1024 * 1024);

                        Console.WriteLine(String.Format(Resources.Vmc_InfoDisplay_3_Fmt,
                            mem, tmem,
                            info.Usage.Services, info.Limits.Services,
                            info.Usage.Apps, info.Limits.Apps));
                    }
                }
            }
            else
            {
                // TODO standardize errors
                Console.Error.WriteLine(String.Format("Error: {0}", rslt.Message));
            }

            return rslt.Success;
        }
コード例 #16
0
        static bool TestStats(IList <string> unparsed)
        {
            string                 appname = unparsed[0];
            IVcapClient            vc      = new VcapClient();
            Application            app     = vc.GetApplication(appname);
            IEnumerable <StatInfo> result  = vc.GetStats(app);

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
            return(true);
        }
コード例 #17
0
        static bool TestFiles(IList <string> unparsed)
        {
            string          appname = unparsed[0];
            string          path    = unparsed[1];
            IVcapClient     vc      = new VcapClient();
            VcapFilesResult result  = vc.Files(appname, path, 0);

            Console.WriteLine(JsonConvert.SerializeObject(result, Formatting.Indented));
            return(true);
        }
コード例 #18
0
ファイル: UserTests.cs プロジェクト: niemyjski/ironfoundry
        public void Stop_App_As_User()
        {
            IVcapClient client = new VcapClient("http://api.ironfoundry.me");

            client.Login("*****@*****.**", "password");
            VcapUser user = client.GetUser("otheruser");

            client.ProxyAs(user);
            client.Stop("appname");
        }
コード例 #19
0
        public void Test_Using_Host_And_IPAddress_Against_Local()
        {
            string ipStr = "172.21.114.11";
            string host  = "api.vcap.me";

            var       uri = new Uri("http://" + host);
            IPAddress ip;

            IPAddress.TryParse(ipStr, out ip);
            var client = new VcapClient(uri, ip);

            client.Login("*****@*****.**", "Password");
        }
コード例 #20
0
ファイル: Services.cs プロジェクト: ademar/ironfoundry
        static bool DeleteService(IList<string> unparsed)
        {
            if (unparsed.Count != 1)
            {
                Console.Error.WriteLine("Usage: vmc delete-service <servicename>"); // TODO usage statement standardization
                return false;
            }

            string svcname = unparsed[0];

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.DeleteService(svcname);
            return rslt.Success;
        }
コード例 #21
0
        public void with_a_standard_default_application()
        {
            cloudActive = new VcapClient(TestAccountInformation.GoodUri.ToString());
            cloudActive.Login(
                TestAccountInformation.Username,
                TestAccountInformation.Password);

            var currentDirectory = Directory.GetCurrentDirectory();
            var pathToTestApp = new DirectoryInfo(currentDirectory + TestAccountInformation.TestAppToPush);

            cloudActive.Push(TestAccountInformation.TestApplicationName, TestAccountInformation.HttpIntegrationTestApiIronfoundryMe, 1,
                pathToTestApp, 64, null);
            testApplication = cloudActive.GetApplication(TestAccountInformation.TestApplicationName);
        }
コード例 #22
0
        public ProviderResponse <SafeObservableCollection <StatInfo> > GetStats(Cloud cloud, Application application)
        {
            ProviderResponse <SafeObservableCollection <StatInfo> > response = new ProviderResponse <SafeObservableCollection <StatInfo> >();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                response.Response = new SafeObservableCollection <StatInfo>(client.GetStats(application));
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #23
0
        public ProviderResponse <SafeObservableCollection <ProvisionedService> > GetProvisionedServices(Cloud cloud)
        {
            ProviderResponse <SafeObservableCollection <ProvisionedService> > response = new ProviderResponse <SafeObservableCollection <ProvisionedService> >();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                response.Response = new SafeObservableCollection <ProvisionedService>(client.GetProvisionedServices());
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #24
0
        public ProviderResponse <IEnumerable <StatInfo> > GetStats(Application app, Cloud cloud)
        {
            var response = new ProviderResponse <IEnumerable <StatInfo> >();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                response.Response = client.GetStats(app);
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #25
0
 public ProviderResponse<bool> ChangePassword(Cloud cloud, string newPassword)
 {
     var response = new ProviderResponse<bool>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         client.ChangePassword(newPassword);
         response.Response = true;
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #26
0
ファイル: Services.cs プロジェクト: chandermani/ironfoundry
        static bool DeleteService(IList <string> unparsed)
        {
            if (unparsed.Count != 1)
            {
                Console.Error.WriteLine("Usage: vmc delete-service <servicename>");
                return(false);
            }

            string svcname = unparsed[0];

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.DeleteService(svcname);

            return(rslt.Success);
        }
コード例 #27
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);
        }
コード例 #28
0
        public ProviderResponse <bool> Update(Cloud cloud, Application app, string directoryToPushFrom)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.Update(app.Name, new System.IO.DirectoryInfo(directoryToPushFrom));
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #29
0
        public ProviderResponse <bool> ChangePassword(Cloud cloud, string newPassword)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.ChangePassword(newPassword);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #30
0
        public ProviderResponse <bool> CreateService(Cloud cloud, string serviceName, string provisionedServiceName)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.CreateService(serviceName, provisionedServiceName);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #31
0
ファイル: Services.cs プロジェクト: ademar/ironfoundry
        static bool BindService(IList<string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc bind-service <servicename> <appname>"); // TODO usage statement standardization
                return false;
            }

            string svcname = unparsed[0];
            string appname = unparsed[1];

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.BindService(svcname, appname);
            return rslt.Success;
        }
コード例 #32
0
ファイル: Services.cs プロジェクト: chandermani/ironfoundry
        static bool UnbindService(IList <string> unparsed)
        {
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc unbind-service <servicename> <appname>");
                return(false);
            }

            string svcname = unparsed[0];
            string appname = unparsed[1];

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.UnbindService(svcname, appname);

            return(rslt.Success);
        }
コード例 #33
0
        public ProviderResponse <bool> Restart(Application app, Cloud cloud)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.Restart(app);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #34
0
        public ProviderResponse <bool> Delete(Application app, Cloud cloud)
        {
            ProviderResponse <bool> response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.Delete(app.Name);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #35
0
        public ProviderResponse <VcapFilesResult> GetFiles(Cloud cloud, Application application, string path, ushort instanceId)
        {
            ProviderResponse <VcapFilesResult> response = new ProviderResponse <VcapFilesResult>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                var         result = client.Files(application.Name, path, instanceId);
                response.Response = result;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #36
0
        static bool CreateService(IList <string> unparsed)
        {
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc create-service <service> <servicename>"); // TODO usage statement standardization
                return(false);
            }

            string svc     = unparsed[0];
            string svcname = unparsed[1];

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.CreateService(svc, svcname);

            return(rslt.Success);
        }
コード例 #37
0
        public void Test_Using_Host_And_IPAddress()
        {
            IPAddress ip   = IPAddress.Parse("127.0.0.1");
            string    host = "localhost";

            var context = StartWebServer();

            Assert.Equal(context.Request.Headers["host"], host);
            context.Response.OutputStream.Close();
            StopWebServer();

            var uri    = new Uri("http://" + host);
            var client = new VcapClient(uri, ip, 12345);

            client.GetInfo();
        }
コード例 #38
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();
        }
コード例 #39
0
        public ProviderResponse <bool> ValidateAccount(string serverUrl, string email, string password)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client       = new VcapClient(serverUrl);
                var         vcapResponse = client.Login(email, password);
                response.Message  = vcapResponse.Message;
                response.Response = vcapResponse.Success;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #40
0
        public ProviderResponse <bool> RegisterAccount(string serverUrl, string email, string password)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(serverUrl);
                client.AddUser(email, password);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Response = false;
                response.Message  = ex.Message;
            }
            return(response);
        }
コード例 #41
0
        static bool UnbindService(IList <string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Usage: vmc unbind-service <servicename> <appname>"); // TODO usage statement standardization
                return(false);
            }

            string svcname = unparsed[0];
            string appname = unparsed[1];

            IVcapClient      vc   = new VcapClient();
            VcapClientResult rslt = vc.UnbindService(svcname, appname);

            return(rslt.Success);
        }
コード例 #42
0
        public ProviderResponse <bool> Push(Cloud cloud, string name, string url, ushort instances, string directoryToPushFrom, uint memory, string[] services)
        {
            var response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client = new VcapClient(cloud);
                client.Push(name, url, instances, new System.IO.DirectoryInfo(directoryToPushFrom), memory, services);
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Response = false;
                response.Message  = ex.Message;
            }
            return(response);
        }
コード例 #43
0
ファイル: UserTests.cs プロジェクト: kirannadell/ironfoundry
 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);
         }
     }
 }
コード例 #44
0
        public ProviderResponse <IEnumerable <Instance> > GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse <IEnumerable <Instance> >();

            try
            {
                IVcapClient client    = new VcapClient(cloud);
                var         stats     = client.GetStats(app);
                var         instances = new SafeObservableCollection <Instance>();
                if (stats != null)
                {
                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                        {
                            ID    = stat.ID,
                            State = stat.State
                        };
                        if (stat.Stats != null)
                        {
                            instance.Cores       = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota / 1048576;
                            instance.DiskQuota   = stat.Stats.DiskQuota / 1048576;
                            instance.Host        = stat.Stats.Host;
                            instance.Parent      = app;
                            instance.Uptime      = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu    = stat.Stats.Usage.CpuTime / 100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage) / 1024;
                                instance.Disk   = Convert.ToInt32(stat.Stats.Usage.DiskUsage) / 1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
コード例 #45
0
ファイル: Delete.cs プロジェクト: ademar/ironfoundry
        static bool Delete(IList<string> unparsed)
        {
            // TODO match ruby argument parsing
            if (unparsed.Count != 1)
            {
                Console.Error.WriteLine("Not enough arguments for [delete]");
                Console.Error.WriteLine("Usage: vmc delete <appname>"); // TODO usage statement standardization
                return false;
            }

            string appname = unparsed[0];

            Console.Write(deleteFmt, appname);

            IVcapClient vc = new VcapClient();
            vc.Delete(appname);
            return true;
        }
コード例 #46
0
ファイル: Apps.cs プロジェクト: ademar/ironfoundry
 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;
 }
コード例 #47
0
ファイル: Target.cs プロジェクト: ademar/ironfoundry
        static bool Target(IList<string> unparsed)
        {
            string url = command_url;
            if (false == unparsed.IsNullOrEmpty())
            {
                url = unparsed[0];
            }

            IVcapClient vc = new VcapClient();
            VcapClientResult rslt = vc.Target(url);
            if (rslt.Success)
            {
                Console.WriteLine(String.Format(Resources.Vmc_TargetDisplay_Fmt, rslt.Message));
            }
            else
            {
                Console.WriteLine(String.Format(Resources.Vmc_TargetNoSuccessDisplay_Fmt, rslt.Message));
            }

            return rslt.Success;
        }
コード例 #48
0
ファイル: DeleteUser.cs プロジェクト: ademar/ironfoundry
        static bool DeleteUser(IList<string> unparsed)
        {
            if (unparsed.Count != 1)
            {
                Console.Error.WriteLine("Too many arguments for [delete_user]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc delete-user <user>"); // TODO usage statement standardization
                return false;
            }

            string email = unparsed[0];
            Console.WriteLine("Deleting user '{0}' will also delete all applications and services for this user.", email);
            Console.Write("Do you want to do this? [yN] ");
            string input = Console.ReadLine();
            if (input == "y")
            {
                Console.Write("Deleting User '{0}' ... ", email);
                IVcapClient vc = new VcapClient();
                VcapClientResult result = vc.DeleteUser(email);
                Console.WriteLine("OK");
            }
            return true;
        }
コード例 #49
0
ファイル: Files.cs プロジェクト: ademar/ironfoundry
        static bool Files(IList<string> unparsed)
        {
            if (unparsed.Count != 2)
            {
                Console.Error.WriteLine("Too many arguments for [files]: {0}", String.Join(", ", unparsed.Select(s => String.Format("'{0}'", s))));
                Console.Error.WriteLine("Usage: vmc files <appname> <path>"); // TODO usage statement standardization
                return false;
            }

            string appname = unparsed[0];
            string path = unparsed[1];

            IVcapClient vc = new VcapClient();
            byte[] output = vc.FilesSimple(appname, path, 0);
            if (false == output.IsNullOrEmpty())
            {
                Stream stdout = Console.OpenStandardOutput();
                stdout.Write(output, 0, output.Length);
                stdout.Flush();
            }
            return true;
        }
コード例 #50
0
 public ProviderResponse<bool> ValidateAccount(string serverUrl, string email, string password)
 {
     var response = new ProviderResponse<bool>();
     try
     {
         IVcapClient client = new VcapClient(serverUrl);
         client.Login(email, password);
         response.Response = true;
     }
     catch (Exception ex)
     {
         response.Response = false;
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #51
0
 public void should_create_vcap_client_with_uri()
 {
     CloudActive = new VcapClient(FakeAccountInformation.GoodUri.ToString());
     CloudActive.Should().NotBeNull();
 }
コード例 #52
0
 public ProviderResponse<VcapFilesResult> GetFiles(Cloud cloud, Application application, string path, ushort instanceId)
 {
     var response = new ProviderResponse<VcapFilesResult>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         var result = client.Files(application.Name, path, instanceId);
         response.Response = result;
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #53
0
        public ProviderResponse<IEnumerable<Instance>> GetInstances(Cloud cloud, Application app)
        {
            var response = new ProviderResponse<IEnumerable<Instance>>();
            try
            {
                IVcapClient client = new VcapClient(cloud);
                var stats = client.GetStats(app);
                var instances = new SafeObservableCollection<Instance>();
                if (stats != null)
                {

                    foreach (var stat in stats)
                    {
                        var instance = new Instance()
                                       {
                                           Id = stat.ID,
                                           State = stat.State
                                       };
                        if (stat.Stats != null)
                        {
                            instance.Cores = stat.Stats.Cores;
                            instance.MemoryQuota = stat.Stats.MemQuota/1048576;
                            instance.DiskQuota = stat.Stats.DiskQuota/1048576;
                            instance.Host = stat.Stats.Host;
                            instance.Parent = app;
                            instance.Uptime = TimeSpan.FromSeconds(Convert.ToInt32(stat.Stats.Uptime));

                            if (stat.Stats.Usage != null)
                            {
                                instance.Cpu = stat.Stats.Usage.CpuTime/100;
                                instance.Memory = Convert.ToInt32(stat.Stats.Usage.MemoryUsage)/1024;
                                instance.Disk = Convert.ToInt32(stat.Stats.Usage.DiskUsage)/1048576;
                            }
                        }
                        instances.Add(instance);
                    }
                }
                response.Response = instances;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return response;
        }
コード例 #54
0
 public ProviderResponse<SafeObservableCollection<ProvisionedService>> GetProvisionedServices(Cloud cloud)
 {
     var response = new ProviderResponse<SafeObservableCollection<ProvisionedService>>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         response.Response = new SafeObservableCollection<ProvisionedService>(client.GetProvisionedServices());
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #55
0
 public ProviderResponse<IEnumerable<StatInfo>> GetStats(Application app, Cloud cloud)
 {
     var response = new ProviderResponse<IEnumerable<StatInfo>>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         response.Response = client.GetStats(app);
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #56
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
                {
                    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;
        }
コード例 #57
0
 public ProviderResponse<SafeObservableCollection<StatInfo>> GetStats(Cloud cloud, Application application)
 {
     var response = new ProviderResponse<SafeObservableCollection<StatInfo>>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         response.Response = new SafeObservableCollection<StatInfo>(client.GetStats(application));
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #58
0
 public ProviderResponse<bool> Push(Cloud cloud, string name, string url, ushort instances, string directoryToPushFrom, uint memory, string[] services)
 {
     var response = new ProviderResponse<bool>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         client.Push(name, url, instances, new System.IO.DirectoryInfo(directoryToPushFrom), memory, services);
         response.Response = true;
     }
     catch (Exception ex)
     {
         response.Response = false;
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #59
0
 public ProviderResponse<bool> UpdateApplication(Application app, Cloud cloud)
 {
     var response = new ProviderResponse<bool>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         client.UpdateApplication(app);
         response.Response = true;
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }
コード例 #60
0
 public ProviderResponse<bool> Update(Cloud cloud, Application app, string directoryToPushFrom)
 {
     var response = new ProviderResponse<bool>();
     try
     {
         IVcapClient client = new VcapClient(cloud);
         client.Update(app.Name, new System.IO.DirectoryInfo(directoryToPushFrom));
         response.Response = true;
     }
     catch (Exception ex)
     {
         response.Message = ex.Message;
     }
     return response;
 }