Beispiel #1
0
        public async Task GetAllSystemImagesAU1()
        {
            IReadOnlyList <DeployedImageWithSoftwareLabelsType> images;

            using (ComputeApiClient apiClient = new ComputeApiClient("AU"))
            {
                await apiClient.LoginAsync(
                    accountCredentials : GetIntegrationTestCredentials()
                    );

                images = await apiClient.GetImagesAsync("AU1");
            }

            foreach (var image in images)
            {
                TestContext.WriteLine(
                    "Image '{0}' (Id = '{1}') - '{2}' ({3})",
                    image.name,
                    image.id,
                    image
                    .machineSpecification
                    .operatingSystem
                    .displayName,
                    image
                    .machineSpecification
                    .operatingSystem
                    .type
                    );
            }
        }
Beispiel #2
0
        public async Task GetAllSystemImagesAllLocations()
        {
            using (ComputeApiClient apiClient = new ComputeApiClient("AU"))
            {
                await apiClient.LoginAsync(
                    accountCredentials : GetIntegrationTestCredentials()
                    );

                foreach (DatacenterSummary datacenter in await apiClient.GetAvailableDataCentersAsync())
                {
                    TestContext.WriteLine("DataCenter '{0}' ({1}):", datacenter.LocationCode, datacenter.DisplayName);

                    foreach (var image in await apiClient.GetImagesAsync(datacenter.LocationCode))
                    {
                        TestContext.WriteLine(
                            "\tImage '{0}' (Id = '{1}') - '{2}' ({3})",
                            image.name,
                            image.id,
                            image
                            .machineSpecification
                            .operatingSystem
                            .displayName,
                            image
                            .machineSpecification
                            .operatingSystem
                            .type
                            );
                    }
                }
            }
        }
		public async Task GetAvailableNetworkDomains()
		{
			ICredentials credentials = GetIntegrationTestCredentials();

			using (var computeApiClient = new ComputeApiClient("apinashpcs01.opsourcecloud.net"))
			{
				IAccount account = await
					computeApiClient
						.LoginAsync(credentials);
				Assert.IsNotNull(account);

				Guid organizationId = account.OrganizationId;
				Assert.AreNotEqual(Guid.Empty, organizationId);

				var networkDomains = (await computeApiClient.GetNetworkDomains()).ToList();

				Assert.AreNotEqual(0, networkDomains.Count);

				TestContext.WriteLine("Domains List \n");

				foreach (NetworkDomain domain in networkDomains)
				{
					TestContext.WriteLine("Name & Type : {0} - {1}", domain.name, domain.type);
					TestContext.WriteLine("Description: {0}", domain.description);
				}
			}
		}
