Search in sources :

Example 6 with NetworkManagementClientImpl

use of com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl in project photon-model by vmware.

the class TestAzureLongRunningEnumeration method setUp.

@Override
@Before
public void setUp() throws Exception {
    for (int i = 0; i < numOfVMsToTest; i++) {
        String azureName = generateName(azureVMNamePrefix);
        azureVMNames.add(azureName);
        nicSpecs.add(initializeNicSpecs(azureName, false, true, false));
    }
    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);
            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(this.timeoutSeconds);
            // 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.waitForServiceAvailable(PhotonModelServices.LINKS);
        this.host.waitForServiceAvailable(PhotonModelTaskServices.LINKS);
        this.nodeStatsUri = UriUtils.buildUri(this.host.getUri(), ServiceUriPaths.CORE_MANAGEMENT);
        this.maxMemoryInMb = this.host.getState().systemInfo.maxMemoryByteCount / BYTES_TO_MB;
        internalTagResourcesMap.put(NetworkState.class, NETWORK_TAG_TYPE_VALUE);
        internalTagResourcesMap.put(SubnetState.class, SUBNET_TAG_TYPE_VALUE);
        internalTagResourcesMap.put(NetworkInterfaceState.class, NETWORK_INTERFACE_TAG_TYPE_VALUE);
        if (!this.isMock) {
            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.storageManagementClient = new StorageManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
            this.networkManagementClient = new NetworkManagementClientImpl(credentials).withSubscriptionId(this.subscriptionId);
        }
    } catch (Throwable e) {
        throw new Exception(e);
    }
}
Also used : NetworkManagementClientImpl(com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl) ResourcePoolState(com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState) AuthCredentialsServiceState(com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState) StorageManagementClientImpl(com.microsoft.azure.management.storage.implementation.StorageManagementClientImpl) ComputeManagementClientImpl(com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl) ApplicationTokenCredentials(com.microsoft.azure.credentials.ApplicationTokenCredentials) AzureTestUtil.randomString(com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.randomString) ResourceManagementClientImpl(com.microsoft.azure.management.resources.implementation.ResourceManagementClientImpl) Before(org.junit.Before)

Aggregations

NetworkManagementClientImpl (com.microsoft.azure.management.network.implementation.NetworkManagementClientImpl)6 ApplicationTokenCredentials (com.microsoft.azure.credentials.ApplicationTokenCredentials)3 ResourceManagementClientImpl (com.microsoft.azure.management.resources.implementation.ResourceManagementClientImpl)3 ResourcePoolState (com.vmware.photon.controller.model.resources.ResourcePoolService.ResourcePoolState)3 AuthCredentialsServiceState (com.vmware.xenon.services.common.AuthCredentialsService.AuthCredentialsServiceState)3 Before (org.junit.Before)3 ComputeManagementClientImpl (com.microsoft.azure.management.compute.implementation.ComputeManagementClientImpl)2 PublicIPAddressInner (com.microsoft.azure.management.network.implementation.PublicIPAddressInner)2 VirtualNetworkInner (com.microsoft.azure.management.network.implementation.VirtualNetworkInner)2 AzureDeferredResultServiceCallback (com.vmware.photon.controller.model.adapters.azure.utils.AzureDeferredResultServiceCallback)2 AzureEnvironment (com.microsoft.azure.AzureEnvironment)1 AddressSpace (com.microsoft.azure.management.network.AddressSpace)1 NetworkSecurityGroupInner (com.microsoft.azure.management.network.implementation.NetworkSecurityGroupInner)1 ResourceGroupInner (com.microsoft.azure.management.resources.implementation.ResourceGroupInner)1 StorageManagementClientImpl (com.microsoft.azure.management.storage.implementation.StorageManagementClientImpl)1 AzureTestUtil.createDefaultResourceGroupState (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.createDefaultResourceGroupState)1 AzureTestUtil.randomString (com.vmware.photon.controller.model.adapters.azure.instance.AzureTestUtil.randomString)1 ComputeState (com.vmware.photon.controller.model.resources.ComputeService.ComputeState)1 NetworkInterfaceState (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceState)1 NetworkInterfaceStateWithDescription (com.vmware.photon.controller.model.resources.NetworkInterfaceService.NetworkInterfaceStateWithDescription)1