Search in sources :

Example 1 with VirtualMachinePublisher

use of com.microsoft.azure.management.compute.VirtualMachinePublisher in project azure-tools-for-java by Microsoft.

the class SelectImageStep method fillPublishers.

private void fillPublishers() {
    setPageComplete(false);
    String region = ((Location) regionComboBox.getData(regionComboBox.getText())).name();
    publisherComboBox.removeAll();
    offerComboBox.removeAll();
    imageLabelList.removeAll();
    offerComboBox.setEnabled(false);
    skuComboBox.setEnabled(false);
    imageLabelList.setEnabled(false);
    DefaultLoader.getIdeHelper().runInBackground(null, "Loading image publishers...", false, true, "", new Runnable() {

        @Override
        public void run() {
            final java.util.List<VirtualMachinePublisher> publishers = wizard.getAzure().virtualMachineImages().publishers().listByRegion(region);
            DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                @Override
                public void run() {
                    for (VirtualMachinePublisher publisher : publishers) {
                        publisherComboBox.add(publisher.name());
                        publisherComboBox.setData(publisher.name(), publisher);
                    }
                    if (publishers.size() > 0) {
                        publisherComboBox.select(0);
                    }
                    fillOffers();
                }
            });
        }
    });
}
Also used : ArrayList(java.util.ArrayList) List(java.util.List) VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) Location(com.microsoft.azure.management.resources.Location)

Example 2 with VirtualMachinePublisher

use of com.microsoft.azure.management.compute.VirtualMachinePublisher in project azure-sdk-for-java by Azure.

the class ListVirtualMachineImages method runSample.

/**
     * 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 Region region = Region.US_WEST_CENTRAL;
    //=================================================================
    // List all virtual machine image publishers and
    // list all virtual machine images
    // published by Canonical, Red Hat and SUSE
    // by browsing through locations, publishers, offers, SKUs and images
    List<VirtualMachinePublisher> publishers = azure.virtualMachineImages().publishers().listByRegion(region);
    VirtualMachinePublisher chosenPublisher;
    System.out.println("US East data center: printing list of \n" + "a) Publishers and\n" + "b) Images published by Canonical, Red Hat and Suse");
    System.out.println("=======================================================");
    System.out.println("\n");
    for (VirtualMachinePublisher publisher : publishers) {
        System.out.println("Publisher - " + publisher.name());
        if (publisher.name().equalsIgnoreCase("Canonical") | publisher.name().equalsIgnoreCase("Suse") | publisher.name().equalsIgnoreCase("RedHat")) {
            chosenPublisher = publisher;
            System.out.print("\n\n");
            System.out.println("=======================================================");
            System.out.println("Located " + chosenPublisher.name());
            System.out.println("=======================================================");
            System.out.println("Printing entries as publisher/offer/sku/image.version()");
            for (VirtualMachineOffer offer : chosenPublisher.offers().list()) {
                for (VirtualMachineSku sku : offer.skus().list()) {
                    for (VirtualMachineImage image : sku.images().list()) {
                        System.out.println("Image - " + chosenPublisher.name() + "/" + offer.name() + "/" + sku.name() + "/" + image.version());
                    }
                }
            }
            System.out.print("\n\n");
        }
    }
    return true;
}
Also used : VirtualMachineSku(com.microsoft.azure.management.compute.VirtualMachineSku) VirtualMachineImage(com.microsoft.azure.management.compute.VirtualMachineImage) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) VirtualMachineOffer(com.microsoft.azure.management.compute.VirtualMachineOffer)

Example 3 with VirtualMachinePublisher

use of com.microsoft.azure.management.compute.VirtualMachinePublisher in project azure-sdk-for-java by Azure.

the class AzureTests method testVMImages.

/**
     * Tests VM images.
     * @throws IOException
     * @throws CloudException
     */
@Test
public void testVMImages() throws CloudException, IOException {
    List<VirtualMachinePublisher> publishers = azure.virtualMachineImages().publishers().listByRegion(Region.US_WEST);
    Assert.assertTrue(publishers.size() > 0);
    for (VirtualMachinePublisher p : publishers) {
        System.out.println(String.format("Publisher name: %s, region: %s", p.name(), p.region()));
        try {
            for (VirtualMachineOffer o : p.offers().list()) {
                System.out.println(String.format("\tOffer name: %s", o.name()));
                try {
                    for (VirtualMachineSku s : o.skus().list()) {
                        System.out.println(String.format("\t\tSku name: %s", s.name()));
                    }
                } catch (com.microsoft.rest.RestException e) {
                    e.printStackTrace();
                }
            }
        } catch (com.microsoft.rest.RestException e) {
            e.printStackTrace();
        }
    }
    List<VirtualMachineImage> images = azure.virtualMachineImages().listByRegion(Region.US_WEST);
    Assert.assertTrue(images.size() > 0);
    try {
        // Seems to help avoid connection refused error on subsequent mock test
        Thread.sleep(2000);
    } catch (InterruptedException e) {
        e.printStackTrace();
    }
}
Also used : VirtualMachineSku(com.microsoft.azure.management.compute.VirtualMachineSku) VirtualMachineImage(com.microsoft.azure.management.compute.VirtualMachineImage) KnownLinuxVirtualMachineImage(com.microsoft.azure.management.compute.KnownLinuxVirtualMachineImage) VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) VirtualMachineOffer(com.microsoft.azure.management.compute.VirtualMachineOffer) Test(org.junit.Test)

