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); } }
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); }
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); }
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; }
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; } }
public void with_known_good_cloud_target() { CloudActive = new VcapClient(TestAccountInformation.GoodUri.ToString()); CloudActive.Login( TestAccountInformation.Username, TestAccountInformation.Password); }
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; }
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; } }
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); } }
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); }
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"); }
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); }
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; }
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; }
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; }
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); }
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); }
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"); }
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; }
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); }
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); }
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); }
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); }
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; }
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); }
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 <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); }
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); }
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); }
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; }
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); }
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); }
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); }
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); }
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); }
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(); }
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(); }
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); }
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); }
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); }
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); }
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); } } }
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); }
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; }
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; }
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; }
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; }
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; }
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; }
public void should_create_vcap_client_with_uri() { CloudActive = new VcapClient(FakeAccountInformation.GoodUri.ToString()); CloudActive.Should().NotBeNull(); }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }
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; }