U g,@s2dZddddddddd d d d d dgZddlZddlZddlZddlZeZGdddeZda ddZ ddZ ddZ ddZ ddZddZddZddZdd ZddZGdd d eZGdd d eZGd d d eZGd!d"d"eZGd#d$d$eZGd%d d eZGd&ddeZGd'd(d(eZdS))zE!Provides information about the cluster on which this job is running.Clusterwherelongnamename group_quotas acl_supportno_access_controluse_acl_for_rstdatancepprodMSUOrionNOAAJetNOAAGAEANOAAHera NOAAWCOSSNc@s&eZdZdZdddZeddZdS)rz/!Stores information about a computer cluster. NcCsXt||_t||_|tk r&t||_t||_t||_|dkrN|joL|j}||_dS)z!Sets all public member variables. All are mandatory except use_acl_for_rstdata. The default for use_acl_for_rstdata is the logical AND of group_quotas and acl_support.N) boolrr DO_NOT_SET productionstrrrr)selfrrrrrrr=/lfs/h1/ops/prod/packages/hafs.v2.0.7/ush/produtil/cluster.py__init__s      zCluster.__init__cCs|jS)Nrrrrr partitionDszCluster.partition)N)__name__ __module__ __qualname____doc__rpropertyrrrrrrs  /cCs|adS)z!Sets the current cluster (module-level "here" variable) to the given value. Bad things may happen if this is not a subclass of Cluster. #@param there A Cluster object for this local cluster.N)here)Zthererrr set_clusterLsr!cCstdkrtjdrtantjdr0tantjdr\tjdr\tjdr\tan^tjdrtatjdrtan8tjdrt an$tjd rt ant d d d d d atS) z!Guesses what cluster the program is running on, and if it cannot, returns a cluster named "noname" with reasonable defaults. The result is stored in the module scope "here" variable.Nz/lfs3z/gladez/dataz/scratchz/homez /scratch1z /lfs/h2/emcz /lustre/f2FZnoname) r ospathexistsr UCARYellowstone WisconsinS4r Z NOAATheiaWCOSS2r rrrrrrTs&       cCstdkrttjS)z]!Synonym for here.longname. Will call the "where()" function if "here" is uninitialized.N)r rrrrrrrmscCstdkrttjS)zY!Synonym for here.name. Will call the "where()" function if "here" is uninitialized.N)r rrrrrrrsscCstdkrttjS)za!Synonym for here.group_quotas. Will call the "where()" function if "here" is uninitialized.N)r rrrrrrryscCstdkrttjS)z`!Synonym for here.acl_support. Will call the "where()" function if "here" is uninitialized.N)r rrrrrrrscCstdkrttjotj S)z!True if the cluster provides no means to control access to files. This is true if the cluster uses group ids for quotas, and provides no access control list support.N)r rrrrrrrrscCstdkrttjS)zh!Synonym for here.use_acl_for_rstdata. Will call the "where()" function if "here" is uninitialized.N)r rrrrrrrscCstdkrttjodtjkS)a,!Are we on NCEP production? @returns True if the present machine is the NCEP production machine. Note that this function may read a text file when it is called, and the return value may change during the execution of the program if the program is running during a production switch.NZncep)r rrrrrrrr scCstdkrttjS)zR!Returns system-specific information about what part of the system you are on.N)r rrrrrrrsrcs eZdZdZfddZZS)r a@!The NOAA Jet Cluster Represents the NOAA Jet cluster, which has non-functional ACL support. Will report that ACLs are supported, but should not be used. Also, group quotas are in use. That means that there is no means by which to restrict access control, so no_access_control() will return True.cstt|dddddddS)z!constructor for NOAAJetTFZjetzjet.rdhpcs.noaa.govN)superr rr __class__rrrszNOAAJet.__init__rrrrr __classcell__rrr)rr scs eZdZdZfddZZS)r z!Represents the NOAA GAEA cluster. Allows ACLs to be used for restricted data, and specifies that group quotas are not in use.cstt|ddddddS)z!constructor for NOAAGAEAFTZgaeazgaea.rdhpcs.noaa.govN)r(r rrr)rrrszNOAAGAEA.__init__r+rrr)rr scs eZdZdZfddZZS)r zn!Represents the NOAA Hera cluster. Does not allow ACLs, assumes no group quotas (fileset quotas instead).cstt|ddddddS)NFZherazhera.rdhpcs.noaa.gov)r(r rrr)rrrszNOAAHera.__init__r+rrr)rr scs eZdZdZfddZZS)r%zT!Represents the Yellowstone cluster. Does not allow ACLs, assumes group quotas.cstt|ddddddS)z !Constructor for UCARYellowstoneTFZ yellowstonezyellowstone.ucar.eduN)r(r%rrr)rrrs zUCARYellowstone.__init__r+rrr)rr%sr%cs eZdZdZfddZZS)r&zK!Represents the S4 cluster. Does not allow ACLs, assumes group quotas.cstt|ddddddS)z!Constructor for WisconsinS4TFZs4zs4.ssec.wisc.eduN)r(r&rrr)rrrs zWisconsinS4.__init__r+rrr)rr&sr&cs eZdZdZfddZZS)r zmRepresents the MSU Orion cluster. Does not allow ACLs, assumes no group quotas (fileset quotas instead).cstt|ddddddS)NFZorionzorion.hpc.msstate.edu)r(r rrr)rrrs zMSUOrion.__init__r+rrr)rr scs6eZdZdZd fdd ZddZedd ZZS) rak!Represents the NOAA WCOSS clusters, Tide, Gyre and the test system Eddy. Automatically determines which WCOSS the program is on based on the first letter of socket.gethostname(). Will report no ACL support, and no group quotas. Hence, the cluster should use group IDs for access control. The production accessor is no longer a public member variable: it is now a property, which may open the /etc/prod file. The result of the self.production property is cached for up to prod_cache_time seconds. That time can be specified in the constructor, and defaults to 30 seconds.Ncs<tt|ddt||d||_d|_d|_t||_dS)z!Creates a NOAAWCOSS object, and optionally specifies the time for which the result of self.production should be cached. Default: 30 seconds. @param prod_cache_time how long to cache the prod vs. dev information, in secondsFz.ncep.noaa.govNr) r(rrr_phase _production _lastprodint_prod_cache_time)rZprod_cache_timerZphaser)rrrszNOAAWCOSS.__init__cCsd|_d|_d|_dS)zh!Clears the cached value of self.production so the next call will return up-to-date information.Nr)r/r0r.rrrruncacheszNOAAWCOSS.uncachec Cstt}|jdks&||j|jkrd}tjdrtddR}|D]F}t d|rF| dddkrF| dd  |j k}qqFW5QRX||_tt|_|S|jSdS) a!Is this the WCOSS2 production machine? The name of the WCOSS2 production machine: cactus or dogwood luna as determined by the /lfs/h1/ops/prod/config/prodmachinefile file. @returns True or False: is this the WCOSS2 production machine? @note The return value may change during the execution of this program if a production switch happened. A cached value is returned if the values is not too old. To force a refresh, call uncache() first. @warning The check requires opening and parsing the /etc/prod file, so the runtime is likely several milliseconds when the cache times out.NFz'/lfs/h1/ops/prod/config/prodmachinefilertz[a-z]+:rZprimary)r1timer/r0r2r"r#r$openrematchstripsplitr)rnowprodflinerrrrs      zNOAAWCOSS.production)r-NN) rrrrrr3rrr,rrr)rrs   cs"eZdZdZdfdd ZZS)r'zW!This subclass of NOAAWCOSS handles the new Cray portions of WCOSS: Luna and Surge.NcsN|dkr8tdd}|dkr&d}n|dkr4d}nd}tt|j|ddS) a!Create a new WCOSS2 object describing this cluster as a Cray machine. @property name The name of the cluster. Default is to check the hostname with socket.gethosname() and decide "dogwood" vs. "cactus" based on the first letter of the hostname. Nrr6cZcactussZdogwoodr)socketZ gethostnamer(r'r)rrZhost1r)rrrszWCOSS2.__init__)Nr+rrr)rr'sr')r__all__r7rCr"r9objectrrr r!rrrrrrrr rr r r r%r&r rr'rrrrs@  7  C