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
0f9c85a8
authored
Jul 09, 2019
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Inherit connection class
parent
10f3194e
Show whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
25 additions
and
68 deletions
+25
-68
implementation/image/openstack_image_manager.py
+2
-6
implementation/network/openstack_floating_ip_manager.py
+2
-6
implementation/network/openstack_network_manager.py
+2
-6
implementation/network/openstack_port_manager.py
+2
-6
implementation/network/openstack_router_manager.py
+2
-6
implementation/network/openstack_subnet_manager.py
+2
-6
implementation/storage/openstack_snapshot_manager.py
+2
-6
implementation/storage/openstack_storage_manager.py
+2
-6
implementation/vm/instance.py
+9
-20
No files found.
implementation/image/openstack_image_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.image.image_manager
import
ImageManager
from
interface_openstack.interface.image.image_manager
import
ImageManager
from
interface_openstack.interface.image.image
import
Image
from
interface_openstack.interface.image.image
import
Image
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackImageManager
(
ImageManager
):
class
OpenstackImageManager
(
ImageManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_image_to_rc_image
(
os_image
)
->
Image
:
def
os_image_to_rc_image
(
os_image
)
->
Image
:
...
...
implementation/network/openstack_floating_ip_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.network.FloatingIP
import
floating_ip
from
interface_openstack.interface.network.FloatingIP
import
floating_ip
from
interface_openstack.interface.network.FloatingIPManager
import
floating_ip_manager
from
interface_openstack.interface.network.FloatingIPManager
import
floating_ip_manager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackFloatingIPManager
(
FloatingIPManager
):
class
OpenstackFloatingIPManager
(
FloatingIPManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_floating_ip_to_rc_floating_ip
(
os_floating_ip
)
->
FloatingIP
:
def
os_floating_ip_to_rc_floating_ip
(
os_floating_ip
)
->
FloatingIP
:
...
...
implementation/network/openstack_network_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.network.Network
import
network
from
interface_openstack.interface.network.Network
import
network
from
interface_openstack.interface.network.NetworkManager
import
network_manager
from
interface_openstack.interface.network.NetworkManager
import
network_manager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackNetworkManager
(
NetworkManager
):
class
OpenstackNetworkManager
(
NetworkManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_network_to_rc_network
(
os_network
)
->
Network
:
def
os_network_to_rc_network
(
os_network
)
->
Network
:
...
...
implementation/network/openstack_port_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.network.Port
import
port
from
interface_openstack.interface.network.Port
import
port
from
interface_openstack.interface.network.PortManager
import
port_manager
from
interface_openstack.interface.network.PortManager
import
port_manager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackPortManager
(
PortManager
):
class
OpenstackPortManager
(
PortManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_port_to_rc_port
(
os_port
):
def
os_port_to_rc_port
(
os_port
):
...
...
implementation/network/openstack_router_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.network.Router
import
router
from
interface_openstack.interface.network.Router
import
router
from
interface_openstack.interface.network.RouterManager
import
router_manager
from
interface_openstack.interface.network.RouterManager
import
router_manager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackRouterManager
(
RouterManager
):
class
OpenstackRouterManager
(
RouterManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_router_to_rc_router
(
os_router
)
->
Router
:
def
os_router_to_rc_router
(
os_router
)
->
Router
:
...
...
implementation/network/openstack_subnet_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.network.Subnet
import
subnet
from
interface_openstack.interface.network.Subnet
import
subnet
from
interface_openstack.interface.network.SubnetManager
import
subnet_manager
from
interface_openstack.interface.network.SubnetManager
import
subnet_manager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackSubnetManager
(
SubnetManager
):
class
OpenstackSubnetManager
(
SubnetManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_subnet_to_rc_subnet
(
os_subnet
):
def
os_subnet_to_rc_subnet
(
os_subnet
):
...
...
implementation/storage/openstack_snapshot_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.storage.snapshot
import
Snapshot
from
interface_openstack.interface.storage.snapshot
import
Snapshot
from
interface_openstack.interface.storage.snapshot_manager
import
SnapshotManager
from
interface_openstack.interface.storage.snapshot_manager
import
SnapshotManager
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackSnapshotManager
(
SnapshotManager
):
class
OpenstackSnapshotManager
(
SnapshotManager
,
OpenStackConnection
):
def
__init__
(
self
,
os
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
os
@staticmethod
@staticmethod
def
os_snapshot_to_rc_snapshot
(
os_snapshot
)
->
Snapshot
:
def
os_snapshot_to_rc_snapshot
(
os_snapshot
)
->
Snapshot
:
...
...
implementation/storage/openstack_storage_manager.py
View file @
0f9c85a8
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
...
@@ -4,14 +4,10 @@ from openstack.exceptions import ResourceNotFound
from
interface_openstack.interface.storage.storage_manager
import
StorageManager
from
interface_openstack.interface.storage.storage_manager
import
StorageManager
from
interface_openstack.interface.storage.volume
import
Volume
from
interface_openstack.interface.storage.volume
import
Volume
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
class
OpenstackStorageManager
(
StorageManager
):
class
OpenstackStorageManager
(
StorageManager
,
OpenStackConnection
):
def
__init__
(
self
,
openstack
)
->
None
:
super
()
.
__init__
()
self
.
openstack
=
openstack
@staticmethod
@staticmethod
def
os_volume_to_rc_volume
(
os_volume
)
->
Volume
:
def
os_volume_to_rc_volume
(
os_volume
)
->
Volume
:
...
...
implementation/vm/instance.py
View file @
0f9c85a8
from
interface.vm.instance
import
InstanceInterface
from
interface
_openstack.interface
.vm.instance
import
InstanceInterface
from
interface.vm.resources
import
Instance
,
Flavor
from
interface
_openstack.interface
.vm.resources
import
Instance
,
Flavor
from
openstack.exceptions
import
SDKException
from
openstack.exceptions
import
SDKException
from
novaclient
import
client
from
novaclient
import
client
import
logging
import
logging
from
keystoneauth1.identity
import
v3
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
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
)
def
openstackError
(
func
):
def
openstackError
(
func
):
...
@@ -31,11 +22,7 @@ def openstackError(func):
...
@@ -31,11 +22,7 @@ def openstackError(func):
return
wrap_OpenStackError
return
wrap_OpenStackError
class
OSVirtualMachineManager
(
InstanceInterface
):
class
OSVirtualMachineManager
(
InstanceInterface
,
OpenStackConnection
):
def
__init__
(
self
,
cloud
):
super
()
.
__init__
()
self
.
openstack
=
cloud
@openstackError
@openstackError
def
_get_openstack_server
(
self
,
name_or_id
):
def
_get_openstack_server
(
self
,
name_or_id
):
...
@@ -52,7 +39,8 @@ class OSVirtualMachineManager(InstanceInterface):
...
@@ -52,7 +39,8 @@ class OSVirtualMachineManager(InstanceInterface):
b_device
=
block_dev_map
.
__dict__
b_device
=
block_dev_map
.
__dict__
devices
.
append
(
b_device
)
devices
.
append
(
b_device
)
flavor
=
self
.
get_flavor
(
flavor
)
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
,
flavorRef
=
flavor
.
id
,
networks
=
networks
,
networks
=
networks
,
block_device_mapping
=
devices
block_device_mapping
=
devices
...
@@ -61,7 +49,8 @@ class OSVirtualMachineManager(InstanceInterface):
...
@@ -61,7 +49,8 @@ class OSVirtualMachineManager(InstanceInterface):
@openstackError
@openstackError
def
create_vm_from_template
(
self
,
name
,
image
,
flavor
,
networks
):
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
@openstackError
def
create_multiple_vm_from_template
(
self
,
name
,
image
,
flavor
,
networks
,
def
create_multiple_vm_from_template
(
self
,
name
,
image
,
flavor
,
networks
,
...
@@ -176,7 +165,7 @@ class OSVirtualMachineManager(InstanceInterface):
...
@@ -176,7 +165,7 @@ class OSVirtualMachineManager(InstanceInterface):
metadata
)
metadata
)
def
get_vnc_console
(
self
,
server_id
):
def
get_vnc_console
(
self
,
server_id
):
with
client
.
Client
(
"2"
,
session
=
se
ss
)
as
nova
:
with
client
.
Client
(
"2"
,
session
=
se
lf
.
client_session
)
as
nova
:
if
server_id
:
if
server_id
:
instance
=
nova
.
servers
.
get
(
server_id
)
instance
=
nova
.
servers
.
get
(
server_id
)
return
instance
.
get_vnc_console
(
"novnc"
)
return
instance
.
get_vnc_console
(
"novnc"
)
...
...
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