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
0806c772
Commit
0806c772
authored
1 year ago
by
Simone Spinelli
Browse files
Options
Downloads
Patches
Plain Diff
Device FQDN is calculated - SNMP location needs rework
parent
1a5b365b
No related branches found
Branches containing commit
No related tags found
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/device/create_device.py
+64
-61
64 additions, 61 deletions
gso/workflows/device/create_device.py
with
64 additions
and
61 deletions
gso/workflows/device/create_device.py
+
64
−
61
View file @
0806c772
...
...
@@ -48,7 +48,7 @@ def initial_input_form_generator(product_name: str) -> FormGenerator:
title
=
product_name
device_site
:
site_selector
()
fqdn
:
str
hostname
:
str
ts_address
:
ipaddress
.
IPv4Address
ts_port
:
int
device_vendor
:
device_pb
.
DeviceVendor
...
...
@@ -88,19 +88,23 @@ def get_info_from_ipam(subscription: device.DeviceInactive) -> State:
@step
(
"
Initialize subscription
"
)
def
initialize_subscription
(
subscription
:
device
.
DeviceInactive
,
fqdn
:
str
,
hostname
:
str
,
ts_address
:
ipaddress
.
IPv4Address
,
ts_port
:
str
,
device_vendor
:
device_pb
.
DeviceVendor
,
device_site
:
str
,
device_role
:
device_pb
.
DeviceRole
)
->
State
:
subscription
.
device
.
device_fqdn
=
fqdn
subscription
.
device
.
device_ts_address
=
str
(
ts_address
)
subscription
.
device
.
device_ts_port
=
str
(
ts_port
)
subscription
.
device
.
device_vendor
=
device_vendor
subscription
.
device
.
device_site
\
=
Site
.
from_subscription
(
device_site
[
0
]).
site
fqdn
=
str
(
hostname
+
"
.
"
+
subscription
.
device
.
device_site
.
site_name
.
lower
()
+
"
.
"
+
subscription
.
device
.
device_site
.
site_country_code
.
lower
()
+
"
.geant.net
"
)
subscription
.
device
.
device_fqdn
=
fqdn
subscription
.
device
.
device_role
=
device_role
subscription
.
description
=
f
"
Device
{
fqdn
}
type
\
(
{
subscription
.
device_type
}
)
"
...
...
@@ -108,45 +112,43 @@ def initialize_subscription(
subscription
,
SubscriptionLifecycle
.
PROVISIONING
)
return
{
"
subscription
"
:
subscription
}
return
{
"
subscription
"
:
subscription
,
"
fqdn
"
:
fqdn
}
@step
(
"
Provision device [DRY RUN]
"
)
def
provision_device_dry
(
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
subscription
:
device
.
DeviceProvisioning
)
->
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()
import
ansible_runner
snmp_location
=
subscription
.
device
.
device_site
.
site_country_code
r
=
ansible_runner
.
run
(
private_data_dir
=
"
/opt/geant-gap-ansible
"
,
playbook
=
"
base_config.yaml
"
,
inventory
=
subscription
.
device
.
device_fqdn
,
extravars
=
{
"
lo_ipv4_address
"
:
str
(
subscription
.
device
.
device_lo_ipv4_address
),
"
lo_ipv6_address
"
:
str
(
subscription
.
device
.
device_lo_ipv6_address
),
"
lo_iso_address
"
:
subscription
.
device
.
device_lo_iso_address
,
"
snmp_location
"
:
snmp_location
,
"
si_ipv4_network
"
:
str
(
subscription
.
device
.
device_si_ipv4_network
),
"
lt_ipv4_network
"
:
str
(
subscription
.
device
.
device_ias_lt_ipv4_network
),
"
lt_ipv6_network
"
:
str
(
subscription
.
device
.
device_ias_lt_ipv6_network
),
"
site_country_code
"
:
subscription
.
device
.
device_site
.
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}
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
}
#
return {"return_code": 0}
@inputstep
(
"
Confirm step
"
,
assignee
=
"
CHANGES
"
)
...
...
@@ -161,39 +163,40 @@ def confirm_step() -> FormGenerator:
@step
(
"
Provision device [FOR REAL]
"
)
def
provision_device_real
(
subscription
:
device
.
DeviceProvisioning
,
fqdn
:
str
,
ts_address
:
str
,
ts_port
:
str
subscription
:
device
.
DeviceProvisioning
)
->
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}
import
ansible_runner
snmp_location
=
subscription
.
device
.
device_site
.
site_country_code
r
=
ansible_runner
.
run
(
private_data_dir
=
"
/opt/geant-gap-ansible
"
,
playbook
=
"
base_config.yaml
"
,
inventory
=
subscription
.
device
.
device_fqdn
,
extravars
=
{
"
lo_ipv4_address
"
:
str
(
subscription
.
device
.
device_lo_ipv4_address
),
"
lo_ipv6_address
"
:
str
(
subscription
.
device
.
device_lo_ipv6_address
),
"
lo_iso_address
"
:
subscription
.
device
.
device_lo_iso_address
,
"
snmp_location
"
:
snmp_location
,
"
si_ipv4_network
"
:
str
(
subscription
.
device
.
device_si_ipv4_network
),
"
lt_ipv4_network
"
:
str
(
subscription
.
device
.
device_ias_lt_ipv4_network
),
"
lt_ipv6_network
"
:
str
(
subscription
.
device
.
device_ias_lt_ipv6_network
),
"
site_country_code
"
:
subscription
.
device
.
device_site
.
site_country_code
,
"
verb
"
:
"
deploy
"
,
"
dryrun
"
:
"
False
"
,
"
commit_comment
"
:
"
Deployed with WFO and Ansible
"
,
},
)
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
)
#
TODO: figure out what to return when we are suspending & waiting
#
for the provisioning-proxy to call back
return
{
"
return_code
"
:
0
}
#
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}
@workflow
(
"
Create Device
"
,
...
...
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