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
0be24b70
authored
May 13, 2019
by
Belákovics Ádám
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix conversion error
parent
e1cdc179
Pipeline
#713
failed with stage
in 38 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
8 deletions
+16
-8
implementation/vm/instance.py
+7
-5
main.py
+9
-3
No files found.
implementation/vm/instance.py
View file @
0be24b70
...
@@ -190,8 +190,11 @@ class OSVirtualMachineManager(InstanceInterface):
...
@@ -190,8 +190,11 @@ class OSVirtualMachineManager(InstanceInterface):
def
attach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
def
attach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
self
.
openstack
.
compute
.
create_volume_attachment
(
server_id
,
self
.
openstack
.
compute
.
create_volume_attachment
(
server_id
,
{
"volumeId"
:
volume_id
,
{
"volumeId"
:
volume_id
,
"device"
:
device
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server) "device": device
})
})
@openstackError
@openstackError
def
detach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
def
detach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
self
.
openstack
.
compute
.
delete_volume_attachment
(
server_id
,
self
.
openstack
.
compute
.
delete_volume_attachment
(
server_id
,
...
@@ -199,17 +202,16 @@ class OSVirtualMachineManager(InstanceInterface):
...
@@ -199,17 +202,16 @@ class OSVirtualMachineManager(InstanceInterface):
"device"
:
device
"device"
:
device
})
})
def
convert_server_to_instance
(
self
,
server
):
def
convert_server_to_instance
(
self
,
server
):
if
not
server
.
image
:
if
not
server
.
image
:
image_id
=
None
image_id
=
None
else
:
else
:
image_id
=
server
.
image
.
id
image_id
=
server
.
image
_
id
return
Instance
(
id
=
server
.
id
,
return
Instance
(
id
=
server
.
id
,
flavor
=
server
.
flavor
.
id
,
flavor
=
server
.
flavor
_
id
,
name
=
server
.
name
,
name
=
server
.
name
,
image_id
=
image_id
,
image_id
=
image_id
,
disks
=
server
.
volumes
,
disks
=
server
.
attached_
volumes
,
status
=
server
.
status
,
status
=
server
.
status
,
launched_at
=
server
.
launched_at
,
launched_at
=
server
.
launched_at
,
terminated_at
=
server
.
terminated_at
,
terminated_at
=
server
.
terminated_at
,
...
...
main.py
View file @
0be24b70
...
@@ -23,14 +23,20 @@ print('#'*40)
...
@@ -23,14 +23,20 @@ print('#'*40)
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# interface.stop_vm('a6bc504f-a422-4492-b429-e5dad2df12f4')
# interface.stop_vm('a6bc504f-a422-4492-b429-e5dad2df12f4')
# server = interface.get_vm("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server)
# print(interface.delete_flavor("flavorTest"))
# print(interface.delete_flavor("flavorTest"))
for
flavor
in
interface
.
list_flavors
():
for
flavor
in
interface
.
list_flavors
():
print
(
flavor
.
JSON
())
print
(
flavor
.
JSON
())
# print(interface.create_base_vm("BaseTest", "2", networks, block_dev_map))
for
vm
in
interface
.
list_all_vm
():
print
(
vm
.
JSON
())
print
(
"*"
*
50
)
print
(
interface
.
create_base_vm
(
"BaseTest"
,
"2"
,
networks
,
block_dev_map
)
.
JSON
())
# print(interface.convert_server_to_instance(server).JSON())
# print(interface.convert_server_to_instance(server).JSON())
...
...
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