Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
devops
Manage
Activity
Members
Labels
Plan
Issues
4
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
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
osm
devops
Commits
eb0de08b
Commit
eb0de08b
authored
6 years ago
by
calvinosanch
Committed by
calvinosanch
6 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Adding checks to upgrade and validation tools
Signed-off-by:
gcalvino
<
guillermo.calvinosanchez@altran.com
>
parent
dbada22a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
descriptor-packages/tools/upgrade_descriptor_version.py
+20
-0
20 additions, 0 deletions
descriptor-packages/tools/upgrade_descriptor_version.py
descriptor-packages/tools/validate_descriptor.py
+32
-0
32 additions, 0 deletions
descriptor-packages/tools/validate_descriptor.py
with
52 additions
and
0 deletions
descriptor-packages/tools/upgrade_descriptor_version.py
+
20
−
0
View file @
eb0de08b
...
...
@@ -129,6 +129,16 @@ if __name__=="__main__":
if
"
vnfd:vnfd-catalog
"
in
data
or
"
vnfd-catalog
"
in
data
:
descriptor
=
"
VNF
"
#Check if mgmt-interface is defined:
remove_prefix
(
data
,
"
vnfd:
"
)
vnfd_descriptor
=
data
[
"
vnfd-catalog
"
]
vnfd_list
=
vnfd_descriptor
[
"
vnfd
"
]
mgmt_iface
=
False
for
vnfd
in
vnfd_list
:
if
vnfd
.
get
(
"
mgmt-interface
"
):
mgmt_iface
=
True
if
not
mgmt_iface
:
raise
KeyError
(
"'
mgmt-iface
'
is a mandatory field and it is not defined
"
)
myvnfd
=
vnfd_catalog
.
vnfd
()
pybindJSONDecoder
.
load_ietf_json
(
data
,
None
,
None
,
obj
=
myvnfd
)
elif
"
nsd:nsd-catalog
"
in
data
or
"
nsd-catalog
"
in
data
:
...
...
@@ -192,6 +202,8 @@ if __name__=="__main__":
error_position
.
append
(
"
external-interface
"
)
for
external_interface
in
external_interface_list
:
error_position
[
-
1
]
=
"
external-interface[{}]
"
.
format
(
external_interface
[
"
name
"
])
if
"
rw-vnfd:floating-ip-needed
"
in
external_interface
:
del
external_interface
[
"
rw-vnfd:floating-ip-needed
"
]
external_interface
[
"
type
"
]
=
"
EXTERNAL
"
external_interface
[
"
external-connection-point-ref
"
]
=
\
external_interface
.
pop
(
"
vnfd-connection-point-ref
"
)
...
...
@@ -210,6 +222,14 @@ if __name__=="__main__":
internal_interface
.
pop
(
"
vdu-internal-connection-point-ref
"
)
interface_list
.
append
(
internal_interface
)
error_position
.
pop
()
#Removing "rw-vnfd:floating-ip-needed" items from V3 descriptors
interfaces
=
vdu
.
pop
(
"
interface
"
,
())
for
iface
in
interfaces
:
if
"
rw-vnfd:floating-ip-needed
"
in
iface
:
del
iface
[
"
rw-vnfd:floating-ip-needed
"
]
interface_list
.
append
(
iface
)
# order interface alphabetically and set position
if
interface_list
:
interface_list
=
sorted
(
interface_list
,
...
...
This diff is collapsed.
Click to expand it.
descriptor-packages/tools/validate_descriptor.py
+
32
−
0
View file @
eb0de08b
...
...
@@ -46,6 +46,28 @@ def usage():
print
(
"
-i|--input FILE: (same as param FILE) descriptor file to be upgraded
"
)
return
def
remove_prefix
(
desc
,
prefix
):
"""
Recursively removes prefix from keys
:param desc: dictionary or list to change
:param prefix: prefix to remove. Must
:return: None, param desc is changed
"""
prefix_len
=
len
(
prefix
)
if
isinstance
(
desc
,
dict
):
prefixed_list
=
[]
for
k
,
v
in
desc
.
items
():
if
isinstance
(
v
,
(
list
,
tuple
,
dict
)):
remove_prefix
(
v
,
prefix
)
if
isinstance
(
k
,
str
)
and
k
.
startswith
(
prefix
)
and
k
!=
prefix
:
prefixed_list
.
append
(
k
)
for
k
in
prefixed_list
:
desc
[
k
[
prefix_len
:]]
=
desc
.
pop
(
k
)
elif
isinstance
(
desc
,
(
list
,
tuple
)):
for
i
in
desc
:
if
isinstance
(
desc
,
(
list
,
tuple
,
dict
)):
remove_prefix
(
i
,
prefix
)
if
__name__
==
"
__main__
"
:
error_position
=
[]
format_output_yaml
=
True
...
...
@@ -91,6 +113,16 @@ if __name__=="__main__":
if
"
vnfd:vnfd-catalog
"
in
data
or
"
vnfd-catalog
"
in
data
:
descriptor
=
"
VNF
"
# Check if mgmt-interface is defined:
remove_prefix
(
data
,
"
vnfd:
"
)
vnfd_descriptor
=
data
[
"
vnfd-catalog
"
]
vnfd_list
=
vnfd_descriptor
[
"
vnfd
"
]
mgmt_iface
=
False
for
vnfd
in
vnfd_list
:
if
vnfd
.
get
(
"
mgmt-interface
"
):
mgmt_iface
=
True
if
not
mgmt_iface
:
raise
KeyError
(
"'
mgmt-iface
'
is a mandatory field and it is not defined
"
)
myvnfd
=
vnfd_catalog
.
vnfd
()
pybindJSONDecoder
.
load_ietf_json
(
data
,
None
,
None
,
obj
=
myvnfd
)
elif
"
nsd:nsd-catalog
"
in
data
or
"
nsd-catalog
"
in
data
:
...
...
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