Chapter 09/circuit-oneops-1-master/components/cookbooks/panos/libraries/address_manager.rb
def create_dag_with_addresses(address_group_name, addresses, tag, device_groups)
    device_groups.each do |device_group|
      # create the tag that will be used
      tag_request = TagRequest.new(@url, @key)
      tag_request.create(tag, device_group)

      # create a DAG
      addr_group = AddressGroup.new(address_group_name, 'Dynamic', tag, device_group)
      dag_request = AddressGroupRequest.new(@url, @key)
      dag_request.create(addr_group)

      # create the address
      address_request = AddressRequest.new(@url, @key)
      addresses['entries'].each do |address|
        Chef::Log.info("Address is: #{address}")
        Chef::Log.info("NAME is: #{address['name']}")
        Chef::Log.info("IP Address is: #{address['ip_address']}")
        address_request.create(Address.new(address['name'], 'IP_NETMASK', address['ip_address'], device_group, tag))
      end
    end

    commit_and_check_status(device_groups)
  end
# this function creates the tag, addresses and dynamic address group
this function creates the tag, addresses and dynamic address group
this function creates the tag addresses and dynamic address group
def create_dag_with_addresses(address_group_name, addresses, tag, device_groups)
    device_groups.each do |device_group|
      tag_request = TagRequest.new(@url, @key)
      tag_request.create(tag, device_group)
      addr_group = AddressGroup.new(address_group_name, 'Dynamic', tag, device_group)
      dag_request = AddressGroupRequest.new(@url, @key)
      dag_request.create(addr_group)
      address_request = AddressRequest.new(@url, @key)
      addresses['entries'].each do |address|
        Chef::Log.info("Address is: #{address}")
        Chef::Log.info("NAME is: #{address['name']}")
        Chef::Log.info("IP Address is: #{address['ip_address']}")
        address_request.create(Address.new(address['name'], 'IP_NETMASK', address['ip_address'], device_group, tag))
      end
    end
    commit_and_check_status(device_groups)
  end
def create_dag_with_addresses ( address_group_name , addresses , tag , device_groups ) device_groups . each do | device_group | tag_request = TagRequest . new ( @url , @key ) tag_request . create ( tag , device_group ) addr_group = AddressGroup . new ( address_group_name , 'Dynamic' , tag , device_group ) dag_request = AddressGroupRequest . new ( @url , @key ) dag_request . create ( addr_group ) address_request = AddressRequest . new ( @url , @key ) addresses [ 'entries' ] . each do | address | Chef :: Log . info ( "Address is: #{address}" ) Chef :: Log . info ( "NAME is: #{address['name']}" ) Chef :: Log . info ( "IP Address is: #{address['ip_address']}" ) address_request . create ( Address . new ( address [ 'name' ] , 'IP_NETMASK' , address [ 'ip_address' ] , device_group , tag ) ) end end commit_and_check_status ( device_groups ) end
this function creates the tag, addresses and dynamic address group
this function creates the tag addresses and dynamic address group
# create the tag that will be used # create a DAG # create the address
address_group_name
addresses
tag
device_groups