#NEWLINE# def run_edit( args ) : #NEWLINE# #INDENT# parser = ConfigParser . RawConfigParser ( ) #NEWLINE# parser . read ( [ args . econfig ] ) #NEWLINE# vals = { #NEWLINE# #INDENT# 'frontend' : { k : v for ( k , v ) in parser . items ( ( 'cluster/%s/frontend' % args . cluster ) ) } , #NEWLINE# 'cluster' : { k : v for ( k , v ) in parser . items ( ( 'cluster/%s' % args . cluster ) ) } , #NEWLINE# #UNINDENT# } #NEWLINE# print ( ( 'Changing configuration for cluster %s\n' % args . cluster ) ) #NEWLINE# nfs_size = _ask ( vals , 'Size of encrypted NFS mounted filesystem, in Gb' , [ 'frontend' , 'encrypted_volume_size' ] ) #NEWLINE# compute_nodes = _ask ( vals , 'Number of cluster worker nodes (0 starts a single machine instead of a cluster)' , [ 'cluster' , 'compute_nodes' ] ) #NEWLINE# if ( int ( compute_nodes ) == 0 ) : #NEWLINE# #INDENT# setup_provider = 'ansible' #NEWLINE# frontend_flavor = _ask ( vals , 'Machine type for single frontend worker node' , [ 'frontend' , 'flavor' ] ) #NEWLINE# compute_flavor = None #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# setup_provider = 'ansible-slurm' #NEWLINE# frontend_flavor = 'c3.large' #NEWLINE# compute_flavor = _ask ( vals , 'Machine type for compute nodes' , [ 'cluster' , 'flavor' ] ) #NEWLINE# #UNINDENT# iops = min ( ( int ( nfs_size ) * 30 ) , 4000 ) #NEWLINE# parser . set ( ( 'cluster/%s/frontend' % args . cluster ) , 'flavor' , frontend_flavor ) #NEWLINE# parser . set ( ( 'cluster/%s/frontend' % args . cluster ) , 'encrypted_volume_size' , nfs_size ) #NEWLINE# parser . set ( ( 'cluster/%s/frontend' % args . cluster ) , 'encrypted_volume_type' , 'io1' ) #NEWLINE# parser . set ( ( 'cluster/%s/frontend' % args . cluster ) , 'encrypted_volume_iops' , iops ) #NEWLINE# parser . set ( ( 'cluster/%s' % args . cluster ) , 'setup_provider' , setup_provider ) #NEWLINE# parser . set ( ( 'cluster/%s' % args . cluster ) , 'compute_nodes' , compute_nodes ) #NEWLINE# if compute_flavor : #NEWLINE# #INDENT# parser . set ( ( 'cluster/%s' % args . cluster ) , 'flavor' , compute_flavor ) #NEWLINE# #UNINDENT# bak_file = ( args . econfig + ( '.bak%s' % datetime . datetime . now ( ) . strftime ( '%Y-%m-%d-%H-%M-%S' ) ) ) #NEWLINE# shutil . copyfile ( args . econfig , bak_file ) #NEWLINE# with open ( args . econfig , 'w' ) as out_handle : #NEWLINE# #INDENT# parser . write ( out_handle ) #NEWLINE# #UNINDENT# print ( ) #NEWLINE# print ( ( 'Updated configuration for cluster %s' % args . cluster ) ) #NEWLINE# print ( "Run 'bcbio_vm.py aws info' to see full details for the cluster" )