#NEWLINE# def joined( name , host , user = 'rabbit' , ram_node = None , runas = 'root' ) : #NEWLINE# #INDENT# '\n    Ensure the current node joined to a cluster with node user@host\n\n    name\n        Irrelevant, not used (recommended: user@host)\n    user\n        The user of node to join to (default: rabbit)\n    host\n        The host of node to join to\n    ram_node\n        Join node as a RAM node\n    runas\n        The user to run the rabbitmq command as\n    ' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : '' , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# #UNINDENT# } #NEWLINE# status = __salt__ [ 'rabbitmq.cluster_status' ] ( ) #NEWLINE# if ( '{0}@{1}' . format ( user , host ) in status ) : #NEWLINE# #INDENT# ret [ 'comment' ] = 'Already in cluster' #NEWLINE# return ret #NEWLINE# #UNINDENT# if ( not __opts__ [ 'test' ] ) : #NEWLINE# #INDENT# result = __salt__ [ 'rabbitmq.join_cluster' ] ( host , user , ram_node , runas = runas ) #NEWLINE# if ( 'Error' in result ) : #NEWLINE# #INDENT# ret [ 'result' ] = False #NEWLINE# ret [ 'comment' ] = result [ 'Error' ] #NEWLINE# return ret #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# if ( 'Join' in result ) : #NEWLINE# #INDENT# ret [ 'comment' ] = result [ 'Join' ] #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# ret [ 'changes' ] = { #NEWLINE# #INDENT# 'old' : '' , #NEWLINE# 'new' : '{0}@{1}' . format ( user , host ) , #NEWLINE# #UNINDENT# } #NEWLINE# if __opts__ [ 'test' ] : #NEWLINE# #INDENT# ret [ 'result' ] = None #NEWLINE# ret [ 'comment' ] = 'Node is set to join cluster {0}@{1}' . format ( user , host ) #NEWLINE# #UNINDENT# return ret