Beispiel #4
0
        public async Task GetAvailableDatacenters()
        {
            ICredentials credentials = GetIntegrationTestCredentials();

            using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
            {
                IAccount account = await
                                   computeApiClient
                                   .LoginAsync(credentials);

                Assert.IsNotNull(account);

                Guid organizationId = account.OrganizationId;
                Assert.AreNotEqual(Guid.Empty, organizationId);

                IReadOnlyList <IDatacenterDetail> dataCenters =
                    await computeApiClient
                    .GetAvailableDataCentersAsync();

                Assert.AreNotEqual(0, dataCenters.Count);
                foreach (IDatacenterDetail dataCenter in dataCenters)
                {
                    TestContext.WriteLine("{0}:{1} ({2})", dataCenter.LocationCode, dataCenter.DisplayName, dataCenter.Country);
                }
            }
        }
		public async Task GetAllSystemImagesAllLocations()
		{
			using (ComputeApiClient apiClient = new ComputeApiClient("AU"))
			{
				await apiClient.LoginAsync(
					accountCredentials: GetIntegrationTestCredentials()
				);

				foreach (DatacenterWithMaintenanceStatusType datacenter in await apiClient.GetDataCentersWithMaintenanceStatuses())
				{
					TestContext.WriteLine("DataCenter '{0}' ({1}):", datacenter.location, datacenter.displayName);

					foreach (var image in await apiClient.GetImages(null,null,datacenter.location,null,null))
					{
						TestContext.WriteLine(
							"\tImage '{0}' (Id = '{1}') - '{2}' ({3})",
							image.name,
							image.id,
							image.operatingSystem[0].type,
                            image.operatingSystem[0].displayName
                            
															
						);
					}
				}
			}
		}
		public async Task GetAllSystemImagesAU1()
		{
			IReadOnlyList<DeployedImageWithSoftwareLabelsType> images;
			using (ComputeApiClient apiClient = new ComputeApiClient("AU"))
			{
				await apiClient.LoginAsync(
					accountCredentials: GetIntegrationTestCredentials()
				);

				images = await apiClient.GetImages("AU1");
			}

			foreach (var image in images)
			{
				TestContext.WriteLine(
					"Image '{0}' (Id = '{1}') - '{2}' ({3})",
					image.name,
					image.id,
					image
						.machineSpecification
						.operatingSystem
						.displayName,
					image
						.machineSpecification
						.operatingSystem
						.type
				);
			}
		}
		public async Task LoginWithValidCredentials()
		{
			ICredentials credentials = GetIntegrationTestCredentials();
			using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
			{
				IAccount account = await
					computeApiClient
						.LoginAsync(credentials);
				Assert.IsNotNull(account);
				Assert.IsNotNull(computeApiClient.Account);

				TestContext.WriteLine("Account organisation Id: '{0}", account.OrganizationId);
				TestContext.WriteLine("Account full name: '{0}'", account.FullName);
				TestContext.WriteLine("Account email address: '{0}'", account.EmailAddress);
			}
		}
	    public async Task TestListMultiGeoDataCentersWithKey()
	    {
            ICredentials credentials = GetIntegrationTestCredentials();
            using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
            {
                IAccount account = await
                    computeApiClient
                        .LoginAsync(credentials);
                Assert.IsNotNull(account);

                Guid organizationId = account.OrganizationId;
                Assert.AreNotEqual(Guid.Empty, organizationId);

                await computeApiClient.GetListOfMultiGeographyRegions();
            }
        }
Beispiel #9
0
        public async Task LoginWithValidCredentials()
        {
            ICredentials credentials = GetIntegrationTestCredentials();

            using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
            {
                IAccount account = await
                                   computeApiClient
                                   .LoginAsync(credentials);

                Assert.IsNotNull(account);
                Assert.IsNotNull(computeApiClient.Account);

                TestContext.WriteLine("Account organisation Id: '{0}", account.OrganizationId);
                TestContext.WriteLine("Account full name: '{0}'", account.FullName);
                TestContext.WriteLine("Account email address: '{0}'", account.EmailAddress);
            }
        }
        public async Task ProvisionNetworkDomainTest()
        {
            requestsAndResponses.Add(ApiUris.MyAccount, RequestFileResponseType.AsGoodResponse("GetMyAccountDetails.xml"));
            requestsAndResponses.Add(ApiUris.CreateNetworkDomain(this.accountId), RequestFileResponseType.AsGoodResponse("CreateNetworkDomainResponse.xml"));

            ComputeApiClient client = GetApiClient();
            await client.LoginAsync(new NetworkCredential(string.Empty, string.Empty));

            ResponseType domainResponse = await client.DeployNetworkDomain(new DeployNetworkDomainType()
            {
                datacenterId = "DC1",
                description  = "my description",
                name         = "domain1",
                type         = "ESSENTIALS"
            });

            Assert.IsNotNull(domainResponse);
            Assert.AreEqual("IN_PROGRESS", domainResponse.responseCode);
        }
		public async Task LoginWithInvalidCredentials()
		{
			ICredentials credentials = new NetworkCredential(
				userName: "******",
				password: "******"
			);
			using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
			{
				try
				{
					await computeApiClient.LoginAsync(credentials);
					
					Assert.Fail("LoginAsync with invalid credentials failed to raise a ComputeApiException.");
				}
				catch (ComputeApiException eInvalidCredentials)
				{
					if (eInvalidCredentials.Error != ComputeApiError.InvalidCredentials)
						throw;
				}
			}
		}
		public async Task GetAvailableDatacenters()
		{
			ICredentials credentials = GetIntegrationTestCredentials();
			using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
			{
				IAccount account = await
					computeApiClient
						.LoginAsync(credentials);
				Assert.IsNotNull(account);

				Guid organizationId = account.OrganizationId;
				Assert.AreNotEqual(Guid.Empty, organizationId);

			    IEnumerable<DatacenterWithMaintenanceStatusType> dataCenters =
			        await computeApiClient
			            .GetDataCentersWithMaintenanceStatuses();

				Assert.AreNotEqual(0, dataCenters.Count());
                foreach (DatacenterWithMaintenanceStatusType dataCenter in dataCenters)
					TestContext.WriteLine("{0}:{1} ({2})", dataCenter.location, dataCenter.displayName, dataCenter.country);
			}
		}