Example 4 with VirtualMachinePublisher

use of com.microsoft.azure.management.compute.VirtualMachinePublisher in project azure-sdk-for-java by Azure.

the class ListVirtualMachineExtensionImages method runSample.

/**
     * 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 Region region = Region.US_WEST_CENTRAL;
    //=================================================================
    // List all virtual machine extension image publishers and
    // list all virtual machine extension images
    // published by Microsoft.OSTCExtensions and Microsoft.Azure.Extensions
    // by browsing through extension image publishers, types, and versions
    List<VirtualMachinePublisher> publishers = azure.virtualMachineImages().publishers().listByRegion(region);
    VirtualMachinePublisher chosenPublisher;
    System.out.println("US East data center: printing list of \n" + "a) Publishers and\n" + "b) virtual machine extension images published by Microsoft.OSTCExtensions and Microsoft.Azure.Extensions");
    System.out.println("=======================================================");
    System.out.println("\n");
    for (VirtualMachinePublisher publisher : publishers) {
        System.out.println("Publisher - " + publisher.name());
        if (publisher.name().equalsIgnoreCase("Microsoft.OSTCExtensions") | publisher.name().equalsIgnoreCase("Microsoft.Azure.Extensions")) {
            chosenPublisher = publisher;
            System.out.print("\n\n");
            System.out.println("=======================================================");
            System.out.println("Located " + chosenPublisher.name());
            System.out.println("=======================================================");
            System.out.println("Printing entries as publisher/type/version");
            for (VirtualMachineExtensionImageType imageType : chosenPublisher.extensionTypes().list()) {
                for (VirtualMachineExtensionImageVersion version : imageType.versions().list()) {
                    VirtualMachineExtensionImage image = version.getImage();
                    System.out.println("Image - " + chosenPublisher.name() + "/" + image.typeName() + "/" + image.versionName());
                }
            }
            System.out.print("\n\n");
        }
    }
    return true;
}
Also used : VirtualMachineExtensionImage(com.microsoft.azure.management.compute.VirtualMachineExtensionImage) Region(com.microsoft.azure.management.resources.fluentcore.arm.Region) VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) VirtualMachineExtensionImageType(com.microsoft.azure.management.compute.VirtualMachineExtensionImageType) VirtualMachineExtensionImageVersion(com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersion)

Example 5 with VirtualMachinePublisher

use of com.microsoft.azure.management.compute.VirtualMachinePublisher in project azure-tools-for-java by Microsoft.

the class SelectImageStep method fillOffers.

private void fillOffers() {
    setPageComplete(false);
    offerComboBox.removeAll();
    skuComboBox.removeAll();
    imageLabelList.removeAll();
    skuComboBox.setEnabled(false);
    imageLabelList.setEnabled(false);
    VirtualMachinePublisher publisher = (VirtualMachinePublisher) publisherComboBox.getData(publisherComboBox.getText());
    DefaultLoader.getIdeHelper().runInBackground(null, "Loading image offers...", false, true, "", new Runnable() {

        @Override
        public void run() {
            try {
                final java.util.List<VirtualMachineOffer> offers = publisher.offers().list();
                DefaultLoader.getIdeHelper().invokeLater(new Runnable() {

                    @Override
                    public void run() {
                        for (VirtualMachineOffer offer : offers) {
                            offerComboBox.add(offer.name());
                            offerComboBox.setData(offer.name(), offer);
                        }
                        offerComboBox.setEnabled(true);
                        if (offers.size() > 0) {
                            offerComboBox.select(0);
                        }
                        fillSkus();
                    }
                });
            } catch (Exception e) {
                String msg = "An error occurred while attempting to retrieve offers list." + "\n" + e.getMessage();
                PluginUtil.displayErrorDialogWithAzureMsg(PluginUtil.getParentShell(), Messages.err, msg, e);
            }
        }
    });
}
Also used : VirtualMachinePublisher(com.microsoft.azure.management.compute.VirtualMachinePublisher) ArrayList(java.util.ArrayList) List(java.util.List) VirtualMachineOffer(com.microsoft.azure.management.compute.VirtualMachineOffer)

Aggregations

VirtualMachinePublisher (com.microsoft.azure.management.compute.VirtualMachinePublisher)5 VirtualMachineOffer (com.microsoft.azure.management.compute.VirtualMachineOffer)3 VirtualMachineImage (com.microsoft.azure.management.compute.VirtualMachineImage)2 VirtualMachineSku (com.microsoft.azure.management.compute.VirtualMachineSku)2 Region (com.microsoft.azure.management.resources.fluentcore.arm.Region)2 ArrayList (java.util.ArrayList)2 List (java.util.List)2 KnownLinuxVirtualMachineImage (com.microsoft.azure.management.compute.KnownLinuxVirtualMachineImage)1 VirtualMachineExtensionImage (com.microsoft.azure.management.compute.VirtualMachineExtensionImage)1 VirtualMachineExtensionImageType (com.microsoft.azure.management.compute.VirtualMachineExtensionImageType)1 VirtualMachineExtensionImageVersion (com.microsoft.azure.management.compute.VirtualMachineExtensionImageVersion)1 Location (com.microsoft.azure.management.resources.Location)1 Test (org.junit.Test)1