Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
osc-plugins
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
mpcdf
obs
osc-plugins
Commits
ce288a7f
Commit
ce288a7f
authored
5 years ago
by
Lorenz Hüdepohl
Browse files
Options
Downloads
Patches
Plain Diff
Add '--dry-run' for mpcdf_setup_cluster_project
parent
6f950c36
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mpcdf_setup_clusters_project.py
+51
-18
51 additions, 18 deletions
mpcdf_setup_clusters_project.py
with
51 additions
and
18 deletions
mpcdf_setup_clusters_project.py
+
51
−
18
View file @
ce288a7f
...
...
@@ -4,10 +4,13 @@ import osc
import
osc.conf
import
osc.core
import
osc.cmdln
from
xml.etree
import
ElementTree
import
mpcdf_common
@osc.cmdln.option
(
'
-n
'
,
'
--dry-run
'
,
action
=
"
store_true
"
,
help
=
"
Do not actually run anything but output the resulting prj/prjconf configuration
"
)
@osc.cmdln.alias
(
"
mpcdf_setup_clusters
"
)
def
do_mpcdf_setup_cluster_project
(
self
,
subcmd
,
opts
,
*
args
):
"""
${cmd_name}: Set-up the
'
clusters
'
project
...
...
@@ -26,12 +29,13 @@ def do_mpcdf_setup_cluster_project(self, subcmd, opts, *args):
api_url
=
self
.
get_api_url
()
projects
=
[
p
for
p
in
osc
.
core
.
meta_get_project_list
(
api_url
)
if
p
.
startswith
(
"
software:
"
)]
software_meta
=
mpcdf_common
.
project_meta
(
api_url
,
"
software
"
)
subprojects
=
[
p
for
p
in
osc
.
core
.
meta_get_project_list
(
api_url
)
if
p
.
startswith
(
"
software:
"
)]
macros
=
{}
for
project
in
projects
:
target
=
project
[
len
(
"
software:
"
):].
replace
(
"
:
"
,
"
-
"
)
for
sub
project
in
sub
projects
:
target
=
sub
project
[
len
(
"
software:
"
):].
replace
(
"
:
"
,
"
-
"
)
if
target
in
macros
:
raise
Exception
(
"
Internal error
"
)
...
...
@@ -39,10 +43,10 @@ def do_mpcdf_setup_cluster_project(self, subcmd, opts, *args):
macros
[
target
]
=
[]
for
attribute
in
mpcdf_common
.
config_attributes
+
mpcdf_common
.
default_attributes
:
_
,
name
=
attribute
.
split
(
"
:
"
)
values
=
mpcdf_common
.
overloaded_project_attribute
(
api_url
,
project
,
attribute
)
values
=
mpcdf_common
.
overloaded_project_attribute
(
api_url
,
sub
project
,
attribute
)
macros
[
target
].
append
(
"
%available_{0} {1}
"
.
format
(
name
,
"
,
"
.
join
(
sorted
(
values
))))
all_compilers
=
mpcdf_common
.
overloaded_project_attribute
(
api_url
,
project
,
"
MPCDF:compiler_modules
"
)
all_compilers
=
mpcdf_common
.
overloaded_project_attribute
(
api_url
,
sub
project
,
"
MPCDF:compiler_modules
"
)
latest_intel
=
sorted
((
c
for
c
in
all_compilers
if
c
.
startswith
(
"
intel
"
)),
key
=
mpcdf_common
.
package_sort_key
)[
-
1
]
latest_gcc
=
sorted
((
c
for
c
in
all_compilers
if
c
.
startswith
(
"
gcc
"
)),
key
=
mpcdf_common
.
package_sort_key
)[
-
1
]
macros
[
target
].
append
(
"
%latest_intel
"
+
latest_intel
)
...
...
@@ -63,22 +67,51 @@ def do_mpcdf_setup_cluster_project(self, subcmd, opts, *args):
prjconf_tail
=
""
.
join
(
prjconf
[
end
+
1
:])
prjconf
=
[
start_marker
]
distributions
=
osc
.
core
.
get_repositories_of_project
(
api_url
,
"
software
"
)
for
repo
in
osc
.
core
.
get_repositories_of_project
(
api_url
,
"
clusters
"
):
for
dist
in
distributions
:
if
repo
.
startswith
(
dist
):
break
dist
=
None
if
dist
is
None
:
raise
Exception
(
"
Internal error
"
)
prjconf
.
append
(
'
%if
"
%_repository
"
==
"
{0}
"'
.
format
(
repo
))
prj_meta
=
mpcdf_common
.
project_meta
(
api_url
,
"
clusters
"
)
for
oldrepo
in
prj_meta
.
findall
(
"
./repository
"
):
prj_meta
.
remove
(
oldrepo
)
for
subproject
in
subprojects
:
_
,
distribution
,
microarchitecture
=
subproject
.
split
(
"
:
"
)
reponame
=
"
{0}-{1}
"
.
format
(
distribution
,
microarchitecture
)
prjconf
.
append
(
'
%if
"
%_repository
"
==
"
{0}
"'
.
format
(
reponame
))
prjconf
.
append
(
"
Macros:
"
)
prjconf
.
extend
(
macros
[
repo
])
prjconf
.
append
(
"
%distribution {0}
"
.
format
(
dist
))
prjconf
.
extend
(
macros
[
repo
name
])
prjconf
.
append
(
"
%distribution {0}
"
.
format
(
dist
ribution
))
prjconf
.
append
(
"
:Macros
"
)
prjconf
.
append
(
"
%endif
"
)
prjconf
.
append
(
""
)
r
=
ElementTree
.
SubElement
(
prj_meta
,
"
repository
"
)
r
.
set
(
"
name
"
,
reponame
)
r
.
text
=
"
\n
"
for
repo
in
osc
.
core
.
get_repositories_of_project
(
api_url
,
subproject
):
p
=
ElementTree
.
SubElement
(
r
,
"
path
"
)
p
.
set
(
"
project
"
,
subproject
)
p
.
set
(
"
repository
"
,
repo
)
p
.
tail
=
"
\n
"
for
arch
in
software_meta
.
findall
(
'
./repository[@name=
"
{0}
"
]/arch
'
.
format
(
distribution
)):
a
=
ElementTree
.
SubElement
(
r
,
"
arch
"
)
a
.
text
=
arch
.
text
a
.
tail
=
"
\n
"
a
.
tail
=
"
\n
"
r
.
tail
=
"
\n
"
r
.
tail
=
"
\n
"
prjconf
.
append
(
end_marker
)
prjconf
=
prjconf_head
+
"
\n
"
.
join
(
prjconf
)
+
prjconf_tail
osc
.
core
.
edit_meta
(
"
prjconf
"
,
"
clusters
"
,
data
=
prjconf
,
apiurl
=
api_url
)
new_prj_meta
=
ElementTree
.
tostring
(
prj_meta
,
encoding
=
osc
.
core
.
ET_ENCODING
)
if
opts
.
dry_run
:
print
(
"
osc meta prjconf {0} -F - <<EOF
\n
{1}
\n
EOF
\n
"
.
format
(
"
clusters
"
,
prjconf
))
print
(
"
osc meta prj {0} -F - <<EOF
\n
{1}
\n
EOF
\n
"
.
format
(
"
clusters
"
,
new_prj_meta
))
else
:
print
(
"
Updating prjconf meta
"
)
osc
.
core
.
edit_meta
(
"
prjconf
"
,
"
clusters
"
,
data
=
prjconf
,
apiurl
=
api_url
)
# Update repositories
print
(
"
Updating prj meta
"
)
osc
.
core
.
edit_meta
(
"
prj
"
,
"
clusters
"
,
data
=
new_prj_meta
,
force
=
True
,
apiurl
=
api_url
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment