-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcondor_submit
executable file
·188 lines (165 loc) · 5.46 KB
/
condor_submit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
#!/bin/bash
# Adapted by Mats Rynge from Purdue's wrapper script
# Adaptation to OSG-Connect by Marco Mambelli - [email protected]
CONDOR_SUBMIT_REAL="/usr/bin/.condor_submit"
# Must have interface: CHECK_MEMBERSHIP [-u UID] [PROJECT]
# return valid project list if project is not provuded, otherwise
# return 0 if user is member of project, 1 otherwise
CHECK_MEMBERSHIP="/usr/bin/osgconnect_show_projects -q"
COUSERNAME=`/usr/bin/id -un`
COGROUPNAME=`/usr/bin/id -gn`
SUBARGS=$*
NEXTARG=0
VANILLA=""
# Uncomment the following line to test project validity,
# NOTE: you must belong to unix groups named after the project name (capitalization counts)
# previous version was using project files
TEST_VALID="yes"
# Uncomment the following to set the XSEDE accounting group
# This has not been tested with unix groups, still requires project files
#SET_ACCOUNTING="yes"
if [ $# -gt 0 ]; then
for subarg in "$@"; do
case $subarg in
-v*)
;;
-d*)
;;
-s*)
;;
--h*)
;;
-h*)
;;
-p*)
NEXTARG=1
;;
-a*)
NEXTARG=1
;;
-r*)
NEXTARG=1
;;
-n*)
NEXTARG=1
;;
*)
if [ $NEXTARG -ne 1 ]; then
SUBFILE="$subarg"
VANILLA=`grep -i vanilla $SUBFILE`
else
NEXTARG=0
fi
esac
done
fi
if [ -z "$SUBFILE" ]; then
exec $CONDOR_SUBMIT_REAL "$@"
fi
# check for certain universes and submit regardless eif one of them
universe=`grep -i universe $SUBFILE | grep -v \# | cut -d= -f2`
case $universe in
*scheduler*)
exec $CONDOR_SUBMIT_REAL "$@"
;;
*local*)
exec $CONDOR_SUBMIT_REAL "$@"
;;
*)
/bin/true
;;
esac
me=`whoami`
# first check the job classad
OSG_PROJECT=`grep -i '^\+ProjectName' $SUBFILE | cut -d= -f2`
# then a default projects file in the user's home directory
if [ -z "$OSG_PROJECT" -a -e "$HOME/.osg_default_project" ]; then
OSG_PROJECT=`cat "$HOME/.osg_default_project"`
fi
# NO MORE default OSG Connect project
#if [ -z "$OSG_PROJECT" ]; then
# OSG_PROJECT="OSG-Connect"
#fi
function check_project {
# $1 user, $2 group to test (optional)
# if no $2 is given then all groups including the user are returned
if [ "x$2" == "x" ]; then
# if [ -f etc/osg/projects ]; then
# cat /etc/osg/projects | grep $me | sed 's/:.*//' | sort
# fi
# could invoke osgconnect_show_projects
echo "$(getent group | tr : , | sed -e 's/$/,/' | grep ,$1, | cut -d, -f1 | grep ^[@_] | sed -e 's/^@/con-/' | sed -e 's/^_//' | sort)"
return
else
tmp_group=`echo $2 | sed -e 's/^con-/@/'`
echo ,$(getent group $tmp_group | cut -d: -f4), | grep ",$1," 2>&1 > /dev/null
return $?
fi
}
if [ -z "$OSG_PROJECT" ]; then
echo
echo "No ProjectName ClassAd defined!"
echo "Please record your OSG project ID in your submit file."
echo " Example: +ProjectName = \"OSG-CO1234567\""
echo
echo "Based on your username, here is a list of projects you might have "
echo "access to:"
#check_project $me
$CHECK_MEMBERSHIP -u $me
exit 1
fi
OSG_PROJECT=`echo "$OSG_PROJECT" | sed "s/[\"' \t]//g"` # get rid of quotes and spaces
# by here, we have a project number specified. Is it valid?
if [ ! -z "$TEST_VALID" ]; then
#grep "^$OSG_PROJECT:" /etc/osg/projects | grep $me 2>&1 > /dev/null
#echo ,$(getent group $OSG_PROJECT | cut -d: -f4), | grep ",$me," 2>&1 > /dev/null
$CHECK_MEMBERSHIP -u $me $OSG_PROJECT
valid=$?
if [ "${valid}" == "1" ]; then # Nope
echo
echo "Sorry, the project you specified ($OSG_PROJECT) is not valid or "
echo "you are not in the list of allowed users."
echo
echo "Based on your username, here is a list of projects you might have "
echo "access to:"
$CHECK_MEMBERSHIP -u $me
exit 1
fi
fi
if [ ! -z "$SET_ACCOUNTING" ]
then
# what accounting group do we belong to?
#ACCTGROUP="group_other.$me"
ACCTGROUP="group_opportunistic.$me"
if grep -i "^$OSG_PROJECT:" /etc/osg/xsede-projects-low-priority >/dev/null 2>&1; then
#ACCTGROUP="group_xsede.low.$me"
ACCTGROUP="group_opportunistic.$me"
elif grep -i "^$OSG_PROJECT:" /etc/osg/xsede-projects-high-priority >/dev/null 2>&1; then
ACCTGROUP="group_xsede.high.$me"
elif [ "x$XSEDE_PROJECT" = "xTG-TRA100004" ];then
# special rule for TG-TRA100004 - rynge 8/12/13
ACCTGROUP="group_other.$me"
fi
# special cases
if echo "$OSG_PROJECT" | grep -i "OSG-Staff" >/dev/null 2>&1; then
ACCTGROUP="group_xsede.high.$me"
fi
#if echo "$XSEDE_PROJECT" | grep -i "Snowmass" >/dev/null 2>&1; then
# ACCTGROUP="group_snowmass.$me"
#fi
# Accouting group OVERRIDE required by MWT2
# +AccountingGroup="group_opport.vo.uc3.`whoami`"
ACCTGROUP="group_opport.vo.uc3.$me"
# if we get this far, we're ok
exec $CONDOR_SUBMIT_REAL \
-a "+UsedOCWrapper = TRUE" \
-a "+ProjectName = \"${OSG_PROJECT}\"" \
-a "+AccountingGroup = \"${ACCTGROUP}\"" \
"$@"
# ending!
fi
# if we get this far, we're ok (no accounting set)
exec $CONDOR_SUBMIT_REAL \
-a "+UsedOCWrapper = TRUE" \
-a "+ProjectName = \"${OSG_PROJECT}\"" \
"$@"