2 years ago
Using Python SDK to create a DeviceGroup and subGroups
I’m working on trying to build a script that will take some input (csv or stdin) to create a device group, and then also create multiple device groups under this one device group being specified.
I have the python script working to create the first device group I need, but the “subGroups” feature does not seem to work or be populated and I was curious if anyone else had any luck with it?
A snippet of my code looks like:
infra_root = 'Network Infrastructure'
infra_address = 'Test Location'
infra_sub_groups = [
{"name":"Aggregation","fullPath":infra_root+"/"+infra_address+"/Aggregation"},
{"name":"Access","fullPath":infra_root+"/"+infra_address+"/Access"},
{"name":"Environmental","fullPath":infra_root+"/"+infra_address+"/Environmental"},
{"name":"PDU","fullPath":infra_root+"/"+infra_address+"/PDU"},
{"name":"UPS","fullPath":infra_root+"/"+infra_address+"/UPS"}
]
body = {
#"fullPath":infra_root+"/"+infra_address,
"groupType":"Normal",
"disableAlerting":False,
"subGroups":infra_sub_groups,
"enableNetflow":False,
"parentId":18,
"name":infra_address
}
The script fires off without error and creates he “infra_address” group no problem (under the parent I have). But the output of the script shows me sub_groups is blank:
{'applies_to': '',
'aws_regions_info': '',
'aws_test_result': None,
'aws_test_result_code': 200,
'azure_regions_info': '',
'azure_test_result': None,
'azure_test_result_code': 200,
'created_on': 1676065949,
'custom_properties': [],
'default_collector_description': None,
'default_collector_id': 0,
'description': '',
'disable_alerting': False,
'effective_alert_enabled': True,
'enable_netflow': False,
'extra': {},
'full_path': 'Network Infrastructure/Test Location',
'gcp_regions_info': '',
'gcp_test_result': None,
'gcp_test_result_code': 200,
'group_status': 'normal',
'group_type': 'Normal',
'has_netflow_enabled_devices': False,
'id': 164,
'name': 'Test Location',
'num_of_aws_devices': 0,
'num_of_azure_devices': 0,
'num_of_direct_devices': 0,
'num_of_direct_sub_groups': 0,
'num_of_gcp_devices': 0,
'num_of_hosts': 0,
'parent_id': 18,
'sub_groups': [],
'user_permission': 'write'}
Doing it this way will make my life easier instead of running a script over and over again to populate the sub device groups.
Thanks!