Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/public_ip.rb
# this fuction checks whether the public ip belongs to the given
# resource group
this fuction checks whether the public ip belongs to the given
resource group
this fuction checks whether the public ip belongs to the given resource group
def check_existence_publicip(resource_group_name, public_ip_name)
      begin
        OOLog.info("Checking existance of public IP '#{public_ip_name}' in '#{resource_group_name}' ")
        start_time = Time.now.to_i
        promise =
          @client.public_ip_addresses.get(resource_group_name, public_ip_name)
        response = promise.value!
        result = response.body
        end_time = Time.now.to_i
        duration = end_time - start_time
        OOLog.info("operation took #{duration} seconds")
        return true
      rescue MsRestAzure::AzureOperationError => e
        OOLog.info("Azure::PublicIp - Exception is: #{e.body}")
        if(e.body.values[0]['code'] == 'ResourceNotFound')
          return false
        else
          return true
        end
      rescue => e
        OOLog.fatal("Exception trying to get public ip #{public_ip_name} from resource group: #{resource_group_name}. Exception: #{e.message}")
      end
    end
def check_existence_publicip ( resource_group_name , public_ip_name ) begin OOLog . info ( "Checking existance of public IP '#{public_ip_name}' in '#{resource_group_name}' " ) start_time = Time . now . to_i promise = @client . public_ip_addresses . get ( resource_group_name , public_ip_name ) response = promise . value! result = response . body end_time = Time . now . to_i duration = end_time - start_time OOLog . info ( "operation took #{duration} seconds" ) return true rescue MsRestAzure :: AzureOperationError => e OOLog . info ( "Azure::PublicIp - Exception is: #{e.body}" ) if ( e . body . values [ 0 ] [ 'code' ] == 'ResourceNotFound' ) return false else return true end rescue => e OOLog . fatal ( "Exception trying to get public ip #{public_ip_name} from resource group: #{resource_group_name}. Exception: #{e.message}" ) end end
this fuction checks whether the public ip belongs to the given
resource group
this fuction checks whether the public ip belongs to the given resource group
resource_group_name
<not_specific>
public_ip_name
<not_specific>