@@ -13,16 +13,13 @@ from configparser import ConfigParser
13
13
import glob
14
14
import os
15
15
import sys
16
- from typing import Dict
17
16
18
17
if __name__ == "__main__" and __package__ is None :
19
18
sys .path .append (os .path .dirname (os .path .dirname (os .path .abspath (__file__ ))))
20
19
21
20
# local imports here
22
- from osg_configure .modules .ce_attributes import BATCH_SYSTEMS , BATCH_SYSTEMS_CASE_MAP
23
- from osg_configure .modules .exceptions import Error , SettingError
24
- from osg_configure .modules import subcluster
25
- from osg_configure .modules import utilities
21
+ from osg_configure .modules .ce_attributes import BATCH_SYSTEMS , get_attributes
22
+ from osg_configure .modules .exceptions import Error
26
23
from osg_configure .version import __version__
27
24
28
25
@@ -51,86 +48,6 @@ def load_configs(config_location: str) -> ConfigParser:
51
48
return config
52
49
53
50
54
- def empty_if_blank (value : str ) -> str :
55
- return "" if utilities .blank (value ) else value
56
-
57
-
58
- def get_resource_from_config (config : ConfigParser ) -> str :
59
- return utilities .classad_quote (
60
- empty_if_blank (
61
- config .get ("Site Information" , "resource" , fallback = "" )
62
- )
63
- )
64
-
65
-
66
- def get_resource_group_from_config (config : ConfigParser ) -> str :
67
- return utilities .classad_quote (
68
- empty_if_blank (
69
- config .get ("Site Information" , "resource_group" , fallback = "" )
70
- )
71
- )
72
-
73
-
74
- def get_batch_systems_from_config (config : ConfigParser ) -> str :
75
- batch_systems = []
76
-
77
- siteinfo_batch_systems = config .get ("Site Information" , "batch_systems" , fallback = None )
78
- if siteinfo_batch_systems is not None :
79
- # Site Information.batch_systems specified -- this one wins
80
- split_batch_systems = utilities .split_comma_separated_list (siteinfo_batch_systems )
81
- for batch_system in split_batch_systems :
82
- try :
83
- batch_systems .append (BATCH_SYSTEMS_CASE_MAP [batch_system .lower ()])
84
- except KeyError :
85
- raise SettingError ("Unrecognized batch system %s" % batch_system )
86
- else :
87
- # Add each batch system that's enabled from the sections in the 20-*.ini files.
88
- for batch_system in BATCH_SYSTEMS :
89
- if batch_system in config :
90
- if config .getboolean (section = batch_system , option = "enabled" , fallback = None ):
91
- batch_systems .append (batch_system )
92
-
93
- # Special case: Bosco (see SOFTWARE-3720); use the Bosco.batch argument.
94
- if config .getboolean ("Bosco" , "enabled" , fallback = False ):
95
- bosco_batch = config .get ("Bosco" , "batch" , fallback = None )
96
- if bosco_batch :
97
- try :
98
- batch_systems .append (BATCH_SYSTEMS_CASE_MAP [bosco_batch .lower ()])
99
- except KeyError :
100
- raise SettingError ("Unrecognized batch system %s in Bosco section" % bosco_batch )
101
-
102
- return utilities .classad_quote ("," .join (batch_systems ))
103
-
104
-
105
- def get_resource_catalog_from_config (config : ConfigParser ) -> str :
106
- return subcluster .resource_catalog_from_config (config , default_allowed_vos = []).format_value ()
107
-
108
-
109
- def get_attributes (config : ConfigParser ) -> Dict [str , str ]:
110
- """Turn config from .ini files into a dict of condor settings.
111
-
112
- """
113
- attributes = {}
114
-
115
- resource = get_resource_from_config (config )
116
- if resource and resource != '""' :
117
- attributes ["OSG_Resource" ] = resource
118
-
119
- resource_group = get_resource_group_from_config (config )
120
- if resource_group and resource_group != '""' :
121
- attributes ["OSG_ResourceGroup" ] = resource_group
122
-
123
- batch_systems = get_batch_systems_from_config (config )
124
- if batch_systems and batch_systems != '""' :
125
- attributes ["OSG_BatchSystems" ] = batch_systems
126
-
127
- resource_catalog = get_resource_catalog_from_config (config )
128
- if resource_catalog and resource_catalog != "{}" :
129
- attributes ["OSG_ResourceCatalog" ] = resource_catalog
130
-
131
- return attributes
132
-
133
-
134
51
def get_options (args ):
135
52
"""Parse, validate, and transform command-line options."""
136
53
parser = ArgumentParser (prog = "osg-ca-attrib-gen" , description = __doc__ )
0 commit comments