public void with_known_good_cloud_target()
 {
     CloudActive = new VcapClient(TestAccountInformation.GoodUri.ToString());
     CloudActive.Login(
         TestAccountInformation.Username,
         TestAccountInformation.Password);
 }
Beispiel #2
0
 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");
 }
Beispiel #3
0
        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");
        }
Beispiel #4
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");
        }
        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);
        }
Beispiel #6
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);
        }
Beispiel #7
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);
         }
     }
 }
Beispiel #8
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);
        }
Beispiel #9
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();
        }
Beispiel #10
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);
                }
            }
        }
        public ProviderResponse <bool> ValidateAccount(Cloud cloud)
        {
            ProviderResponse <bool> response = new ProviderResponse <bool>();

            try
            {
                IVcapClient client       = new VcapClient(cloud);
                var         vcapResponse = client.Login();
                if (vcapResponse != null &&
                    !vcapResponse.Success &&
                    !String.IsNullOrEmpty(vcapResponse.Message))
                {
                    throw new Exception(vcapResponse.Message);
                }
                response.Response = true;
            }
            catch (Exception ex)
            {
                response.Message = ex.Message;
            }
            return(response);
        }
Beispiel #12
0
        static bool Login(IList <string> unparsed)
        {
            bool   failed = true;
            ushort tries  = 0;

            while (failed && tries < 3)
            {
                string email = command_email;
                if (false == unparsed.IsNullOrEmpty())
                {
                    email = unparsed[0];
                }
                if (prompt_ok && email.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_EmailPrompt_Text);
                    email = Console.ReadLine();
                }

                string password = command_password;
                if (prompt_ok && password.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_PasswordPrompt_Text);
                    password = readPassword();
                }

                Console.WriteLine();

                if (email.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedEmailPrompt_Text);
                    return(false);
                }

                if (password.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedPasswordPrompt_Text);
                    return(false);
                }

                IVcapClient vc = new VcapClient();
                try
                {
                    VcapClientResult rslt = vc.Login(email, password);
                    if (rslt.Success)
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_LoginSuccess_Fmt, vc.CurrentUri));
                        failed = false;
                    }
                    else
                    {
                        Console.Error.WriteLine(String.Format(Resources.Vmc_LoginFail_Fmt, vc.CurrentUri));
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(String.Format(Resources.Vmc_LoginError_Fmt, vc.CurrentUri, e.Message));
                }

                ++tries;
            }

            return(false == failed);
        }
        private void PerformAction(string action, Project project, Cloud cloud, ProjectDirectories dir,
                                   Func <IVcapClient, DirectoryInfo, VcapClientResult> function)
        {
            var worker = new BackgroundWorker();

            Messenger.Default.Register <NotificationMessageAction <string> >(this,
                                                                             message =>
            {
                if (message.Notification.Equals(Messages.SetProgressData))
                {
                    message.Execute(action);
                }
            });

            var window     = new ProgressDialog();
            var dispatcher = window.Dispatcher;
            var helper     = new WindowInteropHelper(window);

            helper.Owner = (IntPtr)(dte.MainWindow.HWnd);
            worker.WorkerSupportsCancellation = true;
            worker.DoWork += (s, args) =>
            {
                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                Messenger.Default.Send(new ProgressMessage(0, "Starting " + action));

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                if (!Directory.Exists(dir.StagingPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Staging Path"))));
                    Directory.CreateDirectory(dir.StagingPath);
                }

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                if (Directory.Exists(dir.DeployFromPath))
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(10, "Creating Precompiled Site Path"))));
                    Directory.Delete(dir.DeployFromPath, true);
                }

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(30, "Preparing Compiler"))));

                VsWebSite.VSWebSite site = project.Object as VsWebSite.VSWebSite;
                if (site != null)
                {
                    site.PreCompileWeb(dir.DeployFromPath, true);
                }
                else
                {
                    string frameworkPath = (site == null) ? project.GetFrameworkPath() : String.Empty;

                    if (worker.CancellationPending)
                    {
                        args.Cancel = true; return;
                    }
                    string objDir = Path.Combine(dir.ProjectDirectory, "obj");
                    if (Directory.Exists(objDir))
                    {
                        Directory.Delete(objDir, true); // NB: this can cause precompile errors
                    }

                    var process = new System.Diagnostics.Process()
                    {
                        StartInfo = new ProcessStartInfo()
                        {
                            FileName               = Path.Combine(frameworkPath, "aspnet_compiler.exe"),
                            Arguments              = String.Format("-nologo -v / -p \"{0}\" -f -u -c \"{1}\"", dir.ProjectDirectory, dir.DeployFromPath),
                            CreateNoWindow         = true,
                            ErrorDialog            = false,
                            UseShellExecute        = false,
                            RedirectStandardOutput = true
                        }
                    };

                    if (worker.CancellationPending)
                    {
                        args.Cancel = true; return;
                    }
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(40, "Precompiling Site"))));
                    process.Start();
                    string output = process.StandardOutput.ReadToEnd();
                    process.WaitForExit();
                    if (false == String.IsNullOrEmpty(output))
                    {
                        dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Asp Compile Error: " + output))));
                        return;
                    }
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(50, "Logging in to Cloud Foundry"))));

                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                var client = new VcapClient(cloud);
                VcapClientResult result = client.Login();
                if (result.Success == false)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + result.Message))));
                    return;
                }

                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(75, "Sending to " + cloud.Url))));
                if (worker.CancellationPending)
                {
                    args.Cancel = true; return;
                }

                result = function(client, new DirectoryInfo(dir.DeployFromPath));
                if (result.Success == false)
                {
                    dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressError("Failure: " + result.Message))));
                    return;
                }
                dispatcher.BeginInvoke((Action)(() => Messenger.Default.Send(new ProgressMessage(100, action + " complete."))));
            };

            worker.RunWorkerAsync();
            if (!window.ShowDialog().GetValueOrDefault())
            {
                worker.CancelAsync();
            }
        }
        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<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;
 }
Beispiel #16
0
        static bool Login(IList<string> unparsed)
        {
            bool failed = true;
            ushort tries = 0;

            while (failed && tries < 3)
            {
                string email = command_email;
                if (false == unparsed.IsNullOrEmpty())
                {
                    email = unparsed[0];
                }
                if (prompt_ok && email.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_EmailPrompt_Text);
                    email = Console.ReadLine();
                }

                string password = command_password;
                if (prompt_ok && password.IsNullOrWhiteSpace())
                {
                    Console.Write(Resources.Vmc_PasswordPrompt_Text);
                    password = readPassword();
                }

                Console.WriteLine();

                if (email.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedEmailPrompt_Text);
                    return false;
                }

                if (password.IsNullOrWhiteSpace())
                {
                    Console.Error.WriteLine(Resources.Vmc_NeedPasswordPrompt_Text);
                    return false;
                }

                IVcapClient vc = new VcapClient();
                try
                {
                    VcapClientResult rslt = vc.Login(email, password);
                    if (rslt.Success)
                    {
                        Console.WriteLine(String.Format(Resources.Vmc_LoginSuccess_Fmt, vc.CurrentUri));
                        failed = false;
                    }
                    else
                    {
                        Console.Error.WriteLine(String.Format(Resources.Vmc_LoginFail_Fmt, vc.CurrentUri));
                    }
                }
                catch (Exception e)
                {
                    Console.Error.WriteLine(String.Format(Resources.Vmc_LoginError_Fmt, vc.CurrentUri, e.Message));
                }

                ++tries;
            }

            return false == failed;
        }