Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Management Node Recipe example
def TurnOn(arg = None):
print("Turning on Nodes")
for parameters in lookup_parameter('members') or []:
if(parameters != None):
targetNode = parameters.get('targetNode')
remoteActionName = parameters.get('targetActionName')
lookup_remote_action(targetNode + remoteActionName).call()
def UpdateStatus(message):
print('Management Status: Status requested')
aggregateMessage = ''
for parameters in lookup_parameter('members') or []:
if(parameters != None):
targetNode = parameters.get('targetNode')
remoteEventStatusName = parameters.get('targetEventName')
message = lookup_remote_event(remoteEventStatusName).getArg().get('message')
aggregateMessage = targetNode + ': ' + message + ' - '
lookup_local_event(remoteEventStatusName).emit({'message': message})
lookup_local_event("ManagementStatus").emit({'message': aggregateMessage})
statusMetadata = {'Group': 'Status', 'schema':
{'title': '', 'type': 'array', 'items':
{'type': 'object', 'properties':
{
'message': {'type': 'string'},
}
}
}}
param_members = Parameter({'title': 'Management Node Member', 'schema': {'type': 'array', 'items':
{'type': 'object', 'properties':
{
'targetNode': {'title': 'Target Node', 'type': 'string', 'required': True, 'order': 1},
'targetActionName': {'title': 'Target Remote Action Name', 'type': 'string', 'required': True, 'order': 2},
'targetEventName': {'title': 'Target Remote Event Status Name', 'type': 'string', 'required': True, 'order': 4},
}
}
}})
def main(arg = None):
print("Node started...")
statusMetadata['schema']['title'] = 'ManagementStatus'
create_local_event("ManagementStatus", statusMetadata)
create_local_action("TurnOn", TurnOn, None)
for parameters in lookup_parameter('members') or []:
if(parameters != None):
targetNode = parameters.get('targetNode')
remoteActionName = parameters.get('targetActionName')
remoteEventStatusName = parameters.get('targetEventName')
create_remote_action(targetNode + remoteActionName, None, targetNode, remoteActionName)
statusMetadata['schema']['title'] = remoteEventStatusName
create_local_event(remoteEventStatusName, statusMetadata)
create_remote_event(remoteEventStatusName, UpdateStatus, None, targetNode, remoteEventStatusName)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.