• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java VirtualMachineSizeTypes类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中com.microsoft.azure.management.compute.VirtualMachineSizeTypes的典型用法代码示例。如果您正苦于以下问题:Java VirtualMachineSizeTypes类的具体用法?Java VirtualMachineSizeTypes怎么用?Java VirtualMachineSizeTypes使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

VirtualMachineSizeTypes类属于com.microsoft.azure.management.compute包,在下文中一共展示了VirtualMachineSizeTypes类的23个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: createResource

点赞 3

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    final String vmName = "vm" + this.testId;
    final String newRgName = SdkContext.randomResourceName("rgVmInAvail", 10);
    final String newAvailSetName = SdkContext.randomResourceName("avai", 10);

    VirtualMachine vm = virtualMachines.define(vmName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(newRgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withoutPrimaryPublicIPAddress()
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("testuser")
            .withRootPassword("12NewPA$$w0rd!")
            .withComputerName("myvm123")
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .withNewAvailabilitySet(newAvailSetName)
            .create();

    Assert.assertNotNull(vm.availabilitySetId());
    Assert.assertNotNull(vm.computerName());
    Assert.assertTrue(vm.computerName().equalsIgnoreCase("myvm123"));
    return vm;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:26,
代码来源:TestVirtualMachineInAvailabilitySet.java

示例2: createResource

点赞 3

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public BatchAIFileServer createResource(BatchAIFileServers fileServers) throws Exception {
    final Region region = Region.US_EAST;
    final String groupName = SdkContext.randomResourceName("rg", 10);
    final String fsName = SdkContext.randomResourceName("fs", 15);
    final String userName = "tirekicker";

    BatchAIFileServer fileServer = fileServers.define(fsName)
            .withRegion(region)
            .withNewResourceGroup(groupName)
            .withDataDisks(10, 2, StorageAccountType.STANDARD_LRS)
            .withVMSize(VirtualMachineSizeTypes.STANDARD_D1_V2.toString())
            .withUserName(userName)
            .withPassword("MyPassword!")
            .create();
    return fileServer;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:18,
代码来源:TestBatchAIFileServers.java

示例3: virtualMachineSizeType

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachineSizeTypes virtualMachineSizeType() {
    if (this.inner.resourceType() != null
            && this.inner.resourceType().equalsIgnoreCase("virtualMachines")
            && this.inner.name() != null) {
        return VirtualMachineSizeTypes.fromString(this.inner.name());
    } else {
        return null;
    }
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:11,
代码来源:ComputeSkuImpl.java

示例4: size

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachineSizeTypes size() {
    if (this.inner().hardwareProfile() != null && this.inner().hardwareProfile().vmSize() != null) {
        return this.inner().hardwareProfile().vmSize();
    }
    if (this.sku() != null && this.sku().name() != null) {
        return VirtualMachineSizeTypes.fromString(this.sku().name());
    }
    return null;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:11,
代码来源:VirtualMachineScaleSetVMImpl.java

示例5: setHardwareProfileDefaults

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
private void setHardwareProfileDefaults() {
    if (!isInCreateMode()) {
        return;
    }
    HardwareProfile hardwareProfile = this.inner().hardwareProfile();
    if (hardwareProfile.vmSize() == null) {
        hardwareProfile.withVmSize(VirtualMachineSizeTypes.BASIC_A0);
    }
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:10,
代码来源:VirtualMachineImpl.java

示例6: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public BatchAICluster createResource(BatchAIClusters clusters) throws Exception {
    final String groupName = SdkContext.randomResourceName("rg", 10);
    final String clusterName = SdkContext.randomResourceName("cluster", 15);
    final String userName = "tirekicker";

    BatchAICluster cluster = clusters.define(clusterName)
            .withRegion(region)
            .withNewResourceGroup(groupName)
            .withVMSize(VirtualMachineSizeTypes.STANDARD_NC6.toString())
            .withUserName(userName)
            .withPassword("MyPassword")
            .withAutoScale(1, 1)
            .create();
    Assert.assertEquals("steady", cluster.allocationState().toString());
    Assert.assertEquals(userName, cluster.adminUserName());
    cluster.jobs().define("myJob")
            .withRegion(region)
            .withNodeCount(1)
            .withStdOutErrPathPrefix("$AZ_BATCHAI_MOUNT_ROOT/azurefileshare")
            .defineCognitiveToolkit()
                .withPythonScriptFile("$AZ_BATCHAI_INPUT_SAMPLE/ConvNet_MNIST.py")
                .withCommandLineArgs("$AZ_BATCHAI_INPUT_SAMPLE $AZ_BATCHAI_OUTPUT_MODEL")
                .attach()
            .withInputDirectory("SAMPLE", "$AZ_BATCHAI_MOUNT_ROOT/azurefileshare/mnistcntksample")
            .withOutputDirectory("MODEL", "$AZ_BATCHAI_MOUNT_ROOT/azurefileshare/model")
            .withContainerImage("microsoft/cntk:2.1-gpu-python3.5-cuda8.0-cudnn6.0")
            .create();
    return cluster;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java
代码行数:31,
代码来源:TestBatchAI.java

示例7: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    final String vmName = "vm" + this.testId;
    VirtualMachine virtualMachine = virtualMachines.define(vmName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup()
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withoutPrimaryPublicIPAddress()
            .withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
            .withAdminUsername("testuser")
            .withAdminPassword("12NewPA$$w0rd!")
            .withUnmanagedDisks()
            .withNewUnmanagedDataDisk(30)
            .defineUnmanagedDataDisk("disk2")
                .withNewVhd(20)
                .withCaching(CachingTypes.READ_ONLY)
                .attach()
            .withSize(VirtualMachineSizeTypes.STANDARD_A8)
            .create();

    Assert.assertTrue(virtualMachine.size().equals(VirtualMachineSizeTypes.STANDARD_A8));
    Assert.assertTrue(virtualMachine.unmanagedDataDisks().size() == 2);
    VirtualMachineUnmanagedDataDisk disk2 = null;
    for (VirtualMachineUnmanagedDataDisk dataDisk : virtualMachine.unmanagedDataDisks().values()) {
        if (dataDisk.name().equalsIgnoreCase("disk2")) {
            disk2 = dataDisk;
            break;
        }
    }
    Assert.assertNotNull(disk2);
    Assert.assertTrue(disk2.cachingType() == CachingTypes.READ_ONLY);
    Assert.assertTrue(disk2.size() == 20);
    return virtualMachine;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:36,
代码来源:TestVirtualMachineDataDisk.java

示例8: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    final String vmName = "vm" + this.testId;
    final VirtualMachine[] vms = new VirtualMachine[1];
    final SettableFuture<VirtualMachine> future = SettableFuture.create();

    Observable<Indexable> resourceStream = virtualMachines.define(vmName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup()
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withoutPrimaryPublicIPAddress()
            .withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
            .withAdminUsername("testuser")
            .withAdminPassword("12NewPA$$w0rd!")
            .withNewDataDisk(150)
            .withSize(VirtualMachineSizeTypes.STANDARD_D1_V2)
            .createAsync();

    Utils.<VirtualMachine>rootResource(resourceStream)
            .subscribe(new Action1<VirtualMachine>() {
                @Override
                public void call(VirtualMachine virtualMachine) {
                    future.set(virtualMachine);
                }
            });
    vms[0] = future.get();

    Assert.assertEquals(1, vms[0].dataDisks().size());
    VirtualMachineDataDisk dataDisk = vms[0].dataDisks().values().iterator().next();
    Assert.assertEquals(150, dataDisk.size());
    Assert.assertEquals(128, vms[0].osDiskSize());
    Disk osDisk = virtualMachines.manager().disks().getById(vms[0].osDiskId());
    Assert.assertNotNull(osDisk);
    Assert.assertEquals(128, osDisk.sizeInGB());

    return vms[0];
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:39,
代码来源:TestVirtualMachine.java

示例9: updateResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine updateResource(VirtualMachine resource) throws Exception {
    resource = resource.update()
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .withNewDataDisk(100)
            .apply();
    return resource;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:9,
代码来源:TestVirtualMachine.java

示例10: testManagedDiskVMUpdate

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Test
public void testManagedDiskVMUpdate() throws Exception {
    final String rgName = SdkContext.randomResourceName("rg", 13);
    final String linuxVM2Name = SdkContext.randomResourceName("vm" + "-", 10);
    final String linuxVM2Pip = SdkContext.randomResourceName("pip" + "-", 18);
    VirtualMachine linuxVM2 = azure.virtualMachines().define(linuxVM2Name)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(rgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(linuxVM2Pip)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername("tester")
            .withRootPassword("Abcdef.123456!")
            // Begin: Managed data disks
            .withNewDataDisk(100)
            .withNewDataDisk(100, 1, CachingTypes.READ_WRITE)
            // End: Managed data disks
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .create();

    linuxVM2.deallocate();
    linuxVM2.update()
            .withoutDataDisk(2)
            .withNewDataDisk(200)
            .apply();
    azure.resourceGroups().beginDeleteByName(rgName);
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:29,
代码来源:AzureTests.java

示例11: prepareSpecializedUnmanagedVirtualMachine

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
private static VirtualMachine prepareSpecializedUnmanagedVirtualMachine(Azure azure, Region region, String rgName) {
    final String userName = "tirekicker";
    final String password = "12NewPA$$w0rd!";
    final String linuxVMName1 = SdkContext.randomResourceName("vm" + "-", 10);
    final String publicIpDnsLabel = SdkContext.randomResourceName("pip" + "-", 20);

    VirtualMachine linuxVM = azure.virtualMachines().define(linuxVMName1)
            .withRegion(region)
            .withNewResourceGroup(rgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(publicIpDnsLabel)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername(userName)
            .withRootPassword(password)
            .withUnmanagedDisks()
            .defineUnmanagedDataDisk("disk-1")
                .withNewVhd(100)
                .withLun(1)
                .attach()
            .defineUnmanagedDataDisk("disk-2")
                .withNewVhd(50)
                .withLun(2)
                .attach()
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .create();

    // De-provision the virtual machine
    deprovisionAgentInLinuxVM(linuxVM.getPrimaryPublicIPAddress().fqdn(), 22, userName, password);
    System.out.println("Deallocate VM: " + linuxVM.id());
    linuxVM.deallocate();
    System.out.println("Deallocated VM: " + linuxVM.id() + "; state = " + linuxVM.powerState());
    System.out.println("Generalize VM: " + linuxVM.id());
    linuxVM.generalize();
    System.out.println("Generalized VM: " + linuxVM.id());
    return linuxVM;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:38,
代码来源:ManageManagedDisks.java

示例12: prepareSpecializedManagedVirtualMachine

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
private static VirtualMachine prepareSpecializedManagedVirtualMachine(Azure azure, Region region, String rgName) {
    final String userName = "tirekicker";
    final String password = "12NewPA$$w0rd!";
    final String linuxVMName1 = SdkContext.randomResourceName("vm" + "-", 10);
    final String publicIPDnsLabel = SdkContext.randomResourceName("pip" + "-", 20);

    VirtualMachine linuxVM = azure.virtualMachines().define(linuxVMName1)
            .withRegion(region)
            .withNewResourceGroup(rgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(publicIPDnsLabel)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername(userName)
            .withRootPassword(password)
            .withNewDataDisk(100)
            .withNewDataDisk(200)
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .create();

    // De-provision the virtual machine
    deprovisionAgentInLinuxVM(linuxVM.getPrimaryPublicIPAddress().fqdn(), 22, userName, password);
    System.out.println("Deallocate VM: " + linuxVM.id());
    linuxVM.deallocate();
    System.out.println("Deallocated VM: " + linuxVM.id() + "; state = " + linuxVM.powerState());
    System.out.println("Generalize VM: " + linuxVM.id());
    linuxVM.generalize();
    System.out.println("Generalized VM: " + linuxVM.id());
    return linuxVM;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:31,
代码来源:ManageManagedDisks.java

示例13: fromNewDockerVM

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
/**
 * It creates a new Azure virtual machine and it instantiate a Java Docker client.
 * @param azure - instance of Azure
 * @param rgName - name of the Azure resource group to be used when creating a virtual machine
 * @param region - region to be used when creating a virtual machine
 * @param registryServerUrl - address of the private container registry
 * @param username - user name to connect with to the private container registry
 * @param password - password to connect with to the private container registry
 * @return an instance of DockerClient
 * @throws Exception exception thrown
 */
public static DockerClient fromNewDockerVM(Azure azure, String rgName, Region region,
                                           String registryServerUrl, String username, String password) throws Exception {
    final String dockerVMName = SdkContext.randomResourceName("dockervm", 15);
    final String publicIPDnsLabel = SdkContext.randomResourceName("pip", 10);
    final String vmUserName = "dockerUser";
    final String vmPassword = "12NewPA$$w0rd!";

    // Could not find a Docker environment; presume that there is no local Docker engine running and
    //    attempt to configure a Docker engine running inside a new    Azure virtual machine
    System.out.println("Creating an Azure virtual machine running Docker");

    Date t1 = new Date();

    VirtualMachine dockerVM = azure.virtualMachines().define(dockerVMName)
            .withRegion(region)
            .withExistingResourceGroup(rgName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(publicIPDnsLabel)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
            .withRootUsername(vmUserName)
            .withRootPassword(vmPassword)
            .withSize(VirtualMachineSizeTypes.STANDARD_D2_V2)
            .create();

    Date t2 = new Date();
    System.out.println("Created Azure Virtual Machine: (took " + ((t2.getTime() - t1.getTime()) / 1000) + " seconds) " + dockerVM.id());

    // Get the IP of the Docker host
    NicIPConfiguration nicIPConfiguration = dockerVM.getPrimaryNetworkInterface().primaryIPConfiguration();
    PublicIPAddress publicIp = nicIPConfiguration.getPublicIPAddress();
    String dockerHostIP = publicIp.ipAddress();

    DockerClient dockerClient = installDocker(dockerHostIP, vmUserName, vmPassword, registryServerUrl, username, password);
    System.out.println("List Docker host info");
    System.out.println("\tFound Docker version: " + dockerClient.versionCmd().exec().toString());
    System.out.println("\tFound Docker info: " + dockerClient.infoCmd().exec().toString());

    return dockerClient;
}
 

开发者ID:Azure-Samples,
项目名称:acr-java-manage-azure-container-registry,
代码行数:52,
代码来源:DockerUtils.java

示例14: withSize

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachineImpl withSize(String sizeName) {
    this.inner().hardwareProfile().withVmSize(VirtualMachineSizeTypes.fromString(sizeName));
    return this;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:6,
代码来源:VirtualMachineImpl.java

示例15: size

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachineSizeTypes size() {
    return inner().hardwareProfile().vmSize();
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:5,
代码来源:VirtualMachineImpl.java

示例16: ensureVMs

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
private static VirtualMachine[] ensureVMs(Networks networks, ComputeManager computeManager, int count) throws Exception {
    // Create a network for the VMs
    Network network = networks.define("net" + TEST_ID)
            .withRegion(REGION)
            .withNewResourceGroup(GROUP_NAME)
            .withAddressSpace("10.0.0.0/28")
            .withSubnet("subnet1", "10.0.0.0/29")
            .withSubnet("subnet2", "10.0.0.8/29")
            .create();

    Creatable<AvailabilitySet> availabilitySetDefinition = computeManager.availabilitySets().define("as" + TEST_ID)
            .withRegion(REGION)
            .withExistingResourceGroup(GROUP_NAME)
            .withSku(AvailabilitySetSkuTypes.MANAGED);

    // Create the requested number of VM definitions
    String userName = "testuser" + TEST_ID;
    List<Creatable<VirtualMachine>> vmDefinitions = new ArrayList<>();
    for (int i = 0; i < count; i++) {
        String vmName = SdkContext.randomResourceName("vm", 15);

        Creatable<VirtualMachine> vm = computeManager.virtualMachines().define(vmName)
                .withRegion(REGION)
                .withExistingResourceGroup(GROUP_NAME)
                .withExistingPrimaryNetwork(network)
                .withSubnet(network.subnets().values().iterator().next().name())
                .withPrimaryPrivateIPAddressDynamic()
                .withoutPrimaryPublicIPAddress()
                .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
                .withRootUsername(userName)
                .withRootPassword("Abcdef.123456")
                .withNewAvailabilitySet(availabilitySetDefinition)
                .withSize(VirtualMachineSizeTypes.STANDARD_A1);

        vmDefinitions.add(vm);
    }

    CreatedResources<VirtualMachine> createdVMs2 = computeManager.virtualMachines().create(vmDefinitions);
    VirtualMachine[] array = new VirtualMachine[createdVMs2.size()];
    for (int index = 0; index < createdVMs2.size(); index++) {
        array[index] = createdVMs2.get(vmDefinitions.get(index).key());
    }
    return array;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:45,
代码来源:TestLoadBalancer.java

示例17: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    final String vmName = "vm" + this.testId;

    System.out.println("In createResource \n\n\n");

    Creatable<ResourceGroup> rgCreatable = virtualMachines.manager().resourceManager().resourceGroups().define(SdkContext.randomResourceName("rg" + vmName, 20))
            .withRegion(Region.US_EAST);

    Creatable<StorageAccount> storageCreatable = this.storageAccounts.define(SdkContext.randomResourceName("stg", 20))
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(rgCreatable);

    final AtomicInteger resourceCount = new AtomicInteger(0);

    VirtualMachine virtualMachine = (VirtualMachine) virtualMachines.define(vmName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(rgCreatable)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress(SdkContext.randomResourceName("pip", 20))
            .withPopularWindowsImage(KnownWindowsVirtualMachineImage.WINDOWS_SERVER_2012_R2_DATACENTER)
            .withAdminUsername("testuser")
            .withAdminPassword("12NewPA$$w0rd!")
            .withSize(VirtualMachineSizeTypes.STANDARD_D1_V2)
            .withNewStorageAccount(storageCreatable)
            .withNewAvailabilitySet(SdkContext.randomResourceName("avset", 10))
            .createAsync()
            .map(new Func1<Indexable, Resource>() {
                @Override
                public Resource call(Indexable resource) {
                    resourceCount.incrementAndGet();
                    Resource createdResource = (Resource) resource;
                    System.out.println("Created :" + createdResource.id());
                    return createdResource;
                }
            }).toBlocking().last();

    Assert.assertTrue(resourceCount.get() == 7);
    return virtualMachine;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:42,
代码来源:TestResourceStreaming.java

示例18: ensureNetwork

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
VirtualMachine[] ensureNetwork(Networks networks, VirtualMachines vms, NetworkInterfaces networkInterfaces) throws Exception {
    // Create an NSG
    NetworkSecurityGroup nsg = networks.manager().networkSecurityGroups().define("nsg" + TEST_ID)
            .withRegion(REGION)
            .withNewResourceGroup(groupName)
            .create();

    // Create a network for the VMs
    Network network = networks.define("net" + TEST_ID)
            .withRegion(REGION)
            .withExistingResourceGroup(groupName)
            .withAddressSpace("10.0.0.0/28")
            .defineSubnet("subnet1")
                .withAddressPrefix("10.0.0.0/29")
                .withExistingNetworkSecurityGroup(nsg)
                .attach()
            .withSubnet("subnet2", "10.0.0.8/29")
            .create();

    NetworkInterface nic = networkInterfaces.define("ni" + TEST_ID)
            .withRegion(REGION)
            .withExistingResourceGroup(groupName)
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withNewPrimaryPublicIPAddress("pipdns" + TEST_ID)
            .withIPForwarding()
            .withExistingNetworkSecurityGroup(nsg)
            .create();

    // Create the requested number of VM definitions
    String userName = "testuser" + TEST_ID;
    List<Creatable<VirtualMachine>> vmDefinitions = new ArrayList<>();

    Creatable<VirtualMachine> vm1 = vms.define(SdkContext.randomResourceName("vm", 15))
            .withRegion(REGION)
            .withExistingResourceGroup(groupName)
            .withExistingPrimaryNetworkInterface(nic)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
            .withRootUsername(userName)
            .withRootPassword("Abcdef.123456")
            .withSize(VirtualMachineSizeTypes.STANDARD_A1)
            .defineNewExtension("packetCapture")
                .withPublisher("Microsoft.Azure.NetworkWatcher")
                .withType("NetworkWatcherAgentLinux")
                .withVersion("1.4")
                .withMinorVersionAutoUpgrade()
                .attach();

    String vmName = SdkContext.randomResourceName("vm", 15);

    Creatable<VirtualMachine> vm2 = vms.define(vmName)
            .withRegion(REGION)
            .withExistingResourceGroup(groupName)
            .withExistingPrimaryNetwork(network)
            .withSubnet(network.subnets().values().iterator().next().name())
            .withPrimaryPrivateIPAddressDynamic()
            .withoutPrimaryPublicIPAddress()
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
            .withRootUsername(userName)
            .withRootPassword("Abcdef.123456")
            .withSize(VirtualMachineSizeTypes.STANDARD_A1);

    vmDefinitions.add(vm1);
    vmDefinitions.add(vm2);
    vms.create(vmDefinitions);
    CreatedResources<VirtualMachine> createdVMs2 = vms.create(vmDefinitions);
    VirtualMachine[] array = new VirtualMachine[createdVMs2.size()];
    for (int index = 0; index < createdVMs2.size(); index++) {
        array[index] = createdVMs2.get(vmDefinitions.get(index).key());
    }
    return array;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:73,
代码来源:TestNetworkWatcher.java

示例19: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    // Prepare the resource group definition
    final String rgName = "rg" + this.testId;
    Creatable<ResourceGroup> resourceGroupCreatable = virtualMachines.manager().resourceManager().resourceGroups()
            .define(rgName)
            .withRegion(Region.US_EAST);

    // Prepare the virtual network definition [shared by primary and secondary network interfaces]
    final String vnetName = "vnet" + this.testId;
    Creatable<Network> networkCreatable = this.networkManager.networks()
            .define(vnetName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(resourceGroupCreatable)
            .withAddressSpace("10.0.0.0/28");

    // Prepare the secondary network interface definition
    final String secondaryNicName = "nic" + this.testId;
    Creatable<NetworkInterface> secondaryNetworkInterfaceCreatable = this.networkManager.networkInterfaces()
            .define(secondaryNicName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(resourceGroupCreatable)
            .withNewPrimaryNetwork(networkCreatable)
            .withPrimaryPrivateIPAddressStatic("10.0.0.5");
            // .withNewPrimaryPublicIPAddress();
            // [Secondary NIC cannot have PublicIP - Only primary network interface can reference a public IP address]

    // Prepare the secondary network interface definition
    final String secondaryNicName2 = "nic2" + this.testId;
    Creatable<NetworkInterface> secondaryNetworkInterfaceCreatable2 = this.networkManager.networkInterfaces()
            .define(secondaryNicName2)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(resourceGroupCreatable)
            .withNewPrimaryNetwork(networkCreatable)
            .withPrimaryPrivateIPAddressStatic("10.0.0.6");

    // Create Virtual Machine
    final String vmName = "vm" + this.testId;
    final String primaryPipName = "pip" + vmName;
    VirtualMachine virtualMachine = virtualMachines.define(vmName)
            .withRegion(Region.US_EAST)
            .withNewResourceGroup(resourceGroupCreatable)
            .withNewPrimaryNetwork(networkCreatable)
            .withPrimaryPrivateIPAddressStatic("10.0.0.4")
            .withNewPrimaryPublicIPAddress(primaryPipName)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
            .withRootUsername("testuser")
            .withRootPassword("12NewPA$$w0rd!")
            .withSize(VirtualMachineSizeTypes.STANDARD_A9)
            .withNewSecondaryNetworkInterface(secondaryNetworkInterfaceCreatable)
            .withNewSecondaryNetworkInterface(secondaryNetworkInterfaceCreatable2)
            .create();

    Assert.assertTrue(virtualMachine.networkInterfaceIds().size() == 3);
    NetworkInterface primaryNetworkInterface = virtualMachine.getPrimaryNetworkInterface();
    Assert.assertEquals(primaryNetworkInterface.primaryPrivateIP(), "10.0.0.4");

    PublicIPAddress primaryPublicIPAddress = primaryNetworkInterface.primaryIPConfiguration().getPublicIPAddress();
    Assert.assertTrue(primaryPublicIPAddress.fqdn().startsWith(primaryPipName));
    return virtualMachine;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:62,
代码来源:TestVirtualMachineNics.java

示例20: createResource

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
@Override
public VirtualMachine createResource(VirtualMachines virtualMachines) throws Exception {
    final String vmName = "vm" + this.testId;
    final String sshKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCfSPC2K7LZcFKEO+/t3dzmQYtrJFZNxOsbVgOVKietqHyvmYGHEC0J2wPdAqQ/63g/hhAEFRoyehM+rbeDri4txB3YFfnOK58jqdkyXzupWqXzOrlKY4Wz9SKjjN765+dqUITjKRIaAip1Ri137szRg71WnrmdP3SphTRlCx1Bk2nXqWPsclbRDCiZeF8QOTi4JqbmJyK5+0UqhqYRduun8ylAwKKQJ1NJt85sYIHn9f1Rfr6Tq2zS0wZ7DHbZL+zB5rSlAr8QyUdg/GQD+cmSs6LvPJKL78d6hMGk84ARtFo4A79ovwX/Fj01znDQkU6nJildfkaolH2rWFG/qttD [email protected]";        
    final String publicIpDnsLabel = vmName;
    PublicIPAddress pip = pips.define(publicIpDnsLabel)
        .withRegion(Region.US_EAST)
        .withNewResourceGroup()
        .withLeafDomainLabel(publicIpDnsLabel)
        .create();

    VirtualMachine vm = virtualMachines.define(vmName)
            .withRegion(pip.regionName())
            .withExistingResourceGroup(pip.resourceGroupName())
            .withNewPrimaryNetwork("10.0.0.0/28")
            .withPrimaryPrivateIPAddressDynamic()
            .withExistingPrimaryPublicIPAddress(pip)
            .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_14_04_LTS)
            .withRootUsername("testuser")
            .withRootPassword("12NewPA$$w0rd!")
            .withSsh(sshKey)
            .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
            .create();

    pip.refresh();
    Assert.assertTrue(pip.hasAssignedNetworkInterface());

    JSch jsch= new JSch();
    Session session = null;
    if (TestBase.isRecordMode()) {
        try {
            java.util.Properties config = new java.util.Properties();
            config.put("StrictHostKeyChecking", "no");
            // jsch.addIdentity(sshFile, filePassword);
            session = jsch.getSession("testuser", publicIpDnsLabel + "." + "eastus.cloudapp.azure.com", 22);
            session.setPassword("12NewPA$$w0rd!");
            session.setConfig(config);
            session.connect();
        } catch (Exception e) {
            Assert.fail("SSH connection failed" + e.getMessage());
        } finally {
            if (session != null) {
                session.disconnect();
            }
        }

        Assert.assertNotNull(vm.inner().osProfile().linuxConfiguration().ssh());
        Assert.assertTrue(vm.inner().osProfile().linuxConfiguration().ssh().publicKeys().size() > 0);
    }
    return vm;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:52,
代码来源:TestVirtualMachineSsh.java

示例21: runSample

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
/**
 * Main function which runs the actual sample.
 *
 * @param azure instance of the azure client
 * @return true if sample runs successfully
 */
public static boolean runSample(Azure azure) {
    final String linuxVMName = Utils.createRandomName("VM1");
    final String rgName = Utils.createRandomName("rgCOMV");
    final String userName = "tirekicker";
    final String password = "12NewPA$$w0rd!";
    final Region region = Region.US_WEST_CENTRAL;

    try {
        //=============================================================
        // Create a Linux VM using a PIR image with un-managed OS and data disks

        System.out.println("Creating an un-managed Linux VM");

        VirtualMachine linuxVM = azure.virtualMachines().define(linuxVMName)
                .withRegion(region)
                .withNewResourceGroup(rgName)
                .withNewPrimaryNetwork("10.0.0.0/28")
                .withPrimaryPrivateIPAddressDynamic()
                .withoutPrimaryPublicIPAddress()
                .withPopularLinuxImage(KnownLinuxVirtualMachineImage.UBUNTU_SERVER_16_04_LTS)
                .withRootUsername(userName)
                .withRootPassword(password)
                .withUnmanagedDisks()
                .defineUnmanagedDataDisk("disk-1")
                    .withNewVhd(100)
                    .withLun(1)
                    .attach()
                .defineUnmanagedDataDisk("disk-2")
                    .withNewVhd(50)
                    .withLun(2)
                    .attach()
                .withSize(VirtualMachineSizeTypes.STANDARD_D3_V2)
                .create();

        System.out.println("Created a Linux VM with un-managed OS and data disks: " + linuxVM.id());
        Utils.print(linuxVM);

        //=============================================================
        // Deallocate the virtual machine
        System.out.println("Deallocate VM: " + linuxVM.id());

        linuxVM.deallocate();

        System.out.println("De-allocated VM: " + linuxVM.id() + "; state = " + linuxVM.powerState());

        //=============================================================
        // Migrate the virtual machine
        System.out.println("Migrate VM: " + linuxVM.id());

        linuxVM.convertToManaged();

        System.out.println("Migrated VM: " + linuxVM.id());

        Utils.print(linuxVM);

        return true;
    } catch (Exception f) {
        System.out.println(f.getMessage());
        f.printStackTrace();
    } finally {
        try {
            System.out.println("Deleting Resource Group: " + rgName);
            azure.resourceGroups().deleteByName(rgName);
            System.out.println("Deleted Resource Group: " + rgName);
        } catch (NullPointerException npe) {
            System.out.println("Did not create any resources in Azure. No clean up is necessary");
        } catch (Exception g) {
            g.printStackTrace();
        }
    }

    return false;
}
 

开发者ID:Azure,
项目名称:azure-libraries-for-java,
代码行数:80,
代码来源:ConvertVirtualMachineToManagedDisks.java

示例22: builder

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
public static Builder builder(VirtualMachineSizeTypes vmSize, String vmImage, NetworkSettings network) {
    return new Builder(vmSize, vmImage, network);
}
 

开发者ID:elastisys,
项目名称:scale.cloudpool,
代码行数:4,
代码来源:ProvisioningTemplate.java

示例23: Builder

点赞 2

import com.microsoft.azure.management.compute.VirtualMachineSizeTypes; //导入依赖的package包/类
public Builder(VirtualMachineSizeTypes vmSize, String vmImage, NetworkSettings network) {
    this.vmSize = vmSize;
    this.vmImage = vmImage;
    this.network = network;
}
 

开发者ID:elastisys,
项目名称:scale.cloudpool,
代码行数:6,
代码来源:ProvisioningTemplate.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)