use of com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl 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.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl 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);
}
}
use of com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl in project photon-model by vmware.
the class AzureLifecycleOperationServiceTest 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);
PhotonModelAdaptersRegistryAdapters.startServices(this.host);
PhotonModelMetricServices.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.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl in project photon-model by vmware.
the class AzureInstanceService method deleteVirtualMachine.
private DeferredResult<AzureInstanceContext> deleteVirtualMachine(AzureInstanceContext ctx) {
String msg = "Deleting virtual machine [" + ctx.vmName + "]";
ComputeManagementClientImpl computeManager = getComputeManagementClientImpl(ctx);
AzureDeferredResultServiceCallback<OperationStatusResponseInner> deleteVirtualMachineCallback = new AzureDeferredResultServiceCallback<OperationStatusResponseInner>(this, msg) {
@Override
protected DeferredResult<OperationStatusResponseInner> consumeSuccess(OperationStatusResponseInner result) {
logInfo("Successfully deleted VM: " + ctx.vmName);
return DeferredResult.completed(result);
}
};
computeManager.virtualMachines().deleteAsync(ctx.resourceGroupName, ctx.vmName, deleteVirtualMachineCallback);
return deleteVirtualMachineCallback.toDeferredResult().thenApply(result -> ctx);
}
use of com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl in project photon-model by vmware.
the class AzureInstanceService method getAvailabilitySets.
private DeferredResult<AzureInstanceContext> getAvailabilitySets(AzureInstanceContext ctx) {
String msg = "Getting availability sets. ResourceGroup [" + ctx.resourceGroupName + "]";
ComputeManagementClientImpl computeManager = getComputeManagementClientImpl(ctx);
AzureDeferredResultServiceCallbackWithRetry<List<AvailabilitySetInner>> getAvailabilitySetsCallback = new AzureDeferredResultServiceCallbackWithRetry<List<AvailabilitySetInner>>(this, msg) {
@Override
protected DeferredResult<List<AvailabilitySetInner>> consumeSuccess(List<AvailabilitySetInner> result) {
ctx.availabilitySetInners = result;
return DeferredResult.completed(result);
}
@Override
protected Runnable retryServiceCall(ServiceCallback<List<AvailabilitySetInner>> retryCallback) {
return () -> computeManager.availabilitySets().listByResourceGroupAsync(ctx.resourceGroupName, retryCallback);
}
};
computeManager.availabilitySets().listByResourceGroupAsync(ctx.resourceGroupName, getAvailabilitySetsCallback);
return getAvailabilitySetsCallback.toDeferredResult().thenApply(result -> ctx);
}
Aggregations