Add CaptureRole operation to virtualmachine

This commit is contained in:
Paul Meyer 2015-03-17 11:28:49 -07:00
Родитель 294ca5b033
Коммит 494d44c084
2 изменённых файлов: 58 добавлений и 0 удалений

Просмотреть файл

@ -218,3 +218,43 @@ func (self VirtualMachineClient) GetRoleSizeList() (RoleSizeList, error) {
return roleSizeList, err
}
// Captures a VM. If reprovisioningConfigurationSet is non-nil, the VM role is
// redeployed after capturing the image, otherwise, the original VM role is deleted.
// NOTE: an image resulting from this operation shows up in osimage.GetImageList()
// as images with Category "User".
func (self VirtualMachineClient) CaptureRole(cloudserviceName, deploymentName, roleName, imageName, imageLabel string, reprovisioningConfigurationSet *ConfigurationSet) (requestId string, err error) {
if cloudserviceName == "" {
return "", fmt.Errorf(errParamNotSpecified, "cloudserviceName")
}
if deploymentName == "" {
return "", fmt.Errorf(errParamNotSpecified, "deploymentName")
}
if roleName == "" {
return "", fmt.Errorf(errParamNotSpecified, "roleName")
}
if reprovisioningConfigurationSet != nil &&
!(reprovisioningConfigurationSet.ConfigurationSetType == ConfigurationSetTypeLinuxProvisioning ||
reprovisioningConfigurationSet.ConfigurationSetType == ConfigurationSetTypeWindowsProvisioning) {
return "", fmt.Errorf("ConfigurationSet type can only be WindowsProvisioningConfiguration or LinuxProvisioningConfiguration")
}
operation := CaptureRoleOperation{
OperationType: "CaptureRoleOperation",
PostCaptureAction: PostCaptureActionReprovision,
ProvisioningConfiguration: reprovisioningConfigurationSet,
TargetImageLabel: imageLabel,
TargetImageName: imageName,
}
if reprovisioningConfigurationSet == nil {
operation.PostCaptureAction = PostCaptureActionDelete
}
data, err := xml.Marshal(operation)
if err != nil {
return "", err
}
return self.client.SendAzurePostRequest(fmt.Sprintf(azureOperationsURL, cloudserviceName, deploymentName, roleName), data)
}

Просмотреть файл

@ -409,6 +409,24 @@ type RestartRoleOperation struct {
OperationType string
}
// Contains the information for capturing a Role
type CaptureRoleOperation struct {
XMLName xml.Name `xml:"http://schemas.microsoft.com/windowsazure CaptureRoleOperation"`
OperationType string
PostCaptureAction PostCaptureAction
ProvisioningConfiguration *ConfigurationSet `xml:",omitempty"`
TargetImageLabel string
TargetImageName string
}
type PostCaptureAction string
const (
// Enum values for PostCaptureAction
PostCaptureActionDelete PostCaptureAction = "Delete"
PostCaptureActionReprovision PostCaptureAction = "Reprovision"
)
// Contains a list of the available role sizes
type RoleSizeList struct {
XMLName xml.Name `xml:"RoleSizes"`