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
1a821c90
authored
Apr 04, 2019
by
Chif Gergő
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Start openstack implementation
parent
1247484a
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
0 deletions
+30
-0
interface-openstack/client_interface/vm/instance.py
+4
-0
interface-openstack/openstack_implementation/servers/__init__.py
+0
-0
interface-openstack/openstack_implementation/servers/instance.py
+26
-0
No files found.
interface-openstack/client_interface/vm/instance.py
View file @
1a821c90
...
@@ -4,6 +4,7 @@ It should be implemented for using other providers e. g. OpenStack
...
@@ -4,6 +4,7 @@ It should be implemented for using other providers e. g. OpenStack
"""
"""
class
InstanceInterface
:
class
InstanceInterface
:
def
create_vm
(
self
,
name
,
resource
):
def
create_vm
(
self
,
name
,
resource
):
...
@@ -42,6 +43,9 @@ class InstanceInterface:
...
@@ -42,6 +43,9 @@ class InstanceInterface:
def
destroy_vm
(
self
):
def
destroy_vm
(
self
):
pass
pass
def
migrate_vm
(
self
):
pass
def
get_status
(
self
):
def
get_status
(
self
):
pass
pass
...
...
interface-openstack/openstack_implementation/servers/__init__.py
0 → 100644
View file @
1a821c90
interface-openstack/openstack_implementation/servers/instance.py
0 → 100644
View file @
1a821c90
from
..client_interface.vm.instance
import
InstanceInterface
import
openstack
class
OSInstanceInterface
(
InstanceInterface
):
def
__init__
(
self
,
cloud
):
super
()
.
__init__
(
self
)
self
.
openstack
=
openstack
.
connect
(
cloud
)
def
create_vm_from_template
(
self
,
name
,
resource
,
template
):
flavor
=
self
.
openstack
.
compute
.
find_flavor
(
name
)
if
not
flavor
:
flavor
=
self
.
openstack
.
compute
.
Flavor
(
nam
=
name
,
ram
=
resource
.
ram
,
vcpus
=
resource
.
cpu
)
image
=
self
.
openstack
.
compute
.
find_image
(
template
)
if
not
image
:
raise
ValueError
(
"The template not found"
)
new_server
=
self
.
openstack
.
compute
.
create_server
(
name
=
name
,
flavorRef
=
flavor
.
id
,
imageRef
=
image
.
id
)
new_server
=
conn
.
compute
.
wait_for_server
(
new_server
)
return
new_server
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