Beispiel #13
0
        /// <summary>
        ///     Try to login into the account using the credentials.
        ///     If succeed, it will return the account details.
        /// </summary>
        /// <returns>
        ///     The CaaS connection
        /// </returns>
        private async Task <ComputeServiceConnection> LoginTask()
        {
            var messageHandler = GetMessageHandler(ApiCredentials.GetNetworkCredential());
            var baseUri        = KnownApiUri.Instance.GetBaseUri(Vendor, Region);
            var httpClient     = new HttpClientAdapter(
                new HttpClient(messageHandler, disposeHandler: true)
            {
                BaseAddress = baseUri,
                Timeout     = TimeSpan.FromMinutes(5),
            });


            // we will not try to login again, assuming the clientId remains the same accross the regions
            var apiClient = new ComputeApiClient(httpClient);

            var newCloudComputeConnection = new ComputeServiceConnection(apiClient, messageHandler);

            WriteDebug("Trying to login into the CaaS");

            await apiClient.LoginAsync();

            return(newCloudComputeConnection);
        }
Beispiel #14
0
        public async Task LoginWithInvalidCredentials()
        {
            ICredentials credentials = new NetworkCredential(
                userName: "******",
                password: "******"
                );

            using (ComputeApiClient computeApiClient = new ComputeApiClient("au"))
            {
                try
                {
                    await computeApiClient.LoginAsync(credentials);

                    Assert.Fail("LoginAsync with invalid credentials failed to raise a ComputeApiException.");
                }
                catch (ComputeApiException eInvalidCredentials)
                {
                    if (eInvalidCredentials.Error != ComputeApiError.InvalidCredentials)
                    {
                        throw;
                    }
                }
            }
        }
		public async Task CreateNetworkDomain()
		{
			ICredentials credentials = GetIntegrationTestCredentials();

			using (var computeApiClient = new ComputeApiClient("apinashpcs01.opsourcecloud.net"))
			{
				IAccount account = await computeApiClient.LoginAsync(credentials);
				Assert.IsNotNull(account);

				Guid organizationId = account.OrganizationId;
				Assert.AreNotEqual(Guid.Empty, organizationId);

				var newDomain = new DeployNetworkDomain { location = "NASH_PCS01_N2_VMWARE_1", name = "Test Network Domain", description = "This is test Network Domain created using Network 2.0 API", type = "ESSENTIALS" };

				var result = await computeApiClient.DeployNetworkDomain(newDomain);

				Assert.AreEqual("OK", result.responseCode);
				Assert.IsTrue(result.info.Length > 0);
				Assert.IsNotNull(result.info[0].ToString());
			}
		}