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
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
29 additions
and
72 deletions
+29
-72
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
+13
-24
No files found.
implementation/image/openstack_image_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/network/openstack_floating_ip_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/network/openstack_network_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/network/openstack_port_manager.py
View file @
0f9c85a8
...
...
@@ -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
):
...
...
implementation/network/openstack_router_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/network/openstack_subnet_manager.py
View file @
0f9c85a8
...
...
@@ -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
):
...
...
implementation/storage/openstack_snapshot_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/storage/openstack_storage_manager.py
View file @
0f9c85a8
...
...
@@ -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
:
...
...
implementation/vm/instance.py
View file @
0f9c85a8
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,16 +39,18 @@ 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
,
flavorRef
=
flavor
.
id
,
networks
=
networks
,
block_device_mapping
=
devices
)
new_server
=
self
.
openstack
.
compute
.
create_server
(
name
=
name
,
flavorRef
=
flavor
.
id
,
networks
=
networks
,
block_device_mapping
=
devices
)
return
self
.
convert_server_to_instance
(
new_server
)
@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
=
se
ss
)
as
nova
:
with
client
.
Client
(
"2"
,
session
=
se
lf
.
client_session
)
as
nova
:
if
server_id
:
instance
=
nova
.
servers
.
get
(
server_id
)
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