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
A prog2-höz tartozó friss repo anyagok itt elérhetőek:
https://git.iit.bme.hu/
Commit
5ebbd560
authored
Apr 26, 2019
by
Adam Torok
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Openstack subnetmanager impl. added
parent
cd55b09d
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
60 additions
and
0 deletions
+60
-0
implementation/network/OpenstackSubnetManager.py
+60
-0
No files found.
implementation/network/OpenstackSubnetManager.py
0 → 100644
View file @
5ebbd560
from
typing
import
Optional
from
openstack.exceptions
import
ResourceNotFound
from
interface.network.Subnet
import
Subnet
from
interface.network.SubnetManager
import
SubnetManager
class
OpenstackSubnetManager
(
SubnetManager
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
def
os_subnet_to_rc_subnet
(
os_subnet
):
return
Subnet
(
os_subnet
.
id
,
os_subnet
.
network_id
,
os_subnet
.
name
,
os_subnet
.
cidr
,
os_subnet
.
ip_version
,
os_subnet
.
gateway_ip
,
os_subnet
.
is_dhcp_enabled
,
os_subnet
.
created_at
)
def
create
(
self
,
network_id
,
ip_version
,
cidr
)
->
Subnet
:
os_subnet
=
self
.
openstack
.
network
.
create_subnet
(
network_id
=
network_id
,
ip_version
=
ip_version
,
cidr
=
cidr
)
return
self
.
os_subnet_to_rc_subnet
(
os_subnet
)
def
get
(
self
,
id
)
->
Optional
[
Subnet
]:
try
:
os_subnet
=
self
.
openstack
.
network
.
get_subnet
(
id
)
except
ResourceNotFound
:
return
None
return
self
.
os_subnet_to_rc_subnet
(
os_subnet
)
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
network
.
delete_subnet
(
id
=
id
)
except
ResourceNotFound
:
return
False
return
True
def
list
(
self
)
->
[]:
subnets
=
[]
for
os_subnet
in
self
.
openstack
.
network
.
subnets
():
subnets
.
append
(
self
.
os_subnet_to_rc_subnet
(
os_subnet
))
return
subnets
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