Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
controller
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor 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
TFS
controller
Commits
2fedcee6
Commit
2fedcee6
authored
2 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
WebUI
- added support for json-formatted custom config rules
parent
2ad35901
No related branches found
No related tags found
2 merge requests
!54
Release 2.0.0
,
!11
Merge Hackfest material into Develop
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/webui/service/main/DescriptorTools.py
+12
-2
12 additions, 2 deletions
src/webui/service/main/DescriptorTools.py
src/webui/service/main/routes.py
+18
-1
18 additions, 1 deletion
src/webui/service/main/routes.py
with
30 additions
and
3 deletions
src/webui/service/main/DescriptorTools.py
+
12
−
2
View file @
2fedcee6
...
@@ -12,8 +12,8 @@
...
@@ -12,8 +12,8 @@
# See the License for the specific language governing permissions and
# See the License for the specific language governing permissions and
# limitations under the License.
# limitations under the License.
import
copy
import
copy
,
json
from
typing
import
Dict
,
List
,
Optional
,
Tuple
from
typing
import
Dict
,
List
,
Optional
,
Tuple
,
Union
def
get_descriptors_add_contexts
(
contexts
:
List
[
Dict
])
->
List
[
Dict
]:
def
get_descriptors_add_contexts
(
contexts
:
List
[
Dict
])
->
List
[
Dict
]:
contexts_add
=
copy
.
deepcopy
(
contexts
)
contexts_add
=
copy
.
deepcopy
(
contexts
)
...
@@ -49,6 +49,16 @@ def get_descriptors_add_slices(slices : List[Dict]) -> List[Dict]:
...
@@ -49,6 +49,16 @@ def get_descriptors_add_slices(slices : List[Dict]) -> List[Dict]:
slices_add
.
append
(
slice_copy
)
slices_add
.
append
(
slice_copy
)
return
slices_add
return
slices_add
TypeResourceValue
=
Union
[
str
,
int
,
bool
,
float
,
dict
,
list
]
def
format_custom_config_rules
(
config_rules
:
List
[
Dict
])
->
List
[
Dict
]:
for
config_rule
in
config_rules
:
if
'
custom
'
not
in
config_rule
:
continue
custom_resource_value
:
TypeResourceValue
=
config_rule
[
'
custom
'
][
'
resource_value
'
]
if
isinstance
(
custom_resource_value
,
(
dict
,
list
)):
custom_resource_value
=
json
.
dumps
(
custom_resource_value
,
sort_keys
=
True
,
indent
=
0
)
config_rule
[
'
custom
'
][
'
resource_value
'
]
=
custom_resource_value
return
config_rules
def
split_devices_by_rules
(
devices
:
List
[
Dict
])
->
Tuple
[
List
[
Dict
],
List
[
Dict
]]:
def
split_devices_by_rules
(
devices
:
List
[
Dict
])
->
Tuple
[
List
[
Dict
],
List
[
Dict
]]:
devices_add
=
[]
devices_add
=
[]
devices_config
=
[]
devices_config
=
[]
...
...
This diff is collapsed.
Click to expand it.
src/webui/service/main/routes.py
+
18
−
1
View file @
2fedcee6
...
@@ -21,7 +21,7 @@ from device.client.DeviceClient import DeviceClient
...
@@ -21,7 +21,7 @@ from device.client.DeviceClient import DeviceClient
from
service.client.ServiceClient
import
ServiceClient
from
service.client.ServiceClient
import
ServiceClient
from
slice.client.SliceClient
import
SliceClient
from
slice.client.SliceClient
import
SliceClient
from
webui.service.main.DescriptorTools
import
(
from
webui.service.main.DescriptorTools
import
(
get_descriptors_add_contexts
,
get_descriptors_add_services
,
get_descriptors_add_slices
,
format_custom_config_rules
,
get_descriptors_add_contexts
,
get_descriptors_add_services
,
get_descriptors_add_slices
,
get_descriptors_add_topologies
,
split_devices_by_rules
)
get_descriptors_add_topologies
,
split_devices_by_rules
)
from
webui.service.main.forms
import
ContextForm
,
DescriptorForm
from
webui.service.main.forms
import
ContextForm
,
DescriptorForm
...
@@ -84,6 +84,23 @@ def process_descriptors(descriptors):
...
@@ -84,6 +84,23 @@ def process_descriptors(descriptors):
slices
=
descriptors
.
get
(
'
slices
'
,
[])
slices
=
descriptors
.
get
(
'
slices
'
,
[])
connections
=
descriptors
.
get
(
'
connections
'
,
[])
connections
=
descriptors
.
get
(
'
connections
'
,
[])
# Format CustomConfigRules in Devices, Services and Slices provided in JSON format
for
device
in
devices
:
config_rules
=
device
.
get
(
'
device_config
'
,
{}).
get
(
'
config_rules
'
,
[])
config_rules
=
format_custom_config_rules
(
config_rules
)
device
[
'
device_config
'
][
'
config_rules
'
]
=
config_rules
for
service
in
services
:
config_rules
=
service
.
get
(
'
service_config
'
,
{}).
get
(
'
config_rules
'
,
[])
config_rules
=
format_custom_config_rules
(
config_rules
)
service
[
'
service_config
'
][
'
config_rules
'
]
=
config_rules
for
slice
in
slices
:
config_rules
=
slice
.
get
(
'
slice_config
'
,
{}).
get
(
'
config_rules
'
,
[])
config_rules
=
format_custom_config_rules
(
config_rules
)
slice
[
'
slice_config
'
][
'
config_rules
'
]
=
config_rules
# Context and Topology require to create the entity first, and add devices, links, services, slices, etc. in a
# Context and Topology require to create the entity first, and add devices, links, services, slices, etc. in a
# second stage.
# second stage.
contexts_add
=
get_descriptors_add_contexts
(
contexts
)
contexts_add
=
get_descriptors_add_contexts
(
contexts
)
...
...
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