#NEWLINE# @ classmethod #NEWLINE# def conf( cls ) : #NEWLINE# #INDENT# logger . debug ( 'Preparing config for snapshot' ) #NEWLINE# nodes = db ( ) . query ( Node ) . filter ( Node . status . in_ ( [ 'ready' , 'provisioned' , 'deploying' , 'error' ] ) ) . all ( ) #NEWLINE# dump_conf = deepcopy ( settings . DUMP ) #NEWLINE# for node in nodes : #NEWLINE# #INDENT# if ( node . cluster is None ) : #NEWLINE# #INDENT# logger . info ( 'Node {id} is not assigned to an environment, falling back to root' . format ( id = node . id ) ) #NEWLINE# ssh_user = 'root' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# editable_attrs = objects . Cluster . get_editable_attributes ( node . cluster ) #NEWLINE# try : #NEWLINE# #INDENT# ssh_user = editable_attrs [ 'service_user' ] [ 'name' ] [ 'value' ] #NEWLINE# #UNINDENT# except KeyError : #NEWLINE# #INDENT# logger . info ( "Environment {env} doesn't support non-root accounts on the slave nodes, falling back to root for node-{node}" . format ( env = node . cluster_id , node = node . id ) ) #NEWLINE# ssh_user = 'root' #NEWLINE# #UNINDENT# #UNINDENT# host = { #NEWLINE# #INDENT# 'hostname' : objects . Node . get_slave_name ( node ) , #NEWLINE# 'address' : node . ip , #NEWLINE# 'ssh-user' : ssh_user , #NEWLINE# 'ssh-key' : settings . SHOTGUN_SSH_KEY , #NEWLINE# #UNINDENT# } #NEWLINE# if ( 'controller' in node . roles ) : #NEWLINE# #INDENT# dump_conf [ 'dump' ] [ 'controller' ] [ 'hosts' ] . append ( host ) #NEWLINE# #UNINDENT# dump_conf [ 'dump' ] [ 'slave' ] [ 'hosts' ] . append ( host ) #NEWLINE# #UNINDENT# dump_conf [ 'dump' ] [ 'local' ] [ 'objects' ] . append ( { #NEWLINE# #INDENT# 'type' : 'postgres' , #NEWLINE# 'dbhost' : settings . DATABASE [ 'host' ] , #NEWLINE# 'dbname' : settings . DATABASE [ 'name' ] , #NEWLINE# 'username' : settings . DATABASE [ 'user' ] , #NEWLINE# 'password' : settings . DATABASE [ 'passwd' ] , #NEWLINE# #UNINDENT# } ) #NEWLINE# dump_conf [ 'dump' ] [ 'local' ] [ 'objects' ] . append ( { #NEWLINE# #INDENT# 'type' : 'xmlrpc' , #NEWLINE# 'server' : settings . COBBLER_URL , #NEWLINE# 'methods' : [ 'get_distros' , 'get_profiles' , 'get_systems' ] , #NEWLINE# 'to_file' : 'cobbler.txt' , #NEWLINE# #UNINDENT# } ) #NEWLINE# dump_conf [ 'dump' ] [ 'master' ] [ 'hosts' ] = [ { #NEWLINE# #INDENT# 'hostname' : socket . gethostname ( ) , #NEWLINE# 'address' : settings . MASTER_IP , #NEWLINE# 'ssh-key' : settings . SHOTGUN_SSH_KEY , #NEWLINE# #UNINDENT# } ] #NEWLINE# logger . debug ( 'Dump conf: %s' , str ( dump_conf ) ) #NEWLINE# return dump_conf