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
Show 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/
ENV/
env.bak/
venv.bak/
environment.sh
# Spyder project settings
.spyderproject
...
...
implementation/image/openstack_image_manager.py
View file @
f1525f93
...
...
@@ -14,7 +14,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
return
Image
(
os_image
.
id
,
os_image
.
name
,
os_image
.
disk_format
os_image
.
disk_format
,
os_image
.
size
)
def
upload_file
(
self
,
name
,
path
,
format
)
->
Image
:
...
...
@@ -34,8 +35,8 @@ class OpenstackImageManager(ImageManager, OpenStackConnection):
return
self
.
os_image_to_rc_image
(
os_image
)
def
download
(
self
,
id
):
return
self
.
openstack
.
image
.
download_image
(
i
d
)
def
download
(
self
,
id
,
path
):
return
self
.
openstack
.
image
.
download_image
(
i
mage
=
id
,
output
=
path
)
def
delete
(
self
,
id
)
->
bool
:
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
novaclient
import
client
import
logging
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
wrap_OpenStackError
(
*
args
,
**
kw
):
...
...
@@ -158,11 +160,13 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
self
.
openstack
.
compute
.
resize_server
(
instance
,
flavor
)
@openstackError
def
create_
template
(
self
,
name_or_id
,
template_name
,
metadata
=
None
):
i
nstance
=
self
.
_get_openstack_server
(
name_or_id
)
self
.
openstack
.
compute
.
create_server_image
(
instance
,
templat
e_name
,
def
create_
image
(
self
,
instance_id
,
metadata
=
None
):
i
mage_name
=
secrets
.
token_hex
(
30
)
self
.
openstack
.
compute
.
create_server_image
(
instance
_id
,
imag
e_name
,
metadata
)
image
=
self
.
openstack
.
compute
.
find_image
(
image_name
)
return
self
.
os_image_to_rc_image
(
image
)
def
get_vnc_console
(
self
,
server_id
):
with
client
.
Client
(
"2"
,
session
=
self
.
client_session
)
as
nova
:
...
...
@@ -196,3 +200,9 @@ class OSVirtualMachineManager(InstanceInterface, OpenStackConnection):
launched_at
=
server
.
launched_at
,
terminated_at
=
server
.
terminated_at
,
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
class
Image
:
def
__init__
(
self
,
id
,
name
,
f
ormat
)
->
None
:
def
__init__
(
self
,
id
,
name
,
f
ile_format
,
size
)
->
None
:
super
()
.
__init__
()
self
.
id
=
id
self
.
name
=
name
self
.
format
=
format
self
.
file_format
=
file_format
self
.
size
=
size
def
__str__
(
self
)
->
str
:
return
self
.
toJSON
()
...
...
interface/image/image_manager.py
View file @
f1525f93
class
ImageManager
:
def
__init__
(
self
)
->
None
:
super
()
.
__init__
()
def
upload_file
(
self
,
name
,
path
,
format
):
raise
NotImplementedError
...
...
@@ -11,11 +8,6 @@ class ImageManager:
def
download
(
self
,
id
):
raise
NotImplementedError
def
download_to_file
(
self
,
id
,
path
):
f
=
open
(
path
,
'wb'
)
f
.
write
(
self
.
download
(
id
))
f
.
close
()
def
delete
(
self
,
id
):
raise
NotImplementedError
...
...
interface/vm/instance.py
View file @
f1525f93
...
...
@@ -65,7 +65,7 @@ class InstanceInterface:
def
resize_vm
(
self
,
name_or_id
):
raise
NotImplementedError
def
create_
template
(
self
,
name_or_id
,
template_name
):
def
create_
image
(
self
,
instance_id
,
metadata
):
raise
NotImplementedError
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