#NEWLINE# def present( name , maintenance_db , user = None , db_password = None , db_host = None , db_port = None , db_user = None ) : #NEWLINE# #INDENT# '\n    Ensure that a named language is present in the specified\n    database.\n\n    name\n        The name of the language to install\n\n    maintenance_db\n        The name of the database in which the language is to be installed\n\n    user\n        System user all operations should be performed on behalf of\n\n    db_user\n        database username if different from config or default\n\n    db_password\n        user password if any password for a specified user\n\n    db_host\n        Database host if different from config or default\n\n    db_port\n        Database port if different from config or default\n    ' #NEWLINE# ret = { #NEWLINE# #INDENT# 'name' : name , #NEWLINE# 'changes' : { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } , #NEWLINE# 'result' : True , #NEWLINE# 'comment' : 'Language {0} is already installed' . format ( name ) , #NEWLINE# #UNINDENT# } #NEWLINE# dbargs = { #NEWLINE# #INDENT# 'runas' : user , #NEWLINE# 'host' : db_host , #NEWLINE# 'user' : db_user , #NEWLINE# 'port' : db_port , #NEWLINE# 'password' : db_password , #NEWLINE# #UNINDENT# } #NEWLINE# languages = __salt__ [ 'postgres.language_list' ] ( maintenance_db , ** dbargs ) #NEWLINE# if ( name not in languages ) : #NEWLINE# #INDENT# if __opts__ [ 'test' ] : #NEWLINE# #INDENT# ret [ 'result' ] = None #NEWLINE# ret [ 'comment' ] = 'Language {0} is set to be installed' . format ( name ) #NEWLINE# return ret #NEWLINE# #UNINDENT# if __salt__ [ 'postgres.language_create' ] ( name , maintenance_db , ** dbargs ) : #NEWLINE# #INDENT# ret [ 'comment' ] = 'Language {0} has been installed' . format ( name ) #NEWLINE# ret [ 'changes' ] [ name ] = 'Present' #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# ret [ 'comment' ] = 'Failed to install language {0}' . format ( name ) #NEWLINE# ret [ 'result' ] = False #NEWLINE# #UNINDENT# #UNINDENT# return ret