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
5d471157
authored
5 years ago
by
Bodor Máté
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change create_template to create_image
parent
c9558666
Pipeline
#781
failed with stage
in 38 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
implementation/vm/instance.py
+16
-7
interface/image/image.py
+1
-1
No files found.
implementation/vm/instance.py
View file @
5d471157
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,12 +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
):
self
.
openstack
.
compute
.
create_server_image
(
name_or_id
,
template_name
,
def
create_image
(
self
,
instance_id
,
metadata
=
None
):
image_name
=
secrets
.
token_hex
(
30
)
self
.
openstack
.
compute
.
create_server_image
(
instance_id
,
image_name
,
metadata
)
image
=
self
.
openstack
.
compute
.
find_image
(
templat
e_name
)
return
image
image
=
self
.
openstack
.
compute
.
find_image
(
imag
e_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
:
...
...
@@ -197,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
)
This diff is collapsed.
Click to expand it.
interface/image/image.py
View file @
5d471157
...
...
@@ -2,7 +2,7 @@ import json
class
Image
:
def
__init__
(
self
,
id
,
name
,
format
)
->
None
:
def
__init__
(
self
,
id
,
name
,
format
=
None
)
->
None
:
super
()
.
__init__
()
self
.
id
=
id
...
...
This diff is collapsed.
Click to expand it.
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