You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Still using this and again its ace so thak you , just wondernig if there is an easy way to add to a group.
for example a user group has 2 members, if I set the members attribute on the group to add the additional it replaces the 2 with the 1 so it replaces instead of appends.
I have found a workaround but its pretty messy. basically gets the current lot of members then appends the new one to it.
@staticmethod
def print_dataAddress(response, response2=None, verbose=False):
if response['status']=='success':
if verbose:
pprint.pprint (response)
elif response['http_method']=='GET':
global data
data = {'member': []}
for member in response['results']:
for whats in member['member']:
data['member'].append({'name':((whats)['name'])})
else:
print ('OK!')
else:
print ('Fail!')
pprint.pprint (response)
@imatrycode
When you are working with the group, you can not access members separately. You can only deal with them as a whole set, whether you are creating or editing them.
Unfortunately I don't have fortigate readily available anymore, but I recall that some endpoints were allowing to edit some subitems. You could try to do something like t.create(['cmdb', 'user', 'group',X], data= {'name':("SOMETHING")}), where X is the id of your group. Again - I am not sure if you can access it or not and can't test it, but I recall some endpoints allowing you to do it.
Otherwise you have found acceptable workaround - just grab the list of all members, add/remove them as needed and push the whole list back to the firewall.
hello again,
Still using this and again its ace so thak you , just wondernig if there is an easy way to add to a group.
for example a user group has 2 members, if I set the members attribute on the group to add the additional it replaces the 2 with the 1 so it replaces instead of appends.
Any help on this would be appreicated
E.g. this creates the group with the member
t.print_data (t.create(['cmdb', 'user', 'group'], data={'name':'VLAN-'+(vlan)+'-GRP','group-type':'firewall','member':[{'name':(username)}]}),verbose=True)
Editing it's member attribute to say:
member':[{'name':(username), {'name':("SOMETHING")}]} replaces it with these 2
Bit If I do
ember':[{'name':("SOMETHING")}]}
it replaces all the members with the new one, wonder if there is an append method.
The text was updated successfully, but these errors were encountered: