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
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
implementation/vm/instance.py
+12
-10
main.py
+9
-3
No files found.
implementation/vm/instance.py
View file @
0be24b70
...
...
@@ -44,10 +44,10 @@ class OSVirtualMachineManager(InstanceInterface):
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
)
flavorRef
=
flavor
.
id
,
networks
=
networks
,
block_device_mapping
=
devices
)
return
self
.
convert_server_to_instance
(
new_server
)
@openstackError
...
...
@@ -97,7 +97,7 @@ class OSVirtualMachineManager(InstanceInterface):
flavors
=
[]
for
flavor
in
self
.
openstack
.
compute
.
flavors
():
flavors
.
append
(
Flavor
(
flavor
.
name
,
flavor
.
id
,
flavor
.
ram
,
flavor
.
vcpus
,
flavor
.
disk
))
flavor
.
vcpus
,
flavor
.
disk
))
return
flavors
@openstackError
...
...
@@ -190,8 +190,11 @@ class OSVirtualMachineManager(InstanceInterface):
def
attach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
self
.
openstack
.
compute
.
create_volume_attachment
(
server_id
,
{
"volumeId"
:
volume_id
,
"device"
:
device
# server = interface.openstack.compute.get_server("8e94c162-f8ed-4872-b9e5-50bf33040b5b")
#
# print(server) "device": device
})
@openstackError
def
detach_volume
(
self
,
server_id
,
volume_id
,
device
=
None
):
self
.
openstack
.
compute
.
delete_volume_attachment
(
server_id
,
...
...
@@ -199,17 +202,16 @@ class OSVirtualMachineManager(InstanceInterface):
"device"
:
device
})
def
convert_server_to_instance
(
self
,
server
):
if
not
server
.
image
:
image_id
=
None
else
:
image_id
=
server
.
image
.
id
image_id
=
server
.
image
_
id
return
Instance
(
id
=
server
.
id
,
flavor
=
server
.
flavor
.
id
,
flavor
=
server
.
flavor
_
id
,
name
=
server
.
name
,
image_id
=
image_id
,
disks
=
server
.
volumes
,
disks
=
server
.
attached_
volumes
,
status
=
server
.
status
,
launched_at
=
server
.
launched_at
,
terminated_at
=
server
.
terminated_at
,
...
...
main.py
View file @
0be24b70
...
...
@@ -23,14 +23,20 @@ print('#'*40)
# interface.create_vm_from_template('new_server', resource, "cirros-0.4.0-x86_64-disk")
# 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"))
for
flavor
in
interface
.
list_flavors
():
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())
...
...
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