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();
}
});
}
});
}
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;
}
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();
}
}
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;
}
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);
}
}
});
}
Aggregations