Chapter 09/circuit-oneops-1-master/components/cookbooks/azure/libraries/availability_set.rb
# this method will add the availability set if needed.
# it first checks to make sure the availability set exists,
# if not, it will create it.
this method will add the availability set if needed.
it first checks to make sure the availability set exists,
if not, it will create it.
this method will add the availability set if needed . it first checks to make sure the availability set exists if not it will create it .
def add(resource_group, availability_set, location)
      existance_promise = get(resource_group, availability_set)
      if !existance_promise.nil?
        OOLog.info("Availability Set #{existance_promise.name} exists
                        in the #{existance_promise.location} region.")
      else
        OOLog.info("Creating Availability Set
                      '#{availability_set}' in #{location} region")
        avail_set = get_avail_set_props(location)
        begin
          start_time = Time.now.to_i
          response =
            @client.availability_sets.create_or_update(resource_group,
                                                       availability_set,
                                                       avail_set).value!
          response.body
          end_time = Time.now.to_i
          duration = end_time - start_time
          OOLog.info("Availability Set created in #{duration} seconds")
        rescue MsRestAzure::AzureOperationError => e
          OOLog.fatal("Error adding an availability set: #{e.body}")
        rescue => ex
          OOLog.fatal("Error adding an availability set: #{ex.message}")
        end
      end
    end
def add ( resource_group , availability_set , location ) existance_promise = get ( resource_group , availability_set ) if ! existance_promise . nil? OOLog . info ( "Availability Set #{existance_promise.name} exists
                        in the #{existance_promise.location} region." ) else OOLog . info ( "Creating Availability Set
                      '#{availability_set}' in #{location} region" ) avail_set = get_avail_set_props ( location ) begin start_time = Time . now . to_i response = @client . availability_sets . create_or_update ( resource_group , availability_set , avail_set ) . value! response . body end_time = Time . now . to_i duration = end_time - start_time OOLog . info ( "Availability Set created in #{duration} seconds" ) rescue MsRestAzure :: AzureOperationError => e OOLog . fatal ( "Error adding an availability set: #{e.body}" ) rescue => ex OOLog . fatal ( "Error adding an availability set: #{ex.message}" ) end end end
this method will add the availability set if needed.
this method will add the availability set if needed .
# check if it exists # need to create the availability set
resource_group
<not_specific>
availability_set
<not_specific>
location
<not_specific>