lib/fog/azurerm/requests/resources/create_resource_group.rb in fog-azure-rm-0.0.4 vs lib/fog/azurerm/requests/resources/create_resource_group.rb in fog-azure-rm-0.0.5
- old
+ new
@@ -2,36 +2,36 @@
module Resources
class AzureRM
# This class provides the actual implemention for service calls.
class Real
def create_resource_group(name, location)
+ Fog::Logger.debug "Creating Resource Group: #{name}."
+ resource_group = Azure::ARM::Resources::Models::ResourceGroup.new
+ resource_group.location = location
begin
- Fog::Logger.debug "Creating Resource Group: #{name}."
- rg_properties = ::Azure::ARM::Resources::Models::ResourceGroup.new
- rg_properties.location = location
- promise = @rmc.resource_groups.create_or_update(name, rg_properties)
- result = promise.value!
+ resource_group = @rmc.resource_groups.create_or_update(name, resource_group)
Fog::Logger.debug "Resource Group #{name} created successfully."
- Azure::ARM::Resources::Models::ResourceGroup.serialize_object(result.body)
+ resource_group
rescue MsRestAzure::AzureOperationError => e
- msg = "Exception creating Resource Group #{name}. #{e.body['error']['message']}"
- raise msg
+ raise Fog::AzureRm::OperationError.new(e)
end
end
end
# This class provides the mock implementation for unit tests.
class Mock
def create_resource_group(name, location)
- {
+ resource_group = {
'location' => location,
'id' => "/subscriptions/########-####-####-####-############/resourceGroups/#{name}",
'name' => name,
'properties' =>
{
'provisioningState' => 'Succeeded'
}
}
+ result_mapper = Azure::ARM::Resources::Models::ResourceGroup.mapper
+ @rmc.deserialize(result_mapper, resource_group, 'result.body')
end
end
end
end
end