Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
Copyright (C) 2013-2014 Dell, Inc ==================================================================== Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. ====================================================================
 
 
 package org.dasein.cloud.azure.compute.image;
 
 
 import  javax.annotation.Nonnull;
 import  javax.annotation.Nullable;
 import java.util.*;

Implements support for Azure OS images through the Dasein Cloud machine image API.

Author(s):
George Reese (george.reese@imaginary.com)
Version:
2012.04.1
Since:
2012.04.1
 
 public class AzureOSImage extends AbstractImageSupport<Azure> {
     static private final Logger logger = Azure.getLogger(AzureOSImage.class);
 
     static private final String IMAGES = "/services/images";
     static private final String VMIMAGES = "/services/vmimages";
     static private final String RESOURCE_VMIMAGES = "/services/vmimages?location=%s&category=%s";
     static private final String MICROSOFT = "--microsoft--";
 
     private Azure provider;
 
     public AzureOSImage(Azure provider) {
         super(provider);
         this. = provider;
     }
 
     @Override
     public void bundleVirtualMachineAsync(@Nonnull String virtualMachineId, @Nonnull MachineImageFormat format, @Nonnull String bucket, @Nonnull String name, @Nonnull AsynchronousTask<StringtrackingTaskthrows CloudExceptionInternalException {
         throw new OperationNotSupportedException("No ability to bundle vms");
     }
 
     private transient volatile OSImageCapabilities capabilities;
     @Override
         if == null ) {
             = new OSImageCapabilities();
        }
        return ;
    }
    @Override
    protected @Nonnull MachineImage capture(@Nonnull ImageCreateOptions options, @Nullable AsynchronousTask<MachineImagetaskthrows CloudExceptionInternalException {
        .debug("Capture image of "+options.getVirtualMachineId()+" with new name "+options.getName());
        try {
            iftask != null ) {
                task.setStartTime(System.currentTimeMillis());
            }
            String vmid = options.getVirtualMachineId();
            String name = options.getName();
            VirtualMachine vm;
            if (vm == null) {
                throw new CloudException("Virtual machine not found: " + options.getVirtualMachineId());
            }
            if (!vm.getCurrentState().equals(.)) {
                .debug("Stopping server");
                .getComputeServices().getVirtualMachineSupport().stop(vmidfalse);
                try {
                    long timeout = System.currentTimeMillis() + (. * 10L);
                    vm = null;
                    while (timeout > System.currentTimeMillis()) {
                        vm =  .getComputeServices().getVirtualMachineSupport().getVirtualMachine(options.getVirtualMachineId());
                        if (vm.getCurrentState().equals(.)) {
                            .debug("Server stopped");
                            break;
                        }
                        try { Thread.sleep(15000L); }
                        catchInterruptedException ignore ) { }
                    }
                }
                catch (Throwable ignore) {
                }
                if (!vm.getCurrentState().equals(.)) {
                    throw new CloudException("Server still not stopped after 10 minutes.  Please try again later");
                }
            }
            try {
                ProviderContext ctx = .getContext();
                ifctx == null ) {
                    throw new AzureConfigException("No context was set for this request");
                }
                Operation.CaptureRoleAsVMImageOperation captureVMImageOperation = new Operation.CaptureRoleAsVMImageOperation();
                captureVMImageOperation.setOsState("Generalized");
                captureVMImageOperation.setVmImageName(name);
                captureVMImageOperation.setVmImageLabel(name);
                String operationUrl = String.format(.vm.getTag("serviceName").toString(),
                        vm.getTag("deploymentName").toString(), vm.getTag("roleName").toString());
                AzureMethod method = new AzureMethod();
                try {
                    method.post(operationUrlcaptureVMImageOperation);
                }
                catch (JAXBException e)
                {
                    .error(e.getMessage());
                    throw new InternalException(e);
                }
                MachineImage img = null;
                try {
                    long timeout = System.currentTimeMillis() + (. * 10L);
                    while (timeout > System.currentTimeMillis()) {
                        img = getImage(name);
                        if (img != null) {
                            .debug("Found image "+name);
                            break;
                        }
                        try { Thread.sleep(15000L); }
                        catchInterruptedException ignore ) { }
                    }
                }
                catch (Throwable ignore) {
                }
                if (img == null) {
                    throw new CloudException("Drive cloning completed, but no ID was provided for clone");
                }iftask != null ) {
                    task.completeWithResult(img);
                }
                //VM is deleted when Azure capture image operation ends, so we need to delete the cloud service
                .getComputeServices().getVirtualMachineSupport().terminateService(vm.getTag("serviceName").toString(), "Post makeImage cleanup");
                return img;
            }
            finally {
                if.isTraceEnabled() ) {
                    .trace("EXIT: " + AzureOSImage.class.getName() + ".launch()");
                }
            }
        } finally {
            .release();
        }
    }
    @Override
    public MachineImage getImage(@Nonnull String machineImageIdthrows CloudExceptionInternalException {
        if(machineImageId == null)
            throw new InternalException("The parameter machineImageId cannot be null");
        final Iterable<MachineImageallImages = getAllImages(falsetruetrue);
        forMachineImage img : allImages ) {
            ifmachineImageId.equals(img.getProviderMachineImageId()) ) {
                .debug("Found image i'm looking for "+machineImageId);
                img.setImageClass(.);
                return img;
            }
        }
        return null;
    }
    @Override
    public @Nonnull String getProviderTermForImage(@Nonnull Locale locale) {
        return "OS image";
    }
    @Nonnull
    @Override
    public String getProviderTermForImage(@Nonnull Locale locale, @Nonnull ImageClass cls) {
        return "OS image";
    }
    @Nonnull
    @Override
    public String getProviderTermForCustomImage(@Nonnull Locale locale, @Nonnull ImageClass cls) {
        return "OS image";
    }
    @Override
    public boolean hasPublicLibrary() {
        return true;
    }
    @Nonnull
    @Override
        return .;
    }
    @Override
    public boolean isImageSharedWithPublic(@Nonnull String machineImageIdthrows CloudExceptionInternalException {
        MachineImage img = getMachineImage(machineImageId);
        return (img != null &&
                (.equals(img.getProviderOwnerId())
                        || "--public--".equals(img.getProviderOwnerId())
                        || "--Canonical--".equals(img.getProviderOwnerId())
                        || "--RightScaleLinux--".equals(img.getProviderOwnerId())
                        || "--RightScaleWindows--".equals(img.getProviderOwnerId())
                        || "--OpenLogic--".equals(img.getProviderOwnerId())
                        || "--SUSE--".equals(img.getProviderOwnerId())
                )
        );
    }
    private boolean isImageSharedWithPublic(@Nonnull MachineImage img) {
        return (img != null && !getProvider().getContext().getAccountNumber().equals(img.getProviderOwnerId()));
    }
    @Override
    public boolean isSubscribed() throws CloudExceptionInternalException {
    }
    @Nonnull
    @Override
        if (!cls.equals(.) ) {
            return Collections.emptyList();
        }
        final ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        ArrayList<ResourceStatuslist = new ArrayList<ResourceStatus>();
        final Iterable<MachineImageallImages = getAllImages(falsetruefalse);
        forMachineImage image : allImages)
        {
            if("user".equalsIgnoreCase(image.getProviderOwnerId().toLowerCase()) && ctx.getRegionId().equalsIgnoreCase(image.getProviderRegionId().toLowerCase()))
            {
                list.add(new ResourceStatus(image.getProviderMachineImageId(), .));
            }
        }
        return list;
    }
    @Nonnull
    @Override
    public Iterable<MachineImagelistImages(@Nullable ImageFilterOptions imageFilterOptionsthrows CloudExceptionInternalException {
        if (!imageFilterOptions.getImageClass().equals(.)) {
            return Collections.emptyList();
        }
        final ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        final Iterable<MachineImageallImages;
        if(imageFilterOptions.getWithAllRegions()){
            allImages = getAllImages(truetruefalse);
        }
        else{
            allImages = getAllImages(falsetruefalse);
        }
        for (MachineImage image : allImages)
        {
            if (image != null) {
                image.setImageClass(.);
                if (imageFilterOptions.matches(image)) {
                    if (imageFilterOptions.getAccountNumber() == null) {
                        if (ctx.getAccountNumber().equals(image.getProviderOwnerId())) {
                            images.add(image);
                        }
                    }
                    else if (image.getProviderOwnerId().equalsIgnoreCase(imageFilterOptions.getAccountNumber())) {
                        images.add(image);
                    }
                }
            }
        }
        return images;
    }
    @Nonnull
    @Override
    public Iterable<MachineImagelistImages(@Nonnull ImageClass clsthrows CloudExceptionInternalException {
        if (!cls.equals(.)) {
            return Collections.emptyList();
        }
        ProviderContext ctx = .getContext();
        String me = ctx.getAccountNumber();
        ArrayList<MachineImageallImages = listMachineImages();
        ArrayList<MachineImagelist = new ArrayList<MachineImage>();
        for (MachineImage img : allImages) {
            if (img.getProviderOwnerId().equalsIgnoreCase(me)) {
                img.setImageClass(.);
                list.add(img);
            }
        }
        return list;
    }
    @Nonnull
    @Override
    public Iterable<MachineImagelistImages(@Nonnull ImageClass cls, @Nonnull String ownedBythrows CloudExceptionInternalException {
        if (!cls.equals(.)) {
            return Collections.emptyList();
        }
        ProviderContext ctx = .getContext();
        ArrayList<MachineImageallImages = listMachineImages();
        ArrayList<MachineImagelist = new ArrayList<MachineImage>();
        for (MachineImage img : allImages) {
            if (img.getProviderOwnerId().equalsIgnoreCase(ownedBy)) {
                img.setImageClass(.);
                list.add(img);
            }
        }
        return list;
    }
    @Override
    public @Nonnull ArrayList<MachineImagelistMachineImages() throws CloudExceptionInternalException {
        final ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        ArrayList<MachineImagelist = new ArrayList<MachineImage>();
        final Iterable<MachineImageallImages = getAllImages(falsetruefalse);
        for (MachineImage image : allImages)
        {
            ifimage != null ) {
                ifctx.getAccountNumber().equalsIgnoreCase(image.getProviderOwnerId())) {
                    list.add(image);
                }
            }
        }
        return list;
    }
    @Override
    public @Nonnull Iterable<MachineImagelistMachineImagesOwnedBy(String accountIdthrows CloudExceptionInternalException {
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        final Iterable<MachineImageallImages = getAllImages(falsetruetrue);
        for (MachineImage image : allImages) {
            if (accountId != null && accountId.equalsIgnoreCase(image.getProviderOwnerId())) {
                images.add(image);
            }
        }
        return images;
    }
    @Override
    public @Nonnull Iterable<StringlistShares(@Nonnull String forMachineImageIdthrows CloudExceptionInternalException {
        return Collections.emptyList();
    }
    @Nonnull
    @Override
        throw new OperationNotSupportedException("No image registering is currently supported");
    }
    @Override
    public void remove(@Nonnull String machineImageIdthrows CloudExceptionInternalException {
        if.isTraceEnabled() ) {
            .trace("ENTER: " + AzureOSImage.class.getName() + ".remove(" + machineImageId + ")");
        }
        try {
            ProviderContext ctx = .getContext();
            ifctx == null ) {
                throw new AzureConfigException("No context was specified for this request");
            }
            AzureMachineImage image = (AzureMachineImage )getMachineImage(machineImageId);
            ifimage == null ) {
                throw new CloudException("No such machine image: " + machineImageId);
            }
            String url = ;
            if(image.getAzureImageType().equalsIgnoreCase("osimage")) {
                url = ;
            }
            AzureMethod method = new AzureMethod();
            method.invoke("DELETE"ctx.getAccountNumber(), url + "/" + machineImageId + "?comp=media"null);
        }
        finally {
            if.isTraceEnabled() ) {
                .trace("EXIT: " + AzureOSImage.class.getName() + ".launch()");
            }
        }
    }
    @Override
    public void remove(@Nonnull String providerImageIdboolean checkStatethrows CloudExceptionInternalException {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    @Override
    public void removeAllImageShares(@Nonnull String providerImageIdthrows CloudExceptionInternalException {
        //No-OP
    }
    @Override
    public void removeImageShare(@Nonnull String providerImageId, @Nonnull String accountNumberthrows CloudExceptionInternalException {
        throw new OperationNotSupportedException("No ability to share images");
    }
    @Override
    public void removePublicShare(@Nonnull String providerImageIdthrows CloudExceptionInternalException {
        throw new OperationNotSupportedException("No ability to share images");
    }
    private @Nonnull Iterable<MachineImagesearchPublicMachineImages(@Nullable String keyword, @Nullable Platform platform, @Nullable Architecture architecturethrows CloudExceptionInternalException {
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        final Iterable<MachineImageallImages = getAllImages(falsefalsetrue);
        forMachineImage img : allImages) {
            ifarchitecture != null ) {
                if( !architecture.equals(img.getArchitecture()) ) {
                    continue;
                }
            }
            ifplatform != null && !platform.equals(.) ) {
                Platform p = img.getPlatform();
                ifp.equals(.) ) {
                    continue;
                }
                else ifplatform.isWindows() ) {
                    if( !p.isWindows() ) {
                        continue;
                    }
                }
                else ifplatform.equals(.) ) {
                    if( !p.isUnix() ) {
                        continue;
                    }
                }
                else if( !platform.equals(p) ) {
                    continue;
                }
            }
            ifkeyword != null && !keyword.isEmpty()) {
                if( !img.getName().matches(keyword) ) {
                    if( !img.getDescription().matches(keyword) ) {
                        if( !img.getProviderMachineImageId().matches(keyword) ) {
                            continue;
                        }
                    }
                }
            }
            images.add(img);
        }
        return images;
    }
    @Nonnull
    @Override
    public Iterable<MachineImagesearchPublicImages(@Nonnull ImageFilterOptions imageFilterOptionsthrows InternalExceptionCloudException {
        Platform platform = imageFilterOptions.getPlatform();
        ImageClass cls = imageFilterOptions.getImageClass();
        return searchPublicImages(nullplatformnullcls);
    }
    @Nonnull
    @Override
    public Iterable<MachineImagesearchPublicImages(@Nullable String keyword, @Nullable Platform platform, @Nullable Architecture architecture, @Nullable ImageClass... imageClassesthrows CloudExceptionInternalException {
        ArrayList<MachineImagelist = new ArrayList<MachineImage>();
        if (imageClasses.length < 1) {
            // return all images
            Iterable<MachineImageimages = searchPublicMachineImages(keywordplatformarchitecture);
            for (MachineImage img : images) {
                if (isImageSharedWithPublic(img)) {
                    list.add(img);
                }
            }
        }
        else {
            for (ImageClass cls : imageClasses) {
                if (cls.equals(.)) {
                    Iterable<MachineImageimages = searchPublicMachineImages(keywordplatformarchitecture);
                    for (MachineImage img : images) {
                        if (isImageSharedWithPublic(img)) {
                            list.add(img);
                        }
                    }
                }
            }
        }
        return list;
    }
    @Override
    public boolean supportsCustomImages() {
        return true;
    }
    @Override
    public void updateTags(@Nonnull String imageId, @Nonnull Tag... tagsthrows CloudExceptionInternalException {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    @Override
    public void updateTags(@Nonnull String[] strings, @Nonnull Tag... tagsthrows CloudExceptionInternalException {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    @Override
    public void removeTags(@Nonnull String s, @Nonnull Tag... tagsthrows CloudExceptionInternalException {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    @Override
    public void removeTags(@Nonnull String[] strings, @Nonnull Tag... tagsthrows CloudExceptionInternalException {
        //To change body of implemented methods use File | Settings | File Templates.
    }
    @Override
    public @Nonnull String[] mapServiceAction(@Nonnull ServiceAction action) {
        return new String[0];
    }
    private Iterable<MachineImagegetAllImages(boolean isGlobalQueryboolean isPrivateboolean isPublicthrows CloudExceptionInternalException
    {
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        ArrayList<MachineImageosImages = getOSImages(isGlobalQueryisPrivateisPublic);
        images.addAll(osImages);
        ArrayList<MachineImagevmImages = getVMImages(isGlobalQueryisPrivateisPublic);
        images.addAll(vmImages);
        return images;
    }
    private String getCategory(String categorythrows CloudExceptionInternalException
    {
        if(category == null)
            return null;
        ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        if (category.equalsIgnoreCase("user")) {
            return ctx.getAccountNumber();
        } else if (category.toLowerCase().contains("microsoft")){
            return ;
        } else ifcategory.toLowerCase().contains("partner") ) {
            return "--public--";
        } else ifcategory.toLowerCase().contains("canonical") ) {
            return "--Canonical--";
        } else ifcategory.toLowerCase().contains("rightscale with linux") ) {
            return "--RightScaleLinux--";
        } else ifcategory.toLowerCase().contains("rightscale with windows") ) {
            return "--RightScaleWindows--";
        } else ifcategory.toLowerCase().contains("openlogic") ) {
            return "--OpenLogic--";
        } else ifcategory.toLowerCase().contains("suse") ) {
            return "--SUSE--";
        } else ifcategory.toLowerCase().contains("oracle") ) {
            return "--Oracle--";
        }else ifcategory.toLowerCase().contains("public") ) {
            return "--Public--";
        } else {
            return "--" + category + "--";
        }
    }
    private ArrayList<MachineImagegetOSImages(boolean isGlobalQueryboolean isPrivateboolean isPublicthrows CloudExceptionInternalException
    {
        ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        AzureMethod azureMethod = new AzureMethod();
        OSImagesModel osImagesModel = azureMethod.get(OSImagesModel.class);
        if(osImagesModel.getImages() == null){
            return images;
        }
        for(OSImageModel osImageModel : osImagesModel.getImages())
        {
            if(osImageModel.getLocation() == null) {
                continue;
            }
            List<Stringlocations = Arrays.asList(osImageModel.getLocation().trim().toLowerCase().split(";"));
            if(!isGlobalQuery){
                if(locations.contains(ctx.getRegionId().toLowerCase())) {
                    if(osImageModel.getCategory().equalsIgnoreCase("user") && isPrivate) {
                        images.add(azureImageFrom(osImageModelctx.getRegionId()));
                    }
                    else if(!osImageModel.getCategory().equalsIgnoreCase("user") && isPublic){
                        images.add(azureImageFrom(osImageModelctx.getRegionId()));
                    }
                }
            }
            else{
                if(osImageModel.getCategory().equalsIgnoreCase("user") && isPrivate){
                    for (String location : locations) {
                        images.add(azureImageFrom(osImageModellocation));
                    }
                }
                else if(!osImageModel.getCategory().equalsIgnoreCase("user") && isPublic) {
                    for (String location : locations) {
                        images.add(azureImageFrom(osImageModellocation));
                    }
                }
            }
        }
        return images;
    }
    private ArrayList<MachineImagegetVMImages(boolean isGloabalQueryboolean isPrivateboolean isPublicthrows CloudExceptionInternalException
    {
        ProviderContext ctx = .getContext();
        ifctx == null ) {
            throw new AzureConfigException("No context was specified for this request");
        }
        String region = isGloabalQuery ? "" : URLEncoder.encode(ctx.getRegionId());
        String category = "";
        if(isPrivate){
            category = "user";
        }
        else if(isPublic){
            category = "public";
        }
        ArrayList<MachineImageimages = new ArrayList<MachineImage>();
        AzureMethod azureMethod = new AzureMethod();
        VMImagesModel vmImagesModel = azureMethod.get(VMImagesModel.class, String.format(regioncategory));
        if(vmImagesModel.getVmImages() == null){
            return images;
        }
        for (VMImageModel vmImageModel : vmImagesModel.getVmImages())
        {
            if(vmImageModel.getLocation() == null){
                continue;
            }
            if(!isGloabalQuery) {
                images.add(azureImageFrom(vmImageModelctx.getRegionId()));
            }
            else {
                List<Stringlocations = Arrays.asList(vmImageModel.getLocation().trim().toLowerCase().split(";"));
                for (String location : locations) {
                    images.add(azureImageFrom(vmImageModellocation));
                }
            }
        }
        return images;
    }
    private AzureMachineImage azureImageFrom(VMImageModel vmImageModelString regionIdthrows CloudExceptionInternalException {
        AzureMachineImage azureMachineImage = new AzureMachineImage();
        azureMachineImage.setProviderOwnerId(getCategory(vmImageModel.getCategory()));
        azureMachineImage.setProviderRegionId(regionId);
        azureMachineImage.setProviderMachineImageId(vmImageModel.getName());
        azureMachineImage.setName(vmImageModel.getLabel());
        azureMachineImage.setDescription(vmImageModel.getDescription());
        azureMachineImage.setArchitecture(.);
        azureMachineImage.setPlatform(vmImageModel.getOsDiskConfiguration().getOs().equalsIgnoreCase("windows") ? . : .);
        azureMachineImage.setCurrentState(.);
        azureMachineImage.setImageClass(.);
        azureMachineImage.setType(.);
        azureMachineImage.setDescription(vmImageModel.getDescription() != null ? vmImageModel.getDescription() : vmImageModel.getName() );
        if(vmImageModel.getOsDiskConfiguration() != null && vmImageModel.getOsDiskConfiguration().getOsState() != null){
            azureMachineImage.setTag("OSState"vmImageModel.getOsDiskConfiguration().getOsState());
        }
        if(vmImageModel.getOsDiskConfiguration().getMediaLink() != null)
            azureMachineImage.setMediaLink(vmImageModel.getOsDiskConfiguration().getMediaLink());
        String descriptor = azureMachineImage.getProviderMachineImageId() + " " + azureMachineImage.getName() + " " + azureMachineImage.getDescription();
        azureMachineImage.setSoftware(descriptor.contains("SQL Server") ? "SQL Server" : "");
        azureMachineImage.setAzureImageType("VMImage");
        azureMachineImage.setMediaLink(vmImageModel.getOsDiskConfiguration().getMediaLink());
        azureMachineImage.setTag("public", Boolean.toString(isPublicImage(azureMachineImage)));
        return azureMachineImage;
    }
    private AzureMachineImage azureImageFrom(OSImageModel osImageModelString regionIdthrows CloudExceptionInternalException {
        AzureMachineImage azureMachineImage = new AzureMachineImage();
        azureMachineImage.setCurrentState(.);
        azureMachineImage.setProviderRegionId(regionId);
        azureMachineImage.setArchitecture(.);
        azureMachineImage.setProviderMachineImageId(osImageModel.getName());
        azureMachineImage.setProviderOwnerId(getCategory(osImageModel.getCategory()));
        azureMachineImage.setName(osImageModel.getLabel());
        azureMachineImage.setDescription(osImageModel.getDescription());
        azureMachineImage.setMediaLink(osImageModel.getMediaLink());
        azureMachineImage.setPlatform(osImageModel.getOs().equalsIgnoreCase("windows") ? . : .);
        azureMachineImage.setTags(new HashMap<String,String>());
        azureMachineImage.setType(.);
        azureMachineImage.setImageClass(.);
        ifazureMachineImage.getName() == null ) {
            azureMachineImage.setName(azureMachineImage.getProviderMachineImageId());
        }
        else {
            int versionIdx = azureMachineImage.getProviderMachineImageId().indexOf("__");
            if(versionIdx > 0)
            {
                String fullName = null;
                try {
                    fullName = azureMachineImage.getProviderMachineImageId().substring(versionIdx + 2);
                } catch (Throwable ignore) {
                }
                if (fullName != null) {
                    azureMachineImage.setName(fullName);
                }
            }
        }
        ifazureMachineImage.getDescription() == null ) {
            azureMachineImage.setDescription(azureMachineImage.getName());
        }
        String descriptor = azureMachineImage.getProviderMachineImageId() + " " + azureMachineImage.getName() + " " + azureMachineImage.getDescription();
        ifazureMachineImage.getPlatform() == null || azureMachineImage.getPlatform().equals(.) ) {
            Platform p = Platform.guess(descriptor);
            ifazureMachineImage.getPlatform() == null || !..equals(p) ) {
                azureMachineImage.setPlatform(p);
            }
        }
        azureMachineImage.setSoftware(descriptor.contains("SQL Server") ? "SQL Server" : "");
        azureMachineImage.setAzureImageType("OSImage");
        azureMachineImage.setTag("public", Boolean.toString(isPublicImage(azureMachineImage)));
        return azureMachineImage;
    }
    private boolean isPublicImage(AzureMachineImage image){
            return false;
        }
        return true;
    }
New to GrepCode? Check out our FAQ X