Commit 0f9c85a8 by Chif Gergő

Inherit connection class

parent 10f3194e
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.image.image_manager import ImageManager
from interface_openstack.interface.image.image import Image
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackImageManager(ImageManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackImageManager(ImageManager, OpenStackConnection):
@staticmethod
def os_image_to_rc_image(os_image) -> Image:
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.network.FloatingIP import floating_ip
from interface_openstack.interface.network.FloatingIPManager import floating_ip_manager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackFloatingIPManager(FloatingIPManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackFloatingIPManager(FloatingIPManager, OpenStackConnection):
@staticmethod
def os_floating_ip_to_rc_floating_ip(os_floating_ip) -> FloatingIP:
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.network.Network import network
from interface_openstack.interface.network.NetworkManager import network_manager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackNetworkManager(NetworkManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackNetworkManager(NetworkManager, OpenStackConnection):
@staticmethod
def os_network_to_rc_network(os_network) -> Network:
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.network.Port import port
from interface_openstack.interface.network.PortManager import port_manager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackPortManager(PortManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackPortManager(PortManager, OpenStackConnection):
@staticmethod
def os_port_to_rc_port(os_port):
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.network.Router import router
from interface_openstack.interface.network.RouterManager import router_manager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackRouterManager(RouterManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackRouterManager(RouterManager, OpenStackConnection):
@staticmethod
def os_router_to_rc_router(os_router) -> Router:
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.network.Subnet import subnet
from interface_openstack.interface.network.SubnetManager import subnet_manager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackSubnetManager(SubnetManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackSubnetManager(SubnetManager, OpenStackConnection):
@staticmethod
def os_subnet_to_rc_subnet(os_subnet):
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.storage.snapshot import Snapshot
from interface_openstack.interface.storage.snapshot_manager import SnapshotManager
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackSnapshotManager(SnapshotManager):
def __init__(self, os) -> None:
super().__init__()
self.openstack = os
class OpenstackSnapshotManager(SnapshotManager, OpenStackConnection):
@staticmethod
def os_snapshot_to_rc_snapshot(os_snapshot) -> Snapshot:
......
......@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from interface_openstack.interface.storage.storage_manager import StorageManager
from interface_openstack.interface.storage.volume import Volume
from interface_openstack.implementation.utils.connection import OpenStackConnection
class OpenstackStorageManager(StorageManager):
def __init__(self, openstack) -> None:
super().__init__()
self.openstack = openstack
class OpenstackStorageManager(StorageManager, OpenStackConnection):
@staticmethod
def os_volume_to_rc_volume(os_volume) -> Volume:
......
from interface.vm.instance import InstanceInterface
from interface.vm.resources import Instance, Flavor
from interface_openstack.interface.vm.instance import InstanceInterface
from interface_openstack.interface.vm.resources import Instance, Flavor
from openstack.exceptions import SDKException
from novaclient import client
import logging
from keystoneauth1.identity import v3
from keystoneauth1 import session
auth = v3.Password(auth_url="http://10.34.0.113/identity/v3",
username="admin",
password="64c7ee341d03844c548c",
user_domain_id='default',
project_id="2db5309f541c4466bc80bc534cf579d7")
sess = session.Session(auth=auth)
from interface_openstack.implementation.utils.connection import OpenStackConnection
def openstackError(func):
......@@ -31,11 +22,7 @@ def openstackError(func):
return wrap_OpenStackError
class OSVirtualMachineManager(InstanceInterface):
def __init__(self, cloud):
super().__init__()
self.openstack = cloud
class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
@openstackError
def _get_openstack_server(self, name_or_id):
......@@ -52,7 +39,8 @@ class OSVirtualMachineManager(InstanceInterface):
b_device = block_dev_map.__dict__
devices.append(b_device)
flavor = self.get_flavor(flavor)
new_server = self.openstack.compute.create_server(name=name,
new_server = self.openstack.compute.create_server(
name=name,
flavorRef=flavor.id,
networks=networks,
block_device_mapping=devices
......@@ -61,7 +49,8 @@ class OSVirtualMachineManager(InstanceInterface):
@openstackError
def create_vm_from_template(self, name, image, flavor, networks):
return self.create_multiple_vm_from_template(name, image, flavor, networks, 1)
return self.create_multiple_vm_from_template(name, image, flavor,
networks, 1)
@openstackError
def create_multiple_vm_from_template(self, name, image, flavor, networks,
......@@ -176,7 +165,7 @@ class OSVirtualMachineManager(InstanceInterface):
metadata)
def get_vnc_console(self, server_id):
with client.Client("2", session=sess) as nova:
with client.Client("2", session=self.client_session) as nova:
if server_id:
instance = nova.servers.get(server_id)
return instance.get_vnc_console("novnc")
......
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