Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/virtual_network.rb
# this method will return a vnet from the name given in the resource group
this method will return a vnet from the name given in the resource group
this method will return a vnet from the name given in the resource group
def exists?(resource_group_name)
      OOLog.fatal('VNET name is nil. It is required.') if @name.nil?
      begin
        OOLog.info("Checking if Virtual Network '#{@name}' Exists! ...")
        promise = @client.virtual_networks.get(resource_group_name, @name)
        response = promise.value!
        OOLog.info('VNET EXISTS!!')
        return true
      rescue MsRestAzure::AzureOperationError => e
        OOLog.info("Exception from Azure: #{e.body}")
        OOLog.info("Error of Exception is: '#{e.body.values[0]}'")
        OOLog.info("Code of Exception is: '#{e.body.values[0]['code']}'")
        if(e.body.values[0]['code'] == 'ResourceNotFound')
          OOLog.info('VNET DOES NOT EXIST!!')
          return false
        else
          OOLog.fatal("Error getting virtual network: #{@name} from resource group #{resource_group_name}.  Exception: #{e.body}")
        end
      rescue => ex
        OOLog.fatal("Error getting virtual network: #{@name} from resource group #{resource_group_name}.  Exception: #{ex.message}")
      end
    end
def exists? ( resource_group_name ) OOLog . fatal ( 'VNET name is nil. It is required.' ) if @name . nil? begin OOLog . info ( "Checking if Virtual Network '#{@name}' Exists! ..." ) promise = @client . virtual_networks . get ( resource_group_name , @name ) response = promise . value! OOLog . info ( 'VNET EXISTS!!' ) return true rescue MsRestAzure :: AzureOperationError => e OOLog . info ( "Exception from Azure: #{e.body}" ) OOLog . info ( "Error of Exception is: '#{e.body.values[0]}'" ) OOLog . info ( "Code of Exception is: '#{e.body.values[0]['code']}'" ) if ( e . body . values [ 0 ] [ 'code' ] == 'ResourceNotFound' ) OOLog . info ( 'VNET DOES NOT EXIST!!' ) return false else OOLog . fatal ( "Error getting virtual network: #{@name} from resource group #{resource_group_name}.  Exception: #{e.body}" ) end rescue => ex OOLog . fatal ( "Error getting virtual network: #{@name} from resource group #{resource_group_name}.  Exception: #{ex.message}" ) end end
this method will return a vnet from the name given in the resource group
this method will return a vnet from the name given in the resource group
# check the error # If the error is that it doesn't exist, return true # for all other errors, throw the exception back
resource_group_name
<not_specific>