Commit 6f9ca0f7 by edems

upgrade

parent 40c5aa3d
......@@ -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)
......
# 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('\tPublic: %s' % public_network)
print('\tInner: %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('\tPublic: %s' % public_subnet)
print('\tInner: %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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment