Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
RECIRCLE
/
interface-openstack
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
2
Merge Requests
4
Pipelines
Wiki
Snippets
Members
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
56cede34
authored
Apr 26, 2019
by
Adam Torok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
OpenstackPortManager impl. added
parent
5f8349eb
Pipeline
#705
failed with stage
in 35 seconds
Changes
1
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
implementation/network/OpenstackPortManager.py
+55
-0
No files found.
implementation/network/OpenstackPortManager.py
0 → 100644
View file @
56cede34
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface.network.Port
import
Port
from
interface.network.PortManager
import
PortManager
class
OpenstackPortManager
(
PortManager
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
def
os_port_to_rc_port
(
os_port
):
return
Port
(
os_port
.
id
,
os_port
.
network_id
,
os_port
.
device_id
,
os_port
.
security_group_ids
,
os_port
.
name
,
os_port
.
status
,
os_port
.
created_at
)
def
create
(
self
,
network_id
)
->
Port
:
os_port
=
self
.
openstack
.
network
.
create_port
(
network_id
=
network_id
)
return
self
.
os_port_to_rc_port
(
os_port
)
def
get
(
self
,
id
)
->
Optional
[
Port
]:
try
:
os_port
=
self
.
openstack
.
network
.
get_port
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_port_to_rc_port
(
os_port
)
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
network
.
delete_port
(
id
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
)
->
[]:
ports
=
[]
for
os_port
in
self
.
openstack
.
network
.
ports
():
ports
.
append
(
self
.
os_port_to_rc_port
(
os_port
))
return
ports
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment