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
6f9ca0f7
authored
May 13, 2019
by
edems
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upgrade
parent
40c5aa3d
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletions
+49
-1
implementation/network/OpenstackRouterManager.py
+10
-1
main.py
+39
-0
No files found.
implementation/network/OpenstackRouterManager.py
View file @
6f9ca0f7
...
...
@@ -14,7 +14,7 @@ class OpenstackRouterManager(RouterManager):
self
.
openstack
=
openstack
@staticmethod
def
os_router_to_rc_router
(
os_router
):
def
os_router_to_rc_router
(
os_router
)
->
Router
:
return
Router
(
os_router
.
id
,
os_router
.
name
,
...
...
@@ -43,6 +43,15 @@ class OpenstackRouterManager(RouterManager):
return
self
.
os_router_to_rc_router
(
os_router
)
def
add_interface
(
self
,
id
,
subnet_id
):
try
:
os_router
=
self
.
openstack
.
network
.
add_interface_to_router
(
id
,
subnet_id
)
except
ResourceNotFound
:
return
None
print
(
os_router
)
return
self
.
os_router_to_rc_router
(
os_router
)
def
delete
(
self
,
id
)
->
bool
:
try
:
self
.
openstack
.
network
.
delete_router
(
id
)
...
...
main.py
View file @
6f9ca0f7
# This file is for testing the openstack api access
import
openstack
from
implementation.network.OpenstackNetworkManager
import
OpenstackNetworkManager
from
implementation.network.OpenstackRouterManager
import
OpenstackRouterManager
from
implementation.network.OpenstackSubnetManager
import
OpenstackSubnetManager
os
=
openstack
.
connect
(
cloud
=
'openstack'
)
router_manager
=
OpenstackRouterManager
(
os
)
network_manager
=
OpenstackNetworkManager
(
os
)
subnet_manager
=
OpenstackSubnetManager
(
os
)
#router = router_manager.create()
router
=
router_manager
.
get
(
'3ee87bcd-b1b5-4e14-86a1-ce691bd3e5a2'
)
print
(
'Router:'
)
print
(
'
\t
%
s'
%
router
)
#network = network_manager.create()
public_network
=
network_manager
.
get
(
'3b349c93-8b2c-4abd-b8ce-22b7db4cca98'
)
inner_network
=
network_manager
.
get
(
'ac15d5e2-f32e-4ea3-9fa5-345d3e147aa5'
)
print
(
'Network:'
)
print
(
'
\t
Public:
%
s'
%
public_network
)
print
(
'
\t
Inner:
%
s'
%
inner_network
)
#subnet = subnet_manager.create(network.id, 4, '10.34.0.0/16')
public_subnet
=
subnet_manager
.
get
(
'8a7e05f8-6358-48f7-9104-990d350425a0'
)
inner_subnet
=
subnet_manager
.
get
(
'b7650962-4323-475c-9ee6-08d64e2c8577'
)
print
(
'Subnet:'
)
print
(
'
\t
Public:
%
s'
%
public_subnet
)
print
(
'
\t
Inner:
%
s'
%
inner_subnet
)
#print(router_manager.add_interface(router.id, subnet.id))
#print(router_manager.add_interface(router.id, public_subnet.id))
\ No newline at end of file
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