use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AzureTestUtil method buildComputeDescription.
public static ComputeDescription buildComputeDescription(VerificationHost host, ComputeState computeHost, EndpointState endpointState, AuthCredentialsServiceState azureVMAuth) throws Throwable {
if (azureVMAuth == null) {
azureVMAuth = new AuthCredentialsServiceState();
azureVMAuth.userEmail = AZURE_ADMIN_USERNAME;
azureVMAuth.privateKey = AZURE_ADMIN_PASSWORD;
azureVMAuth = TestUtils.doPost(host, azureVMAuth, AuthCredentialsServiceState.class, UriUtils.buildUri(host, AuthCredentialsService.FACTORY_LINK));
}
ComputeDescription azureVMDesc = new ComputeDescription();
azureVMDesc.id = UUID.randomUUID().toString();
azureVMDesc.documentSelfLink = azureVMDesc.id;
azureVMDesc.name = azureVMDesc.id;
azureVMDesc.regionId = AZURE_RESOURCE_GROUP_LOCATION;
azureVMDesc.authCredentialsLink = azureVMAuth.documentSelfLink;
azureVMDesc.tenantLinks = endpointState.tenantLinks;
azureVMDesc.endpointLink = endpointState.documentSelfLink;
azureVMDesc.endpointLinks = new HashSet<>();
azureVMDesc.endpointLinks.add(endpointState.documentSelfLink);
azureVMDesc.computeHostLink = computeHost.documentSelfLink;
azureVMDesc.instanceType = AZURE_VM_SIZE;
azureVMDesc.environmentName = ComputeDescription.ENVIRONMENT_NAME_AZURE;
azureVMDesc.customProperties = new HashMap<>();
// set the create service to the azure instance service
azureVMDesc.instanceAdapterReference = UriUtils.buildUri(host, AzureUriPaths.AZURE_INSTANCE_ADAPTER);
azureVMDesc.powerAdapterReference = UriUtils.buildUri(host, AzureUriPaths.AZURE_POWER_ADAPTER);
azureVMDesc = TestUtils.doPost(host, azureVMDesc, ComputeDescription.class, UriUtils.buildUri(host, ComputeDescriptionService.FACTORY_LINK));
return azureVMDesc;
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class LongRunEndToEndAzureStatsAggregation method setUp.
@Before
public void setUp() throws Exception {
try {
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelInMemoryServices.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelInMemoryServices.LINKS);
this.host.setTimeoutSeconds(600);
ResourcePoolState resourcePool = createDefaultResourcePool(this.host);
AuthCredentialsServiceState authCredentials = createDefaultAuthCredentials(this.host, this.clientID, this.clientKey, this.subscriptionId, this.tenantId);
endpointState = createDefaultEndpointState(this.host, authCredentials.documentSelfLink);
// create a compute host for the Azure
computeHost = createDefaultComputeHost(this.host, resourcePool.documentSelfLink, endpointState);
}
this.nodeStatsUri = UriUtils.buildUri(this.host.getUri(), ServiceUriPaths.CORE_MANAGEMENT);
this.maxMemoryInMb = this.host.getState().systemInfo.maxMemoryByteCount / BYTES_TO_MB;
} catch (Throwable e) {
throw new Exception(e);
}
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class AzurePowerServiceTest method setUp.
@Before
public void setUp() throws Exception {
try {
/*
* Init Class-specific (shared between test runs) vars.
*
* NOTE: Ultimately this should go to @BeforeClass, BUT BasicReusableHostTestCase.HOST
* is not accessible.
*/
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
// TODO: VSYM-992 - improve test/fix arbitrary timeout
this.host.setTimeoutSeconds(1200);
// Create a resource pool where the VM will be housed
ResourcePoolState resourcePool = createDefaultResourcePool(this.host);
AuthCredentialsServiceState authCredentials = createDefaultAuthCredentials(this.host, this.clientID, this.clientKey, this.subscriptionId, this.tenantId);
endpointState = createDefaultEndpointState(this.host, authCredentials.documentSelfLink);
// create a compute host for the Azure
computeHost = createDefaultComputeHost(this.host, resourcePool.documentSelfLink, endpointState);
}
if (!this.isMock) {
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(this.clientID, this.tenantId, this.clientKey, AzureEnvironment.AZURE);
this.computeManagementClient = new ComputeManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
}
} catch (Throwable e) {
throw new Exception(e);
}
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class TestAzureStatsCollection method setUp.
@Before
public void setUp() throws Exception {
try {
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelInMemoryServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelInMemoryServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
this.host.setTimeoutSeconds(600);
// Create a resource pool where the VMs will be housed
ResourcePoolState resourcePool = createDefaultResourcePool(this.host);
AuthCredentialsServiceState authCredentials = createDefaultAuthCredentials(this.host, this.clientID, this.clientKey, this.subscriptionId, this.tenantId);
endpointState = createDefaultEndpointState(this.host, authCredentials.documentSelfLink);
// create a compute host for the Azure
computeHost = createDefaultComputeHost(this.host, resourcePool.documentSelfLink, endpointState);
}
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelMetricServices.LINKS);
this.nodeStatsUri = UriUtils.buildUri(this.host.getUri(), ServiceUriPaths.CORE_MANAGEMENT);
this.maxMemoryInMb = this.host.getState().systemInfo.maxMemoryByteCount / BYTES_TO_MB;
} catch (Throwable e) {
throw new Exception(e);
}
}
use of com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState in project photon-model by vmware.
the class TestAzureEnumerationTask method setUp.
@Override
@Before
public void setUp() throws Exception {
try {
/*
* Init Class-specific (shared between test runs) vars.
*
* NOTE: Ultimately this should go to @BeforeClass, BUT BasicReusableHostTestCase.HOST
* is not accessible.
*/
if (computeHost == null) {
PhotonModelServices.startServices(this.host);
PhotonModelMetricServices.startServices(this.host);
PhotonModelTaskServices.startServices(this.host);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
AzureAdaptersTestUtils.startServicesSynchronouslyAzure(this.host);
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
// TODO: VSYM-992 - improve test/fix arbitrary timeout
this.host.setTimeoutSeconds(600);
// Create a resource pool where the VMs will be housed
ResourcePoolState resourcePool = createDefaultResourcePool(this.host);
AuthCredentialsServiceState authCredentials = createDefaultAuthCredentials(this.host, this.clientID, this.clientKey, this.subscriptionId, this.tenantId);
endpointState = createDefaultEndpointState(this.host, authCredentials.documentSelfLink);
// create a compute host for the Azure
computeHost = createDefaultComputeHost(this.host, resourcePool.documentSelfLink, endpointState);
endpointState.computeHostLink = computeHost.documentSelfLink;
this.host.waitForResponse(Operation.createPatch(this.host, endpointState.documentSelfLink).setBody(endpointState));
}
azureVMName = azureVMName == null ? generateName(azureVMNamePrefix) : azureVMName;
this.host.waitForServiceAvailable(PhotonModelServices.LINKS);
this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
AzureUtils.setAzureClientMock(this.isAzureClientMock);
AzureUtils.setAzureMockHost(this.azureMockEndpointReference);
if (!this.isMock) {
if (AzureUtils.isAzureClientMock()) {
AzureEnvironment azureEnv = AzureEnvironment.AZURE;
azureEnv.endpoints().put(AzureEnvironment.Endpoint.ACTIVE_DIRECTORY.toString(), AzureUtils.getAzureBaseUri());
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(this.clientID, this.tenantId, this.clientKey, azureEnv);
this.computeManagementClient = new ComputeManagementClientImpl(AzureUtils.getAzureBaseUri(), credentials).withSubscriptionId(this.subscriptionId);
this.resourceManagementClient = new ResourceManagementClientImpl(AzureUtils.getAzureBaseUri(), credentials).withSubscriptionId(this.subscriptionId);
this.networkManagementClient = new NetworkManagementClientImpl(AzureUtils.getAzureBaseUri(), credentials).withSubscriptionId(this.subscriptionId);
} else {
ApplicationTokenCredentials credentials = new ApplicationTokenCredentials(this.clientID, this.tenantId, this.clientKey, AzureEnvironment.AZURE);
this.computeManagementClient = new ComputeManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
;
this.resourceManagementClient = new ResourceManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
;
this.networkManagementClient = new NetworkManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
;
}
}
} catch (Throwable e) {
throw new Exception(e);
}
}
Aggregations