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
7e0ec004
Verified
Commit
7e0ec004
authored
5 months ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
Update LSO interactions in switch creation workflow
parent
309c7a8a
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!300
Feature/lan switch interconnect
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
gso/workflows/switch/create_switch.py
+30
-35
30 additions, 35 deletions
gso/workflows/switch/create_switch.py
with
30 additions
and
35 deletions
gso/workflows/switch/create_switch.py
+
30
−
35
View file @
7e0ec004
...
...
@@ -17,13 +17,14 @@ from gso.products.product_blocks.switch import SwitchModel
from
gso.products.product_types.site
import
Site
from
gso.products.product_types.switch
import
SwitchInactive
from
gso.services
import
infoblox
from
gso.services.lso_client
import
execute_playbook
,
lso_interaction
from
gso.services.lso_client
import
LSOState
,
lso_interaction
from
gso.services.partners
import
get_partner_by_name
from
gso.services.sharepoint
import
SharePointClient
from
gso.settings
import
load_oss_params
from
gso.utils.helpers
import
active_site_selector
,
generate_fqdn
from
gso.utils.shared_enums
import
PortNumber
,
Vendor
from
gso.utils.types
import
TTNumber
from
gso.utils.shared_enums
import
Vendor
from
gso.utils.types.ip_address
import
PortNumber
from
gso.utils.types.tt_number
import
TTNumber
from
gso.utils.workflow_steps
import
prompt_sharepoint_checklist_url
...
...
@@ -34,6 +35,7 @@ def _initial_input_form_generator(product_name: str) -> FormGenerator:
model_config
=
ConfigDict
(
title
=
product_name
)
tt_number
:
TTNumber
partner
:
ReadOnlyField
(
"
GEANT
"
,
default_type
=
str
)
# type: ignore[valid-type]
switch_site
:
active_site_selector
()
# type: ignore[valid-type]
hostname
:
str
ts_port
:
PortNumber
...
...
@@ -63,7 +65,7 @@ def create_subscription(product: UUIDstr, partner: str) -> State:
"""
Create a new subscription object.
"""
subscription
=
SwitchInactive
.
from_product_id
(
product
,
get_partner_by_name
(
partner
)[
"
partner_id
"
])
return
{
"
subscription
"
:
subscription
}
return
{
"
subscription
"
:
subscription
,
"
subscription_id
"
:
subscription
.
subscription_id
}
@step
(
"
Initialize subscription
"
)
...
...
@@ -76,11 +78,11 @@ def initialize_subscription(
hostname
:
str
,
)
->
State
:
"""
Initialize the subscription with user input.
"""
subscription
.
switch
.
switch_
site
=
Site
.
from_subscription
(
switch_site
).
site
subscription
.
switch
.
switch_
fqdn
=
generate_fqdn
(
hostname
,
subscription
.
switch
.
switch_
site
.
site_name
,
subscription
.
switch
.
switch_
site
.
site_country_code
subscription
.
switch
.
site
=
Site
.
from_subscription
(
switch_site
).
site
subscription
.
switch
.
fqdn
=
generate_fqdn
(
hostname
,
subscription
.
switch
.
site
.
site_name
,
subscription
.
switch
.
site
.
site_country_code
)
subscription
.
switch
.
switch_
ts_port
=
ts_port
subscription
.
switch
.
ts_port
=
ts_port
subscription
.
switch
.
switch_vendor
=
vendor
subscription
.
switch
.
switch_model
=
model
...
...
@@ -88,10 +90,8 @@ def initialize_subscription(
@step
(
"
[DRY RUN] Deploy base config
"
)
def
deploy_base_config_dry
(
subscription
:
dict
,
tt_number
:
str
,
callback_route
:
str
,
process_id
:
UUIDstr
)
->
Non
e
:
def
deploy_base_config_dry
(
subscription
:
dict
,
tt_number
:
str
,
process_id
:
UUIDstr
)
->
LSOStat
e
:
"""
Perform a dry run of provisioning base config on a switch.
"""
inventory
=
subscription
[
"
switch
"
][
"
switch_fqdn
"
]
extra_vars
=
{
"
subscription_json
"
:
subscription
,
"
dry_run
"
:
True
,
...
...
@@ -99,19 +99,16 @@ def deploy_base_config_dry(subscription: dict, tt_number: str, callback_route: s
"
commit_comment
"
:
f
"
GSO_PROCESS_ID:
{
process_id
}
- TT_NUMBER:
{
tt_number
}
- Deploy base config
"
,
}
execute_playbook
(
playbook_name
=
"
switch_base_config.yaml
"
,
callback_route
=
callback_route
,
inventory
=
inventory
,
extra_vars
=
extra_vars
,
)
return
{
"
playbook_name
"
:
"
switch_base_config.yaml
"
,
"
extra_vars
"
:
extra_vars
,
"
inventory
"
:
{
"
all
"
:
{
"
hosts
"
:
{
subscription
[
"
switch
"
][
"
fqdn
"
]:
None
}}},
}
@step
(
"
[FOR REAL] Deploy base config
"
)
def
deploy_base_config_real
(
subscription
:
dict
,
tt_number
:
str
,
callback_route
:
str
,
process_id
:
UUIDstr
)
->
Non
e
:
def
deploy_base_config_real
(
subscription
:
dict
,
tt_number
:
str
,
process_id
:
UUIDstr
)
->
LSOStat
e
:
"""
Provision base config on a switch.
"""
inventory
=
subscription
[
"
switch
"
][
"
switch_fqdn
"
]
extra_vars
=
{
"
subscription_json
"
:
subscription
,
"
dry_run
"
:
False
,
...
...
@@ -119,12 +116,11 @@ def deploy_base_config_real(subscription: dict, tt_number: str, callback_route:
"
commit_comment
"
:
f
"
GSO_PROCESS_ID:
{
process_id
}
- TT_NUMBER:
{
tt_number
}
- Deploy base config
"
,
}
execute_playbook
(
playbook_name
=
"
switch_base_config.yaml
"
,
callback_route
=
callback_route
,
inventory
=
inventory
,
extra_vars
=
extra_vars
,
)
return
{
"
playbook_name
"
:
"
switch_base_config.yaml
"
,
"
extra_vars
"
:
extra_vars
,
"
inventory
"
:
{
"
all
"
:
{
"
hosts
"
:
{
subscription
[
"
switch
"
][
"
fqdn
"
]:
None
}}},
}
@inputstep
(
"
Prompt for console login
"
,
assignee
=
Assignee
.
SYSTEM
)
...
...
@@ -161,27 +157,26 @@ def create_netbox_device() -> State:
@step
(
"
Run post-deployment checks
"
)
def
run_post_deploy_checks
(
subscription
:
dict
,
callback_route
:
str
)
->
Non
e
:
def
run_post_deploy_checks
(
subscription
:
dict
)
->
LSOStat
e
:
"""
Workflow step for running checks after installing base config.
"""
execute_playbook
(
playbook_name
=
"
switch_base_config_checks.yaml
"
,
callback_route
=
callback_route
,
inventory
=
subscription
[
"
switch
"
][
"
switch_fqdn
"
],
extra_vars
=
{
"
subscription_json
"
:
subscription
},
)
return
{
"
playbook_name
"
:
"
switch_base_config_checks.yaml
"
,
"
extra_vars
"
:
{
"
subscription_json
"
:
subscription
},
"
inventory
"
:
{
"
all
"
:
{
"
hosts
"
:
{
subscription
[
"
switch
"
][
"
fqdn
"
]:
None
}}},
}
@step
(
"
Create a new SharePoint checklist
"
)
def
create_new_sharepoint_checklist
(
subscription
:
SwitchInactive
,
tt_number
:
str
,
process_id
:
UUIDstr
)
->
State
:
"""
Create a new checklist in SharePoint for approving this router.
"""
if
not
subscription
.
switch
.
switch_
fqdn
:
if
not
subscription
.
switch
.
fqdn
:
msg
=
"
Switch is missing an FQDN.
"
raise
ProcessFailureError
(
msg
,
details
=
subscription
.
subscription_id
)
new_list_item_url
=
SharePointClient
().
add_list_item
(
list_name
=
"
switch
"
,
fields
=
{
"
Title
"
:
subscription
.
switch
.
switch_
fqdn
,
"
Title
"
:
subscription
.
switch
.
fqdn
,
"
TT_NUMBER
"
:
tt_number
,
"
GAP_PROCESS_URL
"
:
f
"
{
load_oss_params
().
GENERAL
.
public_hostname
}
/workflows/
{
process_id
}
"
,
},
...
...
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