Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
GÉANT Service Orchestrator
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
Show more breadcrumbs
GÉANT Orchestration and Automation Team
GAP
GÉANT Service Orchestrator
Commits
bcefba8d
Commit
bcefba8d
authored
1 year ago
by
Erik Reid
Browse files
Options
Downloads
Patches
Plain Diff
use ipam service module
parent
80d54639
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!5
Device workflows
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
geant_service_orchestrator/services/ipam.py
+3
-3
3 additions, 3 deletions
geant_service_orchestrator/services/ipam.py
geant_service_orchestrator/workflows/device/create_device.py
+27
-24
27 additions, 24 deletions
geant_service_orchestrator/workflows/device/create_device.py
with
30 additions
and
27 deletions
geant_service_orchestrator/services/ipam.py
+
3
−
3
View file @
bcefba8d
...
...
@@ -23,8 +23,8 @@ def new_service_networks(
v6
=
ipaddress
.
IPv6Network
(
'
dead:beef::/120
'
))
def
new_
host
_address
(
fqdn
:
str
,
networks
:
ServiceNetworks
)
->
HostAddresses
:
def
new_
device_lo
_address
(
fqdn
:
str
,
networks
:
ServiceNetworks
)
->
HostAddresses
:
# TODO: load from ipam
return
HostAddresses
(
v4
=
ipaddress
.
IPv4Address
(
'
10.0.0.1
'
),
v6
=
ipaddress
.
IPv6Address
(
'
dead:beef
::1
'
))
v4
=
ipaddress
.
IPv4Address
(
'
10.
1
0.
1
0.1
0
'
),
v6
=
ipaddress
.
IPv6Address
(
'
fc00:798:aa:1
::1
0
'
))
This diff is collapsed.
Click to expand it.
geant_service_orchestrator/workflows/device/create_device.py
+
27
−
24
View file @
bcefba8d
# from typing import List, Optional
import
ipaddress
from
uuid
import
uuid4
# from orchestrator.db.models import ProductTable, SubscriptionTable
# from orchestrator.forms.validators import Choice, choice_list
from
orchestrator.forms
import
FormPage
from
orchestrator.targets
import
Target
from
orchestrator.workflow
import
inputstep
...
...
@@ -13,9 +11,8 @@ from orchestrator.workflow import done, init, step, workflow
from
orchestrator.workflows.steps
import
resync
,
set_status
from
orchestrator.workflows.steps
import
store_process_subscription
from
orchestrator.workflows.utils
import
wrap_create_initial_input_form
from
products.product_types.device
import
DeviceInactive
,
DeviceProvisioning
from
products.product_types.device
import
DeviceVendor
import
ipaddress
from
geant_service_orchestrator.products.product_types
import
device
from
geant_service_orchestrator.services
import
ipam
def
initial_input_form_generator
(
product_name
:
str
)
->
FormGenerator
:
...
...
@@ -26,7 +23,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
fqdn
:
str
ts_address
:
ipaddress
.
IPv4Address
ts_port
:
int
device_vendor
:
DeviceVendor
device_vendor
:
device
.
DeviceVendor
user_input
=
yield
CreateDeviceForm
...
...
@@ -35,7 +32,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
@step
(
"
Create subscription
"
)
def
create_subscription
(
product
:
UUIDstr
)
->
State
:
subscription
=
DeviceInactive
.
from_product_id
(
product
,
uuid4
())
subscription
=
device
.
DeviceInactive
.
from_product_id
(
product
,
uuid4
())
return
{
"
subscription
"
:
subscription
,
...
...
@@ -44,26 +41,32 @@ def create_subscription(product: UUIDstr) -> State:
@step
(
"
Get information from IPAM
"
)
def
get_info_from_ipam
(
subscription
:
DeviceInactive
)
->
State
:
subscription
.
device
.
lo_ipv4_address
=
"
10.10.10.10
"
subscription
.
device
.
lo_ipv6_address
=
"
fc00:798:aa:1::10
"
def
get_info_from_ipam
(
subscription
:
device
.
DeviceInactive
)
->
State
:
lo
=
ipam
.
new_device_lo_address
()
subscription
.
device
.
lo_ipv4_address
=
lo
.
v4
subscription
.
device
.
lo_ipv6_address
=
lo
.
v6
# TODO: get info about how these are to be generated
subscription
.
device
.
lo_iso_address
=
"
49.51e5.0001.0620.4009.6047.00
"
subscription
.
device
.
si_ipv4_network
=
"
192.168.0.0/31
"
subscription
.
device
.
ias_lt_ipv4_network
=
"
192.168.1.0/31
"
subscription
.
device
.
ias_lt_ipv6_network
=
"
fc00:798:1::150/126
"
return
{
"
subscription
"
:
subscription
}
@step
(
"
get information about SNMP
"
)
def
get_snmp_info
(
subscription
:
DeviceInactive
)
->
State
:
subscription
.
device
.
site_country
=
"
Spain
"
subscription
.
device
.
site_city
=
"
Barcelona
"
subscription
.
device
.
site_country_code
=
"
ES
"
subscription
.
device
.
site_latitude
=
"
41.3743
"
subscription
.
device
.
site_longitude
=
"
2.1328
"
def
get_snmp_info
(
subscription
:
device
.
DeviceInactive
)
->
State
:
country
=
'
Spain
'
city
=
'
Barcelona
'
country_code
=
'
ES
'
latitude
=
'
41.3743
'
longitude
=
'
2.1328
'
subscription
.
device
.
site_country
=
country
subscription
.
device
.
site_city
=
city
subscription
.
device
.
site_country_code
=
country_code
subscription
.
device
.
site_latitude
=
latitude
subscription
.
device
.
site_longitude
=
longitude
subscription
.
device
.
snmp_location
=
(
"
BARCELONA,SPAIN,[41.3743,2.1328]
"
# TODO: Duplicated data?
f
'
{
city
.
upper
()
}
,
{
country
.
upper
()
}
[
{
latitude
}
,
{
longitude
}
]
'
)
return
{
"
subscription
"
:
subscription
}
...
...
@@ -71,11 +74,11 @@ def get_snmp_info(subscription: DeviceInactive) -> State:
@step
(
"
Initialize subscription
"
)
def
initialize_subscription
(
subscription
:
DeviceInactive
,
subscription
:
device
.
DeviceInactive
,
fqdn
:
str
,
ts_address
:
ipaddress
.
IPv4Address
,
ts_port
:
str
,
device_vendor
:
DeviceVendor
device_vendor
:
device
.
DeviceVendor
)
->
State
:
subscription
.
device
.
fqdn
=
fqdn
subscription
.
device
.
ts_address
=
str
(
ts_address
)
...
...
@@ -83,7 +86,7 @@ def initialize_subscription(
subscription
.
device_vendor
=
device_vendor
subscription
.
description
=
f
"
Device
{
fqdn
}
type
\
(
{
subscription
.
device_type
}
)
"
subscription
=
DeviceProvisioning
.
from_other_lifecycle
(
subscription
=
device
.
DeviceProvisioning
.
from_other_lifecycle
(
subscription
,
SubscriptionLifecycle
.
PROVISIONING
)
...
...
@@ -92,7 +95,7 @@ def initialize_subscription(
@step
(
"
Provision device [DRY RUN]
"
)
def
provision_device_dry
(
subscription
:
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
)
->
State
:
import
ansible_runner
...
...
@@ -131,7 +134,7 @@ def confirm_step() -> FormGenerator:
@step
(
"
Provision device [FOR REAL]
"
)
def
provision_device_real
(
subscription
:
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
)
->
State
:
import
ansible_runner
...
...
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