Forum Discussion

martek_58308's avatar
martek_58308
Icon for Nimbostratus rankNimbostratus
Aug 03, 2016
Solved

REST - setSyncLeader in device-group

Hi guys,

 

Need a help with another bit of REST config - bellow is TMSH command to do this

 

modify cm device-group DEVICE_GROUP_NAME devices modify { DEVICE_NAME { set-sync-leader } }

 

and I though that "mgmt/tm/cm/device-group/devices" suppose to do this same

 

However I can't do even GET to this and is returning "Object not found - devices" then I though - well maybe I should specify which device group I want to query so my new REST command looked like bellow

 

https://x.x.x.x/mgmt/tm/cm/device-group/~Common~device_trust_group/devices

 

and this returned me my two devices in this group - however there is no option for "setSyncLeader"

 

I tried POST as well which in my opinion should looks like either

 

https://x.x.x.x/mgmt/tm/cm/device-group/~Common~device_trust_group/devices/~Common~lb01a.tst.com

 

with body like

 

{ "setSyncLeader": true }

 

or I tried as well option like bellow

 

https://x.x.x.x/mgmt/tm/cm/device-group/~Common~device_trust_group/devices

 

with body like bellow

 

{ "name": "lb01a.tst.com", "setSyncLeader": true }

 

Both returned : The requested device group device (/Common/device_trust_group /Common/lb01a.tst.com) already exists."

 

I run out of ideas tbh and any help really appreciated - I can probably run TMSH command but prefer not to

 

Regards, Marcin

 

  • Terse answer.. I am typing on phone traveling..

     

    You woukd not use POST in the device group as you are working with an existing group, not creating one.

     

    I believe you want to use the PATCH verb on the full devicegroup / devices / device URL.

     

3 Replies

  • John_Gruber_432's avatar
    John_Gruber_432
    Historic F5 Account

    Terse answer.. I am typing on phone traveling..

     

    You woukd not use POST in the device group as you are working with an existing group, not creating one.

     

    I believe you want to use the PATCH verb on the full devicegroup / devices / device URL.

     

    • martek_58308's avatar
      martek_58308
      Icon for Nimbostratus rankNimbostratus

      Hi John,

       

      Thx for the clue - sometimes the simplest solution are hidden in front of our eyes

       

      Regards, Marcin

       

  • I'm doing the same in a shell script using PUT as http method. Maybe the snippet will help you:

    lb=my_bigip_fqdn
    dg=device_group_name
    
    lb_commit() {
      local lb_name=$1
      local rest_object_path=$2
      local http_uri=/mgmt/tm"$rest_object_path"
      local http_method=$3
      local json_data=$4
      echo $(curl --insecure -1 -sk -u admin:$adminpw https://$lb_name$http_uri -H 'Content-Type: application/json' -X $http_method -d "$json_data")
    }
    
    result=$(lb_commit $lb /cm/device-group/~Common~$dg/devices/$lb/ PUT "{\"set-sync-leader\":true}")
    echo $result