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
f1525f93
authored
Aug 01, 2019
by
Bodor Máté
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'template_interface' into 'DEV'
Template interface See merge request
!10
parents
e01d873c
0946a05d
Pipeline
#799
failed with stage
in 38 seconds
Changes
6
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
25 additions
and
20 deletions
+25
-20
.gitignore
+1
-0
implementation/image/openstack_image_manager.py
+4
-3
implementation/vm/instance.py
+16
-6
interface/image/image.py
+3
-2
interface/image/image_manager.py
+0
-8
interface/vm/instance.py
+1
-1
No files found.
.gitignore
View file @
f1525f93
...
@@ -113,6 +113,7 @@ venv/
...
@@ -113,6 +113,7 @@ venv/
ENV/
ENV/
env.bak/
env.bak/
venv.bak/
venv.bak/
environment.sh
# Spyder project settings
# Spyder project settings
.spyderproject
.spyderproject
...
...
implementation/image/openstack_image_manager.py
View file @
f1525f93
...
@@ -14,7 +14,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
...
@@ -14,7 +14,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
return
Image
(
return
Image
(
os_image
.
id
,
os_image
.
id
,
os_image
.
name
,
os_image
.
name
,
os_image
.
disk_format
os_image
.
disk_format
,
os_image
.
size
)
)
def
upload_file
(
self
,
name
,
path
,
format
)
->
Image
:
def
upload_file
(
self
,
name
,
path
,
format
)
->
Image
:
...
@@ -34,8 +35,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
...
@@ -34,8 +35,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
return
self
.
os_image_to_rc_image
(
os_image
)
return
self
.
os_image_to_rc_image
(
os_image
)
def
download
(
self
,
id
):
def
download
(
self
,
id
,
path
):
return
self
.
openstack
.
image
.
download_image
(
i
d
)
return
self
.
openstack
.
image
.
download_image
(
i
mage
=
id
,
output
=
path
)
def
delete
(
self
,
id
)
->
bool
:
def
delete
(
self
,
id
)
->
bool
:
try
:
try
:
...
...
implementation/vm/instance.py
View file @
f1525f93
from
interface_openstack.interface.vm.instance
import
InstanceInterface
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
interface_openstack.implementation.utils.connection
import
OpenStackConnection
from
interface_openstack.implementation.utils.connection
import
OpenStackConnection
import
secrets
from
interface_openstack.interface.vm.instance
import
InstanceInterface
from
interface_openstack.interface.vm.resources
import
Instance
,
Flavor
from
interface_openstack.interface.image.image
import
Image
def
openstackError
(
func
):
def
openstackError
(
func
):
def
wrap_OpenStackError
(
*
args
,
**
kw
):
def
wrap_OpenStackError
(
*
args
,
**
kw
):
...
@@ -158,11 +160,13 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
...
@@ -158,11 +160,13 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
self
.
openstack
.
compute
.
resize_server
(
instance
,
flavor
)
self
.
openstack
.
compute
.
resize_server
(
instance
,
flavor
)
@openstackError
@openstackError
def
create_
template
(
self
,
name_or_id
,
template_name
,
metadata
=
None
):
def
create_
image
(
self
,
instance_id
,
metadata
=
None
):
i
nstance
=
self
.
_get_openstack_server
(
name_or_id
)
i
mage_name
=
secrets
.
token_hex
(
30
)
self
.
openstack
.
compute
.
create_server_image
(
instance
,
self
.
openstack
.
compute
.
create_server_image
(
instance
_id
,
templat
e_name
,
imag
e_name
,
metadata
)
metadata
)
image
=
self
.
openstack
.
compute
.
find_image
(
image_name
)
return
self
.
os_image_to_rc_image
(
image
)
def
get_vnc_console
(
self
,
server_id
):
def
get_vnc_console
(
self
,
server_id
):
with
client
.
Client
(
"2"
,
session
=
self
.
client_session
)
as
nova
:
with
client
.
Client
(
"2"
,
session
=
self
.
client_session
)
as
nova
:
...
@@ -196,3 +200,9 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
...
@@ -196,3 +200,9 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
launched_at
=
server
.
launched_at
,
launched_at
=
server
.
launched_at
,
terminated_at
=
server
.
terminated_at
,
terminated_at
=
server
.
terminated_at
,
addresses
=
server
.
addresses
)
addresses
=
server
.
addresses
)
def
os_image_to_rc_image
(
self
,
os_image
):
return
Image
(
os_image
.
id
,
os_image
.
name
)
interface/image/image.py
View file @
f1525f93
...
@@ -2,12 +2,13 @@ import json
...
@@ -2,12 +2,13 @@ import json
class
Image
:
class
Image
:
def
__init__
(
self
,
id
,
name
,
f
ormat
)
->
None
:
def
__init__
(
self
,
id
,
name
,
f
ile_format
,
size
)
->
None
:
super
()
.
__init__
()
super
()
.
__init__
()
self
.
id
=
id
self
.
id
=
id
self
.
name
=
name
self
.
name
=
name
self
.
format
=
format
self
.
file_format
=
file_format
self
.
size
=
size
def
__str__
(
self
)
->
str
:
def
__str__
(
self
)
->
str
:
return
self
.
toJSON
()
return
self
.
toJSON
()
...
...
interface/image/image_manager.py
View file @
f1525f93
class
ImageManager
:
class
ImageManager
:
def
__init__
(
self
)
->
None
:
super
()
.
__init__
()
def
upload_file
(
self
,
name
,
path
,
format
):
def
upload_file
(
self
,
name
,
path
,
format
):
raise
NotImplementedError
raise
NotImplementedError
...
@@ -11,11 +8,6 @@ class ImageManager:
...
@@ -11,11 +8,6 @@ class ImageManager:
def
download
(
self
,
id
):
def
download
(
self
,
id
):
raise
NotImplementedError
raise
NotImplementedError
def
download_to_file
(
self
,
id
,
path
):
f
=
open
(
path
,
'wb'
)
f
.
write
(
self
.
download
(
id
))
f
.
close
()
def
delete
(
self
,
id
):
def
delete
(
self
,
id
):
raise
NotImplementedError
raise
NotImplementedError
...
...
interface/vm/instance.py
View file @
f1525f93
...
@@ -65,7 +65,7 @@ class InstanceInterface:
...
@@ -65,7 +65,7 @@ class InstanceInterface:
def
resize_vm
(
self
,
name_or_id
):
def
resize_vm
(
self
,
name_or_id
):
raise
NotImplementedError
raise
NotImplementedError
def
create_
template
(
self
,
name_or_id
,
template_name
):
def
create_
image
(
self
,
instance_id
,
metadata
):
raise
NotImplementedError
raise
NotImplementedError
def
attach_volume
(
self
,
name_or_id
,
amount
):
def
attach_volume
(
self
,
name_or_id
,
amount
):
...
...
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