...

Source file src/github.com/Azure/azure-sdk-for-go/services/classic/management/vmutils/deployment.go

Documentation: github.com/Azure/azure-sdk-for-go/services/classic/management/vmutils

     1  // +build go1.7
     2  
     3  package vmutils
     4  
     5  // Copyright (c) Microsoft Corporation. All rights reserved.
     6  // Licensed under the MIT License. See License.txt in the project root for license information.
     7  
     8  import (
     9  	"fmt"
    10  
    11  	vm "github.com/Azure/azure-sdk-for-go/services/classic/management/virtualmachine"
    12  )
    13  
    14  // ConfigureDeploymentFromRemoteImage configures VM Role to deploy from a remote
    15  // image source. "remoteImageSourceURL" can be any publically accessible URL to
    16  // a VHD file, including but not limited to a SAS Azure Storage blob url. "os"
    17  // needs to be either "Linux" or "Windows". "label" is optional.
    18  func ConfigureDeploymentFromRemoteImage(
    19  	role *vm.Role,
    20  	remoteImageSourceURL string,
    21  	os string,
    22  	newDiskName string,
    23  	destinationVhdStorageURL string,
    24  	label string) error {
    25  	if role == nil {
    26  		return fmt.Errorf(errParamNotSpecified, "role")
    27  	}
    28  
    29  	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
    30  		RemoteSourceImageLink: remoteImageSourceURL,
    31  		MediaLink:             destinationVhdStorageURL,
    32  		DiskName:              newDiskName,
    33  		OS:                    os,
    34  		DiskLabel:             label,
    35  	}
    36  	return nil
    37  }
    38  
    39  // ConfigureDeploymentFromPlatformImage configures VM Role to deploy from a
    40  // platform image. See osimage package for methods to retrieve a list of the
    41  // available platform images. "label" is optional.
    42  func ConfigureDeploymentFromPlatformImage(
    43  	role *vm.Role,
    44  	imageName string,
    45  	mediaLink string,
    46  	label string) error {
    47  	if role == nil {
    48  		return fmt.Errorf(errParamNotSpecified, "role")
    49  	}
    50  
    51  	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
    52  		SourceImageName: imageName,
    53  		MediaLink:       mediaLink,
    54  	}
    55  	return nil
    56  }
    57  
    58  // ConfigureDeploymentFromPublishedVMImage configures VM Role to deploy from
    59  // a published (public) VM image.
    60  func ConfigureDeploymentFromPublishedVMImage(
    61  	role *vm.Role,
    62  	vmImageName string,
    63  	mediaLocation string,
    64  	provisionGuestAgent bool) error {
    65  	if role == nil {
    66  		return fmt.Errorf(errParamNotSpecified, "role")
    67  	}
    68  
    69  	role.VMImageName = vmImageName
    70  	role.MediaLocation = mediaLocation
    71  	role.ProvisionGuestAgent = provisionGuestAgent
    72  	return nil
    73  }
    74  
    75  // ConfigureDeploymentFromUserVMImage configures VM Role to deploy from a previously
    76  // captured (user generated) VM image.
    77  func ConfigureDeploymentFromUserVMImage(
    78  	role *vm.Role,
    79  	vmImageName string) error {
    80  	if role == nil {
    81  		return fmt.Errorf(errParamNotSpecified, "role")
    82  	}
    83  
    84  	role.VMImageName = vmImageName
    85  	return nil
    86  }
    87  
    88  // ConfigureDeploymentFromExistingOSDisk configures VM Role to deploy from an
    89  // existing disk. 'label' is optional.
    90  func ConfigureDeploymentFromExistingOSDisk(role *vm.Role, osDiskName, label string) error {
    91  	role.OSVirtualHardDisk = &vm.OSVirtualHardDisk{
    92  		DiskName:  osDiskName,
    93  		DiskLabel: label,
    94  	}
    95  	return nil
    96  }
    97  

View as plain text