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
Jira
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
a16436bf
Commit
a16436bf
authored
2 years ago
by
Simone Spinelli
Browse files
Options
Downloads
Patches
Plain Diff
Add create_site workflow
parent
11c0caf6
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!12
Add sites, and add integration of IPtrunks and routers with LSO deployment
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/workflows/site/create_site.py
+31
-141
31 additions, 141 deletions
gso/workflows/site/create_site.py
with
31 additions
and
141 deletions
gso/workflows/site/create_site.py
+
31
−
141
View file @
a16436bf
...
...
@@ -11,26 +11,32 @@ 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
gso.products.product_types
import
site
from
gso.products.product_blocks
import
site
as
site_pb
def
initial_input_form_generator
(
product_name
:
str
)
->
FormGenerator
:
class
Create
Devic
eForm
(
FormPage
):
class
Create
Sit
eForm
(
FormPage
):
class
Config
:
title
=
product_name
fqdn
:
str
ts_address
:
ipaddress
.
IPv4Address
ts_port
:
int
device_vendor
:
device
.
DeviceVendor
site_name
:
str
site_country
:
str
site_country_code
:
str
site_latitude
:
float
site_longitude
:
float
site_bgp_community_id
:
int
site_internal_id
:
int
site_tier
:
site_pb
.
SiteTier
user_input
=
yield
CreateDeviceForm
user_input
=
yield
CreateSiteForm
return
user_input
.
dict
()
@step
(
"
Create subscription
"
)
def
create_subscription
(
product
:
UUIDstr
)
->
State
:
subscription
=
device
.
Devic
eInactive
.
from_product_id
(
product
,
uuid4
())
subscription
=
site
.
Sit
eInactive
.
from_product_id
(
product
,
uuid4
())
return
{
"
subscription
"
:
subscription
,
...
...
@@ -38,54 +44,27 @@ def create_subscription(product: UUIDstr) -> State:
}
@step
(
"
Get information from IPAM
"
)
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 should be generated
subscription
.
device
.
lo_ipv4_address
=
"
10.10.10.10
"
subscription
.
device
.
lo_ipv6_address
=
"
fc00:798:10::10
"
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
:
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
=
(
f
'
{
city
.
upper
()
}
,
{
country
.
upper
()
}
[
{
latitude
}
,
{
longitude
}
]
'
)
return
{
"
subscription
"
:
subscription
}
@step
(
"
Initialize subscription
"
)
def
initialize_subscription
(
subscription
:
device
.
DeviceInactive
,
fqdn
:
str
,
ts_address
:
ipaddress
.
IPv4Address
,
ts_port
:
str
,
device_vendor
:
device
.
DeviceVendor
subscription
:
site
.
SiteInactive
,
site_name
:
str
,
site_country
:
str
,
site_country_code
:
str
,
site_latitude
:
float
,
site_longitude
:
float
,
site_bgp_community_id
:
int
,
site_internal_id
:
int
,
site_tier
:
site_pb
.
SiteTier
)
->
State
:
subscription
.
device
.
fqdn
=
fqdn
subscription
.
device
.
ts_address
=
str
(
ts_address
)
subscription
.
device
.
ts_port
=
str
(
ts_port
)
subscription
.
device_vendor
=
device_vendor
subscription
.
description
=
f
"
Device
{
fqdn
}
type
\
(
{
subscription
.
device_type
}
)
"
subscription
.
site_name
:
site_name
subscription
.
site_country
:
site_country
subscription
.
site_country_code
:
site_country_code
subscription
.
site_latitude
:
site_longitude
subscription
.
site_longitude
:
site_latitude
subscription
.
site_bgp_community_id
:
site_bgp_community_id
subscription
.
site_internal_id
:
site_internal_id
subscription
.
site_tier
:
site_tier
subscription
.
description
=
f
"
Site
{
site_name
}
"
subscription
=
device
.
DeviceProvisioning
.
from_other_lifecycle
(
subscription
,
SubscriptionLifecycle
.
PROVISIONING
)
...
...
@@ -93,90 +72,6 @@ def initialize_subscription(
return
{
"
subscription
"
:
subscription
}
@step
(
"
Provision device [DRY RUN]
"
)
def
provision_device_dry
(
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
)
->
State
:
# import ansible_runner
#
# r = ansible_runner.run(
# private_data_dir="/opt/geant-gap-ansible",
# playbook="base_config.yaml",
# inventory=subscription.device.fqdn,
# extravars={
# "lo_ipv4_address": str(subscription.device.lo_ipv4_address),
# "lo_ipv6_address": str(subscription.device.lo_ipv6_address),
# "lo_iso_address": subscription.device.lo_iso_address,
# "snmp_location": subscription.device.snmp_location,
# "si_ipv4_network": str(subscription.device.si_ipv4_network),
# "lt_ipv4_network": str(subscription.device.ias_lt_ipv4_network),
# "lt_ipv6_network": str(subscription.device.ias_lt_ipv6_network),
# "site_country_code": subscription.device.site_country_code,
# "verb": "deploy",
# },
# )
# out = r.stdout.read()
# out_splitted = out.splitlines()
# # if r.rc != 0:
# # raise ValueError("Ansible has failed")
# return {"dry_run_output": out_splitted, "return_code": r.rc}
# provisioning_proxy.provision_node(
# node_subscription_params=subscription,
# dry_run=True)
# TODO: figure out what to return when we are suspending & waiting
# for the provisioning-proxy to call back
return
{
"
return_code
"
:
0
}
@inputstep
(
"
Confirm step
"
,
assignee
=
"
CHANGES
"
)
def
confirm_step
()
->
FormGenerator
:
class
ConfirmForm
(
FormPage
):
confirm
:
Accept
user_input
=
yield
ConfirmForm
return
{
"
confirm
"
:
user_input
.
confirm
}
@step
(
"
Provision device [FOR REAL]
"
)
def
provision_device_real
(
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
)
->
State
:
# import ansible_runner
#
# r = ansible_runner.run(
# private_data_dir="/opt/geant-gap-ansible",
# playbook="base_config.yaml",
# inventory=subscription.device.fqdn,
# extravars={
# "lo_ipv4_address": str(subscription.device.lo_ipv4_address),
# "lo_ipv6_address": str(subscription.device.lo_ipv6_address),
# "lo_iso_address": subscription.device.lo_iso_address,
# "snmp_location": subscription.device.snmp_location,
# "si_ipv4_network": str(subscription.device.si_ipv4_network),
# "lt_ipv4_network": str(subscription.device.ias_lt_ipv4_network),
# "lt_ipv6_network": str(subscription.device.ias_lt_ipv6_network),
# "site_country_code": subscription.device.site_country_code,
# "verb": "deploy",
# },
# )
# out = r.stdout.read()
# out_splitted = out.splitlines()
#
# return {"real_run_output": out_splitted, "return_code": r.rc}
# provisioning_proxy.provision_node(
# node_subscription_params=subscription)
# TODO: figure out what to return when we are suspending & waiting
# for the provisioning-proxy to call back
return
{
"
return_code
"
:
0
}
@workflow
(
"
Create Device
"
,
initial_input_form
=
wrap_create_initial_input_form
(
...
...
@@ -188,12 +83,7 @@ def create_device():
init
>>
create_subscription
>>
store_process_subscription
(
Target
.
CREATE
)
>>
get_info_from_ipam
>>
get_snmp_info
>>
initialize_subscription
>>
provision_device_dry
>>
confirm_step
>>
provision_device_real
>>
set_status
(
SubscriptionLifecycle
.
ACTIVE
)
>>
resync
>>
done
...
...
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