Sync TAGS from one Resource Handlers to multiple Resource Handlers using shell_plus command

Use Case: I have 40+ Resource Handlers in which I would like to get the TAGS synchronized from one Resource Handler to another Resource Handlers.

Currently Cloudbolt UI do not support such feature. The Resource handlers are secured with individual access credentials and are individual entity resources. The associated tags could be used for security and costing purpose. So, due to security and other dependency, this feature is not enabled in UI. 
However, you may create such tags via script and run it at OS level. With automation, you may sync or update values for such tags via scripts/automation. 

a. ssh to your cloudbolt instance

b. /opt/cloudbolt/ shell_plus

In [41]: a_objects = TaggableAttribute.objects.filter(resource_handler_id=1) # rh id where tag is available
    ...: # loop over objects
    ...: for a in a_objects:
    ...:     # convert a to dictionary
    ...:     a_dict = a.__dict__
    ...:     a_dict.pop('id')   # remove primary key from dict
    ...:     a_dict.pop('_state')
    ...:     for rh_id in [2,3]: # resource handler id where tag is not available
    ...:         a_dict['resource_handler_id'] = rh_id
    ...:         # create B model
    ...:         TaggableAttribute.objects.get_or_create(**a_dict)

Have more questions? Submit a request


Please sign in to leave a comment.