Merge pull request #3269 from ahmetalpbalkan/azure_msg

azure: more accurate messages for resources created
This commit is contained in:
Nathan LeClaire 2016-04-04 17:30:17 -07:00
commit bc54d366d5
1 changed files with 14 additions and 19 deletions

View File

@ -98,7 +98,7 @@ func (a AzureClient) CreateResourceGroup(name, location string) error {
return nil return nil
} }
log.Info("Creating resource group...", logutil.Fields{ log.Info("Creating resource group.", logutil.Fields{
"name": name, "name": name,
"location": location}) "location": location})
_, err := a.resourceGroupsClient().CreateOrUpdate(name, _, err := a.resourceGroupsClient().CreateOrUpdate(name,
@ -109,13 +109,13 @@ func (a AzureClient) CreateResourceGroup(name, location string) error {
} }
func (a AzureClient) resourceGroupExists(name string) (bool, error) { func (a AzureClient) resourceGroupExists(name string) (bool, error) {
log.Info("Querying existing resource group...", logutil.Fields{"name": name}) log.Info("Querying existing resource group.", logutil.Fields{"name": name})
_, err := a.resourceGroupsClient().Get(name) _, err := a.resourceGroupsClient().Get(name)
return checkResourceExistsFromError(err) return checkResourceExistsFromError(err)
} }
func (a AzureClient) CreateNetworkSecurityGroup(ctx *DeploymentContext, resourceGroup, name, location string, rules *[]network.SecurityRule) error { func (a AzureClient) CreateNetworkSecurityGroup(ctx *DeploymentContext, resourceGroup, name, location string, rules *[]network.SecurityRule) error {
log.Info("Creating network security group...", logutil.Fields{ log.Info("Configuring network security group.", logutil.Fields{
"name": name, "name": name,
"location": location}) "location": location})
_, err := a.securityGroupsClient().CreateOrUpdate(resourceGroup, name, _, err := a.securityGroupsClient().CreateOrUpdate(resourceGroup, name,
@ -143,7 +143,7 @@ func (a AzureClient) DeleteNetworkSecurityGroupIfExists(resourceGroup, name stri
} }
func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool) error { func (a AzureClient) CreatePublicIPAddress(ctx *DeploymentContext, resourceGroup, name, location string, isStatic bool) error {
log.Info("Creating public IP address...", logutil.Fields{ log.Info("Creating public IP address.", logutil.Fields{
"name": name, "name": name,
"static": isStatic}) "static": isStatic})
@ -183,7 +183,7 @@ func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, locati
"name": name, "name": name,
"location": location} "location": location}
log.Info("Querying if virtual network already exists...", f) log.Info("Querying if virtual network already exists.", f)
if exists, err := a.virtualNetworkExists(resourceGroup, name); err != nil { if exists, err := a.virtualNetworkExists(resourceGroup, name); err != nil {
return err return err
@ -192,7 +192,7 @@ func (a AzureClient) CreateVirtualNetworkIfNotExists(resourceGroup, name, locati
return nil return nil
} }
log.Debug("Virtual network does not exist, creating...", f) log.Debug("Creating virtual network.", f)
_, err := a.virtualNetworksClient().CreateOrUpdate(resourceGroup, name, _, err := a.virtualNetworksClient().CreateOrUpdate(resourceGroup, name,
network.VirtualNetwork{ network.VirtualNetwork{
Location: to.StringPtr(location), Location: to.StringPtr(location),
@ -223,7 +223,7 @@ func (a AzureClient) GetSubnet(resourceGroup, virtualNetwork, name string) (netw
} }
func (a AzureClient) CreateSubnet(ctx *DeploymentContext, resourceGroup, virtualNetwork, name, subnetPrefix string) error { func (a AzureClient) CreateSubnet(ctx *DeploymentContext, resourceGroup, virtualNetwork, name, subnetPrefix string) error {
log.Info("Creating subnet...", logutil.Fields{ log.Info("Configuring subnet.", logutil.Fields{
"name": name, "name": name,
"vnet": virtualNetwork, "vnet": virtualNetwork,
"cidr": subnetPrefix}) "cidr": subnetPrefix})
@ -256,7 +256,7 @@ func (a AzureClient) CreateNetworkInterface(ctx *DeploymentContext, resourceGrou
// specified Azure location is different than location of the virtual // specified Azure location is different than location of the virtual
// network as Azure does not support cross-region virtual networks. In this // network as Azure does not support cross-region virtual networks. In this
// situation, user will get an explanatory API error from Azure. // situation, user will get an explanatory API error from Azure.
log.Info("Creating network interface...", logutil.Fields{"name": name}) log.Info("Creating network interface.", logutil.Fields{"name": name})
var publicIP *network.PublicIPAddress var publicIP *network.PublicIPAddress
if publicIPAddressID != "" { if publicIPAddressID != "" {
@ -330,7 +330,7 @@ func (a AzureClient) findStorageAccount(resourceGroup, location, prefix string,
"type": storageType, "type": storageType,
"prefix": prefix, "prefix": prefix,
"location": location} "location": location}
log.Debug("Querying existing storage accounts...", f) log.Debug("Querying existing storage accounts.", f)
l, err := a.storageAccountsClient().ListByResourceGroup(resourceGroup) l, err := a.storageAccountsClient().ListByResourceGroup(resourceGroup)
if err != nil { if err != nil {
return nil, err return nil, err
@ -359,7 +359,7 @@ func (a AzureClient) createStorageAccount(resourceGroup, location string, storag
"name": name, "name": name,
"location": location} "location": location}
log.Info("Creating storage account...", f) log.Info("Creating storage account.", f)
_, err := a.storageAccountsClient().Create(resourceGroup, name, _, err := a.storageAccountsClient().Create(resourceGroup, name,
storage.AccountCreateParameters{ storage.AccountCreateParameters{
Location: to.StringPtr(location), Location: to.StringPtr(location),
@ -409,7 +409,7 @@ func (a AzureClient) removeOSDiskBlob(resourceGroup, vmName, vhdURL string) erro
// Machine functionality which deletes the attached disks along with the VM // Machine functionality which deletes the attached disks along with the VM
// as well. Therefore we find out the storage account from OS disk URL and // as well. Therefore we find out the storage account from OS disk URL and
// fetch storage account keys to delete the container containing the disk. // fetch storage account keys to delete the container containing the disk.
log.Debug("Attempting to remove OS disk...", logutil.Fields{"vm": vmName}) log.Debug("Attempting to remove OS disk.", logutil.Fields{"vm": vmName})
log.Debugf("OS Disk vhd URL: %q", vhdURL) log.Debugf("OS Disk vhd URL: %q", vhdURL)
vhdContainer := osDiskStorageContainerName(vmName) vhdContainer := osDiskStorageContainerName(vmName)
@ -447,7 +447,7 @@ func (a AzureClient) removeOSDiskBlob(resourceGroup, vmName, vhdURL string) erro
func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, availabilitySetID, networkInterfaceID, func (a AzureClient) CreateVirtualMachine(resourceGroup, name, location, size, availabilitySetID, networkInterfaceID,
username, sshPublicKey, imageName string, storageAccount *storage.AccountProperties) error { username, sshPublicKey, imageName string, storageAccount *storage.AccountProperties) error {
log.Info("Creating Virtual Machine...", logutil.Fields{ log.Info("Creating virtual machine.", logutil.Fields{
"name": name, "name": name,
"location": location, "location": location,
"size": size, "size": size,
@ -536,12 +536,7 @@ func (a AzureClient) GetAvailabilitySet(resourceGroup, name string) (compute.Ava
func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error { func (a AzureClient) CreateAvailabilitySetIfNotExists(ctx *DeploymentContext, resourceGroup, name, location string) error {
f := logutil.Fields{"name": name} f := logutil.Fields{"name": name}
if ctx.AvailabilitySetID != "" { log.Info("Configuring availability set.", f)
log.Info("Availability Set already exists.", f)
return nil
}
log.Debug("Could not find existing availability set.", f)
log.Info("Creating availability set...", f)
as, err := a.availabilitySetsClient().CreateOrUpdate(resourceGroup, name, as, err := a.availabilitySetsClient().CreateOrUpdate(resourceGroup, name,
compute.AvailabilitySet{ compute.AvailabilitySet{
Location: to.StringPtr(location), Location: to.StringPtr(location),
@ -634,7 +629,7 @@ func deleteResourceIfExists(resourceType, name string, getFunc func() error, del
log.Info(fmt.Sprintf("%s does not exist. Skipping.", resourceType), f) log.Info(fmt.Sprintf("%s does not exist. Skipping.", resourceType), f)
return nil return nil
} }
log.Info(fmt.Sprintf("Removing %s resource...", resourceType), f) log.Info(fmt.Sprintf("Removing %s resource.", resourceType), f)
_, err := deleteFunc() _, err := deleteFunc()
return err return err
} }