Forum Discussion

Will_97818's avatar
Will_97818
Icon for Nimbostratus rankNimbostratus
Jul 07, 2015

Modify Region table via REST

We are trying to modify(add/delete entries) of a region table. This can be done via tmsh as

 

modify gtm region test_region region-members add { subnet 1.1.1.1/32}

 

modify gtm region test_region region-members delete { subnet 1.1.1.1/32}

 

If I try to add entries I get the following.

 

{ "code": 403, "message": "Operation is not allowed on property /gtm/region/Test_Region/region-members.", "errorStack": [] }

 

If I try to delete entries I get

 

{ "code": 403, "message": "Operation is not allowed on configuration item /gtm/region/Test_Region/region-members/subnet%201.1.1.1~32.", "errorStack": [] }

 

The only thing we can seem to do is a PUT to replace the entire region table. Is this not possible via REST?

 

  • Yep, you have to supply the entire region member list each time, so if you want to delete one, you have to basically send the entire list again without the member you wish to remove.

    Another option is to use a CLI script to do this:

    cli script addRegionMemberSubnet {
    proc script::init {} {
    }
    
    proc script::run {} {
        if { $tmsh::argc != 3 } {
          puts "a region name and a subnet must be provided"
          exit 123
          }
          set zero [lindex $tmsh::argv 0]
          set RegionName [lindex $tmsh::argv 1]
          set Subnet [lindex $tmsh::argv 2]
          puts "tmsh::modify gtm region $RegionName region-members add { subnet $Subnet }"
          tmsh::modify gtm region $RegionName region-members add { subnet $Subnet }
          exit 0
    }
    
    proc script::help {} {
    }
    
    proc script::tabc {} {
    }
        total-signing-status not-all-signed
    }
    

    You can then run this from REST using the payload format of

    {"command":"run","utilCmdArgs":"addRegionMemberSubnet Test_Region 1.1.1.1/32"} 
    

    on the URL of

    https://192.168.1.1/mgmt/tm/cli/script 
    

    I hope that helps.

  • Here is the syntax for the delete

     

    curl -sk -u admin "" -H "Content-Type: application/json" -X DELETE | jq . Enter host password for user 'admin': { "code": 403, "message": "Operation is not allowed on configuration item /gtm/region/Test_Region/region-members/subnet%201.1.1.1~32.", "errorStack": [] }

     

  • Yep, you have to supply the entire region member list each time, so if you want to delete one, you have to basically send the entire list again without the member you wish to remove.

    Another option is to use a CLI script to do this:

    cli script addRegionMemberSubnet {
    proc script::init {} {
    }
    
    proc script::run {} {
        if { $tmsh::argc != 3 } {
          puts "a region name and a subnet must be provided"
          exit 123
          }
          set zero [lindex $tmsh::argv 0]
          set RegionName [lindex $tmsh::argv 1]
          set Subnet [lindex $tmsh::argv 2]
          puts "tmsh::modify gtm region $RegionName region-members add { subnet $Subnet }"
          tmsh::modify gtm region $RegionName region-members add { subnet $Subnet }
          exit 0
    }
    
    proc script::help {} {
    }
    
    proc script::tabc {} {
    }
        total-signing-status not-all-signed
    }
    

    You can then run this from REST using the payload format of

    {"command":"run","utilCmdArgs":"addRegionMemberSubnet Test_Region 1.1.1.1/32"} 
    

    on the URL of

    https://192.168.1.1/mgmt/tm/cli/script 
    

    I hope that helps.

  • interesting you say that as I had opened a case with F5 and they said it was a bug and referenced https://support.f5.com/kb/en-us/solutions/public/15000/900/sol15921.html We were already running the fixed in version but I upgraded to 11.5.2 HF1 just in case but the issue persists.

     

    F5 seems to indicate it should work to modify individual members via rest api.

     

    While the script you provided would work(thank you!) we are hoping to avoid scripting. It's just another thing to break when we update code.