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
6a1bf009
Commit
6a1bf009
authored
3 years ago
by
Lluis Gifre Renom
Browse files
Options
Downloads
Patches
Plain Diff
Common tools:
- added helper methods to object_factory
parent
ee6f34de
No related branches found
No related tags found
1 merge request
!54
Release 2.0.0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/common/tools/object_factory/EndPoint.py
+19
-1
19 additions, 1 deletion
src/common/tools/object_factory/EndPoint.py
src/common/tools/object_factory/Link.py
+5
-0
5 additions, 0 deletions
src/common/tools/object_factory/Link.py
with
24 additions
and
1 deletion
src/common/tools/object_factory/EndPoint.py
+
19
−
1
View file @
6a1bf009
...
@@ -13,13 +13,21 @@
...
@@ -13,13 +13,21 @@
# limitations under the License.
# limitations under the License.
import
copy
import
copy
from
typing
import
Dict
,
List
,
Optional
from
typing
import
Dict
,
List
,
Optional
,
Tuple
def
json_endpoint_id
(
device_id
:
Dict
,
endpoint_uuid
:
str
,
topology_id
:
Optional
[
Dict
]
=
None
):
def
json_endpoint_id
(
device_id
:
Dict
,
endpoint_uuid
:
str
,
topology_id
:
Optional
[
Dict
]
=
None
):
result
=
{
'
device_id
'
:
copy
.
deepcopy
(
device_id
),
'
endpoint_uuid
'
:
{
'
uuid
'
:
endpoint_uuid
}}
result
=
{
'
device_id
'
:
copy
.
deepcopy
(
device_id
),
'
endpoint_uuid
'
:
{
'
uuid
'
:
endpoint_uuid
}}
if
topology_id
is
not
None
:
result
[
'
topology_id
'
]
=
copy
.
deepcopy
(
topology_id
)
if
topology_id
is
not
None
:
result
[
'
topology_id
'
]
=
copy
.
deepcopy
(
topology_id
)
return
result
return
result
def
json_endpoint_ids
(
device_id
:
Dict
,
endpoint_descriptors
:
List
[
Tuple
[
str
,
str
,
List
[
int
]]],
topology_id
:
Optional
[
Dict
]
=
None
):
return
[
json_endpoint_id
(
device_id
,
endpoint_uuid
,
topology_id
=
topology_id
)
for
endpoint_uuid
,
_
,
_
in
endpoint_descriptors
]
def
json_endpoint
(
def
json_endpoint
(
device_id
:
Dict
,
endpoint_uuid
:
str
,
endpoint_type
:
str
,
topology_id
:
Optional
[
Dict
]
=
None
,
device_id
:
Dict
,
endpoint_uuid
:
str
,
endpoint_type
:
str
,
topology_id
:
Optional
[
Dict
]
=
None
,
kpi_sample_types
:
List
[
int
]
=
[]
kpi_sample_types
:
List
[
int
]
=
[]
...
@@ -31,3 +39,13 @@ def json_endpoint(
...
@@ -31,3 +39,13 @@ def json_endpoint(
}
}
if
len
(
kpi_sample_types
)
>
0
:
result
[
'
kpi_sample_types
'
]
=
copy
.
deepcopy
(
kpi_sample_types
)
if
len
(
kpi_sample_types
)
>
0
:
result
[
'
kpi_sample_types
'
]
=
copy
.
deepcopy
(
kpi_sample_types
)
return
result
return
result
def
json_endpoints
(
device_id
:
Dict
,
endpoint_descriptors
:
List
[
Tuple
[
str
,
str
,
List
[
int
]]],
topology_id
:
Optional
[
Dict
]
=
None
):
return
[
json_endpoint
(
device_id
,
endpoint_uuid
,
endpoint_type
,
topology_id
=
topology_id
,
kpi_sample_types
=
endpoint_sample_types
)
for
endpoint_uuid
,
endpoint_type
,
endpoint_sample_types
in
endpoint_descriptors
]
This diff is collapsed.
Click to expand it.
src/common/tools/object_factory/Link.py
+
5
−
0
View file @
6a1bf009
...
@@ -15,6 +15,11 @@
...
@@ -15,6 +15,11 @@
import
copy
import
copy
from
typing
import
Dict
,
List
from
typing
import
Dict
,
List
def
get_link_uuid
(
a_device_id
:
Dict
,
a_endpoint_id
:
Dict
,
z_device_id
:
Dict
,
z_endpoint_id
:
Dict
)
->
str
:
return
'
{:s}/{:s}=={:s}/{:s}
'
.
format
(
a_device_id
[
'
device_uuid
'
][
'
uuid
'
],
a_endpoint_id
[
'
endpoint_uuid
'
][
'
uuid
'
],
z_device_id
[
'
device_uuid
'
][
'
uuid
'
],
z_endpoint_id
[
'
endpoint_uuid
'
][
'
uuid
'
])
def
json_link_id
(
link_uuid
:
str
):
def
json_link_id
(
link_uuid
:
str
):
return
{
'
link_uuid
'
:
{
'
uuid
'
:
link_uuid
}}
return
{
'
link_uuid
'
:
{
'
uuid
'
:
link_uuid
}}
...
...
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