lib/fog/azurerm/models/network/virtual_networks.rb in fog-azure-rm-0.1.2 vs lib/fog/azurerm/models/network/virtual_networks.rb in fog-azure-rm-0.2.0
- old
+ new
@@ -6,13 +6,18 @@
class VirtualNetworks < Fog::Collection
model Fog::Network::AzureRM::VirtualNetwork
attribute :resource_group
def all
- requires :resource_group
virtual_networks = []
- service.list_virtual_networks(resource_group).each do |vnet|
+ if !resource_group.nil?
+ requires :resource_group
+ vnets = service.list_virtual_networks(resource_group)
+ else
+ vnets = service.list_virtual_networks_in_subscription
+ end
+ vnets.each do |vnet|
virtual_networks << Fog::Network::AzureRM::VirtualNetwork.parse(vnet)
end
load(virtual_networks)
end
@@ -20,18 +25,11 @@
virtual_network = service.get_virtual_network(resource_group_name, virtual_network_name)
virtual_network_fog = Fog::Network::AzureRM::VirtualNetwork.new(service: service)
virtual_network_fog.merge_attributes(Fog::Network::AzureRM::VirtualNetwork.parse(virtual_network))
end
- def check_if_exists(resource_group, name)
- Fog::Logger.debug "Checkng if Virtual Network #{name} exists."
- if service.check_for_virtual_network(name, resource_group)
- Fog::Logger.debug "Virtual Network #{name} exists."
- true
- else
- Fog::Logger.debug "Virtual Network #{name} doesn't exists."
- false
- end
+ def check_virtual_network_exists(resource_group, name)
+ service.check_virtual_network_exists(resource_group, name)
end
end
end
end
end