Make deleting media optional for hostedservice.DeleteHostedService

And give async control to caller

Signed-off-by: Paul Meyer <paul.meyer@microsoft.com>
This commit is contained in:
Paul Meyer 2015-03-24 09:28:18 -07:00
Родитель 045492a0a6
Коммит 6086affbf5
2 изменённых файлов: 18 добавлений и 18 удалений

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

@ -16,7 +16,7 @@ const (
deleteAzureHostedServiceURL = "services/hostedservices/%s?comp=media"
azureHostedServiceAvailabilityURL = "services/hostedservices/operations/isavailable/%s"
azureDeploymentURL = "services/hostedservices/%s/deployments/%s"
deleteAzureDeploymentURL = "services/hostedservices/%s/deployments/%s?comp=media"
deleteAzureDeploymentURL = "services/hostedservices/%s/deployments/%s"
getHostedServicePropertiesURL = "services/hostedservices/%s"
errParamNotSpecified = "Parameter %s is not specified."
@ -84,18 +84,16 @@ func (self HostedServiceClient) CheckHostedServiceNameAvailability(dnsName strin
return availabilityResponse.Result, availabilityResponse.Reason, nil
}
func (self HostedServiceClient) DeleteHostedService(dnsName string) error {
func (self HostedServiceClient) DeleteHostedService(dnsName string, deleteDisksAndBlobsToo bool) (string, error) {
if dnsName == "" {
return fmt.Errorf(errParamNotSpecified, "dnsName")
return "", fmt.Errorf(errParamNotSpecified, "dnsName")
}
requestURL := fmt.Sprintf(deleteAzureHostedServiceURL, dnsName)
requestId, err := self.client.SendAzureDeleteRequest(requestURL)
if err != nil {
return err
if deleteDisksAndBlobsToo {
requestURL += "?comp=media"
}
return self.client.WaitAsyncOperation(requestId)
return self.client.SendAzureDeleteRequest(requestURL)
}
func (self HostedServiceClient) GetHostedService(name string) (HostedService, error) {

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

@ -111,10 +111,7 @@ func TestDeployPlatformCaptureRedeploy(t *testing.T) {
t.Error(err)
}
t.Logf("Deleting hosted service: %s", vmname)
if err := hostedservice.NewClient(client).DeleteHostedService(vmname); err != nil {
t.Error(err)
}
deleteHostedService(t, client, vmname)
}
func TestDeployFromVmImage(t *testing.T) {
@ -162,17 +159,13 @@ func TestRoleStateOperations(t *testing.T) {
vmc.StartRole(vmname, vmname, vmname)
vmc.RestartRole(vmname, vmname, vmname)
if err := hostedservice.NewClient(client).DeleteHostedService(role.RoleName); err != nil {
t.Error(err)
}
deleteHostedService(t, client, vmname)
}
func testRoleConfiguration(t *testing.T, client management.Client, role vm.Role, location string) {
createRoleConfiguration(t, client, role, location)
if err := hostedservice.NewClient(client).DeleteHostedService(role.RoleName); err != nil {
t.Error(err)
}
deleteHostedService(t, client, role.RoleName)
}
func createRoleConfiguration(t *testing.T, client management.Client, role vm.Role, location string) {
@ -193,6 +186,15 @@ func createRoleConfiguration(t *testing.T, client management.Client, role vm.Rol
}
}
func deleteHostedService(t *testing.T, client management.Client, vmname string) {
t.Logf("Deleting hosted service: %s", vmname)
if err := client.ExecuteAsyncOperation(func() (string, error) {
return hostedservice.NewClient(client).DeleteHostedService(vmname, true)
}); err != nil {
t.Error(err)
}
}
// === utility funcs ===
// Returns a management Client for testing. Expects AZSUBSCRIPTIONID