5 Replies Latest reply on Apr 7, 2015 11:17 AM by philmodjunk

    Need Script Help Assign an IP Address from a range

    TerMight62

      Title

      Need Script Help Assign an IP Address from a range

      Post

      I need help.

      I have a Database that tracks Customers on a small ISP. Each Customer is Assigned an IP from a Bank ex 10.10.11.1, 10.10.11.2  and so on. I want to have the Databas look at a list of IP's and assign the next IP address that is not already assigned to a customer. 

      And then possible when the customer is marked as INactive it will return the IP address back to the pool of available IP's

      Any Ideas?

      Thanks in advance

        • 1. Re: Need Script Help Assign an IP Address from a range
          philmodjunk

          I would use a looping script to populate a table that has a field for the customer ID and a field for the IP address (it may be easier to use two or more fields for the IP address). The script would generate the complete range of possible IP addresses.

          To assign a new IP address to a customer, perform a find for all records in this table where the customer ID field is empty and assign the new customer's ID to that record. To release an IP address back into the pool of available addresses, clear the record's customer ID field.

          • 2. Re: Need Script Help Assign an IP Address from a range
            TerMight62

            Thank you for the quick reply that is exactly along the line that I was thinking I would need to go. However pretty new at Scripting and couldnt figure out how to write out that specific script. 

            I would use a looping script to populate a table that has a field for the customer ID and a field for the IP address (it may be easier to use two or more fields for the IP address). The script would generate the complete range of possible IP addresses

            My Ip Address range is already Generated. and in a table "IP Bank" with with two fields "Cust ID" and "IP Address" 

            To assign a new IP address to a customer, perform a find for all records in this table where the customer ID field is empty and assign the new customer's ID to that record.

            My other table "Customer Info" has many other fields as well as a "Cust ID" and "Ip Address" field. 

            Would you be able to Show me What this script may look like I have been trying to write myself but I am having no luck.

            Thanks

            • 3. Re: Need Script Help Assign an IP Address from a range
              philmodjunk

              #starting from the record for which you need the IP address...
              Set Variable [$CustID ; value: Customers::__pkCustomerID ]
              Go to Layout ["IP Addresses" (IPAddresses) ]
              Enter Find mode [] ---> clear the pause check box
              Set Field [IPAddresses::_fkCustomerID ; "=" ]
              Set Error Capture [on]
              Perform Find[]
              If [ Not Get ( FoundCOunt ) ]
                 Show Custom dialog [ "No unassigned IP addresses were found" ]
              Else
                 Set Field [IPAddresses::_fkCustomerID ; $CustID ]
              End IF
              Go to Layout [Original Layout]

              Of course, you'll need to use your table occurrence and field names in place of mine.

              • 4. Re: Need Script Help Assign an IP Address from a range
                TerMight62

                #starting from the record for which you need the IP address...
                Set Variable [$CustID ; value: Customers::__pkCustomerID ]
                Go to Layout ["IP Addresses" (IPAddresses) ]
                Enter Find mode [] ---> clear the pause check box
                Set Field [IPAddresses::_fkCustomerID ; "=" ]
                Set Error Capture [on]
                Perform Find[]
                If [ Not Get ( FoundCOunt ) ]
                   Show Custom dialog [ "No unassigned IP addresses were found" ]
                Else
                   Set Field [IPAddresses::_fkCustomerID ; $CustID ]
                End IF
                Go to Layout [Original Layout]

                Just Tried this this morning at work. and it does exactly what I wanted. Thank you PhilModJunk!

                I Have 3 Different Ip Banks ( one for each service area as the addressing scheme is different. ie area 1 is 10.10.11.1  area 2 is 10.10.22.1 and area 3 is 10.10.33.1)

                How would I modify that script to go to the correct Table to get an IP. I have another field on the Customer Info table named "Service area" it is radio buttons for "area 1" "area 2" and "area 3"

                Thanks in advance

                 

                 

                • 5. Re: Need Script Help Assign an IP Address from a range
                  philmodjunk

                  I would use one table for all of the IP bank data but modify the script so that it finds unassigned IP address records for a specific subset of the total list of IP addresses.