Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
Resource Manager
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
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
Resource Manager
Commits
1bd62a19
Commit
1bd62a19
authored
2 years ago
by
JORGE SASIAIN
Browse files
Options
Downloads
Patches
Plain Diff
Add speed column to ports table
parent
e7543d1d
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
resource_management/hardware/router.py
+4
-4
4 additions, 4 deletions
resource_management/hardware/router.py
resource_management/migrations/versions/cdbd931a47d4_add_speed_column_to_ports_table.py
+28
-0
28 additions, 0 deletions
.../versions/cdbd931a47d4_add_speed_column_to_ports_table.py
with
32 additions
and
4 deletions
resource_management/hardware/router.py
+
4
−
4
View file @
1bd62a19
...
...
@@ -3,13 +3,12 @@ import json
from
jnpr.junos
import
Device
from
jnpr.junos.exception
import
ConnectError
,
ConnectTimeoutError
from
jnpr.junos.op.fpc
import
FpcHwTable
from
jnpr.junos.op.fpc
import
FpcInfoTable
from
jnpr.junos.op.ethport
import
EthPortTable
from
jnpr.junos.op.inventory
import
ModuleTable
from
jnpr.junos.op.phyport
import
PhyPortTable
logger
=
logging
.
getLogger
(
__name__
)
PORT_SPEEDS
=
{
"
ge
"
:
1
,
"
xe
"
:
10
,
"
et
"
:
40
}
nodes
=
[
{
"
_id
"
:
1
,
"
fqdn
"
:
"
core1.spa.private
"
},
{
"
_id
"
:
2
,
"
fqdn
"
:
"
core2.spa.private
"
},
...
...
@@ -48,7 +47,8 @@ def load_router():
_ports
.
get
()
for
key
,
value
in
_ports
.
items
():
line_card_position
=
int
(
key
[
3
])
ports
.
append
(
{
"
name
"
:
key
[
-
3
:],
"
speed
"
:
key
[:
2
],
"
<line_card_position>
"
:
line_card_position
}
)
speed
=
PORT_SPEEDS
[
key
[:
2
]]
ports
.
append
(
{
"
name
"
:
key
[
-
3
:],
"
speed
"
:
speed
,
"
<line_card_position>
"
:
line_card_position
}
)
except
Exception
as
err
:
print
(
"
Error reading hardware information for {1}: {0}
"
.
format
(
err
,
devname
))
...
...
This diff is collapsed.
Click to expand it.
resource_management/migrations/versions/cdbd931a47d4_add_speed_column_to_ports_table.py
0 → 100644
+
28
−
0
View file @
1bd62a19
"""
add speed column to ports table
Revision ID: cdbd931a47d4
Revises: 8901d3bca270
Create Date: 2022-10-24 08:02:14.845868
"""
from
alembic
import
op
import
sqlalchemy
as
sa
# revision identifiers, used by Alembic.
revision
=
'
cdbd931a47d4
'
down_revision
=
'
8901d3bca270
'
branch_labels
=
None
depends_on
=
None
def
upgrade
()
->
None
:
with
op
.
batch_alter_table
(
'
ports
'
)
as
batch_op
:
batch_op
.
add_column
(
Column
(
'
speed
'
,
sa
.
Integer
,
nullable
=
False
)),
insert_after
=
'
name
'
)
def
downgrade
()
->
None
:
op
.
drop_column
(
'
ports
'
,
'
speed
'
)
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