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
97f877b6
Verified
Commit
97f877b6
authored
1 year ago
by
Karel van Klink
Browse files
Options
Downloads
Patches
Plain Diff
add modify IP trunk to pp
parent
bab2fa1b
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/services/provisioning_proxy.py
+44
-10
44 additions, 10 deletions
gso/services/provisioning_proxy.py
with
44 additions
and
10 deletions
gso/services/provisioning_proxy.py
+
44
−
10
View file @
97f877b6
import
enum
import
json
import
logging
...
...
@@ -11,13 +12,26 @@ from orchestrator.types import UUIDstr, State
from
orchestrator.utils.json
import
json_dumps
from
gso
import
settings
from
gso.products.product_types.device
import
DeviceProvisioning
from
gso.products.product_types.iptrunk
import
IptrunkProvisioning
from
gso.products.product_types.iptrunk
import
IptrunkProvisioning
,
Iptrunk
logger
=
logging
.
getLogger
(
__name__
)
def
_send_request
(
endpoint
:
str
,
parameters
:
dict
,
process_id
:
UUIDstr
):
class
CUDOperation
(
str
,
enum
.
Enum
):
"""
Enum for different C(R)UD operations that the provisioning proxy supports.
Read is not applicable, hence these become CUD and not CRUD operations.
"""
#: Creation is done with a POST request
POST
=
'
POST
'
#: Updating is done with a PUT request
PUT
=
'
PUT
'
#: Removal is done with a DELETE request
DELETE
=
'
DELETE
'
def
_send_request
(
endpoint
:
str
,
parameters
:
dict
,
process_id
:
UUIDstr
,
operation
:
CUDOperation
):
oss
=
settings
.
load_oss_params
()
pp_params
=
oss
.
PROVISIONING_PROXY
assert
pp_params
...
...
@@ -27,13 +41,19 @@ def _send_request(endpoint: str, parameters: dict, process_id: UUIDstr):
logger
.
debug
(
f
'
[provisioning proxy] provisioning for process
{
process_id
}
'
)
parameters
.
update
({
'
callback
'
:
callback_url
})
url
=
f
'
{
pp_params
.
scheme
}
://
{
pp_params
.
api_base
}
/api/
{
endpoint
}
'
request
=
None
post_request
=
requests
.
post
(
f
'
{
pp_params
.
scheme
}
://
{
pp_params
.
api_base
}
/api/
{
endpoint
}
'
,
json
=
parameters
)
if
operation
==
CUDOperation
.
POST
:
request
=
requests
.
post
(
url
,
json
=
parameters
)
elif
operation
==
CUDOperation
.
PUT
:
request
=
requests
.
put
(
url
,
json
=
parameters
)
elif
operation
==
CUDOperation
.
DELETE
:
request
=
requests
.
delete
(
url
,
json
=
parameters
)
if
post_
request
.
status_code
!=
200
:
raise
AssertionError
(
post_
request
.
text
)
if
request
.
status_code
!=
200
:
raise
AssertionError
(
request
.
text
)
def
provision_device
(
...
...
@@ -45,7 +65,7 @@ def provision_device(
'
subscription
'
:
json
.
loads
(
json_dumps
(
subscription
))
}
_send_request
(
'
device
'
,
parameters
,
process_id
)
_send_request
(
'
device
'
,
parameters
,
process_id
,
CUDOperation
.
POST
)
def
provision_ip_trunk
(
subscription
:
IptrunkProvisioning
,
...
...
@@ -58,7 +78,21 @@ def provision_ip_trunk(subscription: IptrunkProvisioning,
'
object
'
:
''
# FIXME
}
_send_request
(
'
ip_trunk
'
,
parameters
,
process_id
)
_send_request
(
'
ip_trunk
'
,
parameters
,
process_id
,
CUDOperation
.
POST
)
def
modify_ip_trunk
(
old_subscription
:
Iptrunk
,
new_subscription
:
Iptrunk
,
process_id
:
UUIDstr
,
dry_run
:
bool
=
True
):
parameters
=
{
'
dry_run
'
:
dry_run
,
'
old_subscription
'
:
old_subscription
,
'
subscription
'
:
new_subscription
# FIXME missing parameters
}
_send_request
(
'
ip_trunk
'
,
parameters
,
process_id
,
CUDOperation
.
PUT
)
@inputstep
(
'
Await provisioning proxy results
'
,
assignee
=
Assignee
(
'
SYSTEM
'
))
...
...
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