Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathresource_groups_example.py
More file actions
Latest commit
40 lines (28 loc) · 1.33 KB
/
Copy pathresource_groups_example.py
File metadata and controls
40 lines (28 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
importlogging
importtraceback
# Place script specific intersight api imports here
fromintersight.apiimportresource_api
fromintersight.apiimportasset_api
importintersight
importcredentials
FORMAT='%(asctime)-15s [%(levelname)s] [%(filename)s:%(lineno)s] %(message)s'
logging.basicConfig(format=FORMAT, level=logging.DEBUG)
logger=logging.getLogger('openapi')
defmain():
client=credentials.config_credentials()
try:
# Start main code here
resource_instance=resource_api.ResourceApi(client)
asset_instance=asset_api.AssetApi(client)
query_filter="not startsWith(Name,'License')"
api_response=resource_instance.get_resource_group_list(filter=query_filter)
forresultinapi_response.results:
print('Resource Group:', result.name, result.per_type_combined_selector[0].combined_selector)
reg_response=asset_instance.get_asset_device_registration_list(filter=result.per_type_combined_selector[0].combined_selector)
forreginreg_response.results:
print("\tHostname: %s, Platform: %s, SN: %s"% (reg.device_hostname, reg.platform_type, reg.serial))
exceptintersight.OpenApiExceptionasexp:
logger.error("Exception when calling API: %s\n"%exp)
traceback.print_exc()
if__name__=="__main__":
main()