Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
paas-tools
operators
landb-operator
Commits
21d06166
Commit
21d06166
authored
Aug 27, 2020
by
Joao Esteves Marcal
Browse files
Added spec.insertInSets
parent
516ac454
Pipeline
#1899093
passed with stage
in 57 seconds
Changes
5
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
chart/crds/landb.operator.cern.ch_landbsets_crd.yaml
View file @
21d06166
...
...
@@ -59,6 +59,12 @@ spec:
-
INTRA
minLength
:
1
type
:
string
insertInSets
:
description
:
InsertInSets list of lanDB sets we want to add this set
to
items
:
type
:
string
type
:
array
type
:
object
status
:
description
:
LandbSetStatus defines the observed state of LandbSet
...
...
deploy/crds/landb.operator.cern.ch_v1alpha1_landbset_cr.yaml
View file @
21d06166
apiVersion
:
landb.operator.cern.ch/v1alpha1
apiVersion
:
landb.operator.cern.ch/v1alpha1
kind
:
LandbSet
metadata
:
name
:
test-set
spec
:
setName
:
"
Test
Set"
labelSelector
:
node-role.kubernetes.io/worker=
Description
:
"
This
is
a
NICE
set"
\ No newline at end of file
description
:
"
This
is
a
NICE
set"
\ No newline at end of file
roles/files/main.py
View file @
21d06166
...
...
@@ -57,7 +57,7 @@ def dnsDelegatedSearch(search):
def
dnsDelegatedGetByNameView
(
search
,
extra
):
return
client
.
service
.
dnsDelegatedGetByNameView
(
search
,
extra
,
_soapheaders
=
auth_header
)
# This function searches for delegaed domains that match the string domain & view and then
# This function searches for delega
t
ed domains that match the string domain & view and then
# it asserts that Description of that domain matches the ownership_string
def
dnsCheckOwnership
(
domain
,
view
,
ownership_string
):
# Here we are adding a . before the name to match exactly how they are stored in the lanDB database
...
...
@@ -65,7 +65,7 @@ def dnsCheckOwnership(domain, view, ownership_string):
list_of_dns
=
dnsDelegatedGetByNameView
(
"."
+
domain
,
view
)
current_ownership_string
=
list_of_dns
[
"Description"
]
if
current_ownership_string
.
lower
()
!=
ownership_string
.
lower
():
raise
exceptions
.
Fault
(
"INVALIDOWNER: We are trying to modify a delegate domain that belongs to another DelegatedDomain CR "
+
current_ownership_string
)
raise
exceptions
.
Fault
(
"INVALIDOWNER: We are trying to modify a delegate
d
domain that belongs to another DelegatedDomain CR "
+
current_ownership_string
)
# Adds an alias to an existing dns entry
def
dnsDelegatedAliasAdd
(
domain
,
view
,
alias
):
...
...
@@ -158,6 +158,14 @@ def setInsertAddress(landb_set_name, machineName):
def
setDeleteAddress
(
landb_set_name
,
machineName
):
client
.
service
.
setDeleteAddress
(
landb_set_name
,
machineName
,
_soapheaders
=
auth_header
)
# Add an address to a set
def
setInsertSet
(
landb_set_name
,
setName
):
client
.
service
.
setAddSet
(
landb_set_name
,
setName
,
_soapheaders
=
auth_header
)
# Remove an address from a set
def
setDeleteSet
(
landb_set_name
,
setName
):
client
.
service
.
setDeleteSet
(
landb_set_name
,
setName
,
_soapheaders
=
auth_header
)
# -------------- END OF LANDB SET RELATED FUNCTIONS --------------
def
main
():
...
...
@@ -191,6 +199,8 @@ def main():
parser
.
add_argument
(
'--person-first-name'
,
dest
=
'firstName'
,
default
=
""
,
type
=
str
,
help
=
'fisrtName of the person
\
who
\'
s going to be responsible by the landb set'
)
parser
.
add_argument
(
'--type'
,
type
=
str
,
default
=
""
,
help
=
'type of the landb set'
)
parser
.
add_argument
(
'--insert-in-set'
,
dest
=
'set_list'
,
action
=
'append'
,
nargs
=
'*'
,
help
=
'Sets to whom the new set
\
should be added to, this parameter can be specified multiple times'
)
# Parameters specific to set-add-address
parser
.
add_argument
(
'--address'
,
type
=
str
,
default
=
""
,
help
=
'FQDN to be added to the set provided'
)
...
...
@@ -226,6 +236,13 @@ def main():
setInsert
(
args
.
landb_set_name
)
if
len
(
args
.
set_list
)
!=
0
:
for
parrentSet
in
args
.
set_list
:
# Given that we allow the variable to be specified multiple times the structure of this
# variable will be [['Parents Set 1'], ['Parents Set 2'], ['Parents Set 3']] so in the index 0
# we will have the string with the set name
setInsertSet
(
parrentSet
[
0
],
args
.
landb_set_name
)
print
(
"Set created with success"
)
elif
args
.
command
==
'set-remove'
:
...
...
roles/landbset/defaults/main.yml
View file @
21d06166
...
...
@@ -26,3 +26,7 @@ landb_responsible: "{{ lookup('env','LANDB_RESPONSIBLE') }}"
# This variable will be used to pass to python scrip the list of node names that
# we want to add to the lanDB set
list_names
:
"
"
# This variable will be used to pass to python scrip the list of set names to
# whom the new sets should be added to
set_names
:
"
"
roles/landbset/tasks/main.yml
View file @
21d06166
...
...
@@ -8,10 +8,19 @@
# Definition for both variables landb_user, landb_password, landb_responsible and list_names are in the file defaults/main.yml
# If not deleting, create a string of set names separated by ","
# to serve as input when adding a set to LandDB. This list will contain
# the all the lanDB sets to whom the new set should be added to
-
name
:
Create set name string
set_fact
:
set_names
:
'
{{
set_names
+
"
--insert-in-set
"
+
item
}}'
loop
:
'
{{
insert_in_sets
}}'
when
:
state == 'present'
# If are not deleting, then we also want to add the set to lanDB
# flag --person-first-name is omited as it will not be relevant for our use case where the responsible is an e-group
-
name
:
Add set to lanDB
script
:
../files/main.py --landb-user '{{ landb_user }}' --landb-password '{{ landb_password }}' --command set-add --landb-set-name '{{ set_name }}' --person-name '{{ landb_responsible }}' --description '{{ description }}' --domain '{{ domain }}' --type '{{ type }}'
script
:
../files/main.py --landb-user '{{ landb_user }}' --landb-password '{{ landb_password }}' --command set-add --landb-set-name '{{ set_name }}' --person-name '{{ landb_responsible }}' --description '{{ description }}' --domain '{{ domain }}' --type '{{ type }}'
'{{ set_names }}'
args
:
executable
:
python3
when
:
state == 'present'
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment