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
3ec07a18
authored
Apr 26, 2019
by
Adam Torok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Openstack networkmanager impl. added
parent
5ebbd560
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
53 additions
and
0 deletions
+53
-0
implementation/network/OpenstackNetworkManager.py
+53
-0
No files found.
implementation/network/OpenstackNetworkManager.py
0 → 100644
View file @
3ec07a18
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface.network.Network
import
Network
from
interface.network.NetworkManager
import
NetworkManager
class
OpenstackNetworkManager
(
NetworkManager
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
def
os_network_to_rc_network
(
os_network
):
return
Network
(
os_network
.
id
,
os_network
.
name
,
os_network
.
status
,
os_network
.
subnet_ids
,
os_network
.
created_at
)
def
create
(
self
)
->
Network
:
os_network
=
self
.
openstack
.
network
.
create_network
()
return
self
.
os_network_to_rc_network
(
os_network
)
def
get
(
self
,
id
)
->
Optional
[
Network
]:
try
:
os_network
=
self
.
openstack
.
network
.
get_network
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_network_to_rc_network
(
os_network
)
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
network
.
delete_network
(
id
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
)
->
[]:
networks
=
[]
for
os_network
in
self
.
openstack
.
network
.
networks
():
networks
.
append
(
self
.
os_network_to_rc_network
(
os_network
))
return
networks
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