Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Move ocp to wrapanpi3 #381

Draft
wants to merge 9 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ inflection
miq-version>=0.1.6
oauth2client
ovirt-engine-sdk-python~=4.3
openshift==0.3.4
openshift==0.8.8
packaging
pyvmomi>=6.5.0.2017.5.post1
python-cinderclient
Expand All @@ -31,7 +31,7 @@ six
tzlocal
vspk==5.3.2
wait_for
websocket_client
websocket_client==0.56.0

# suds jurko supports python3, suds is only used on python2
suds-jurko; python_version > '3.0'
Expand Down
4 changes: 2 additions & 2 deletions wrapanapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
from .systems.scvmm import SCVMMSystem
from .systems.vcloud import VmwareCloudSystem
from .systems.virtualcenter import VMWareSystem
from .systems.container.rhopenshift import Openshift
from .systems.openshift import OpenshiftSystem

from .entities.vm import VmState

__all__ = [
'EC2System', 'GoogleCloudSystem', 'HawkularSystem',
'LenovoSystem', 'AzureSystem', 'NuageSystem', 'OpenstackSystem',
'OpenstackInfraSystem', 'RedfishSystem', 'RHEVMSystem', 'SCVMMSystem',
'VmwareCloudSystem', 'VMWareSystem', 'Openshift', 'VmState'
'VmwareCloudSystem', 'VMWareSystem', 'OpenshiftSystem', 'VmState'
]
4 changes: 3 additions & 1 deletion wrapanapi/entities/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
from .vm import Vm, VmState, VmMixin
from .instance import Instance
from .physical_container import PhysicalContainer
from .project import Project, ProjectMixin
from .stack import Stack, StackMixin
from .server import Server, ServerState

__all__ = [
'Template', 'TemplateMixin', 'Vm', 'VmState', 'VmMixin', 'Instance',
'PhysicalContainer', 'Server', 'ServerState', 'Stack', 'StackMixin'
'PhysicalContainer', 'Server', 'ServerState', 'Stack', 'StackMixin',
'Project', 'ProjectMixin'
]
85 changes: 85 additions & 0 deletions wrapanapi/entities/project.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
"""
wrapanapi.entities.project

Methods/classes pertaining to performing actions on a project
"""
import six

from abc import ABCMeta, abstractmethod

from wrapanapi.entities.base import Entity, EntityMixin
from wrapanapi.exceptions import MultipleItemsError, NotFoundError


class Project(six.with_metaclass(ABCMeta, Entity)):
"""
Represents a project on a system
"""
@abstractmethod
def get_quota(self):
"""
Deploy a VM/instance with name 'vm_name' using this template

Returns: an implementation of a BaseVM object
"""


class ProjectMixin(six.with_metaclass(ABCMeta, EntityMixin)):
"""
Defines methods a wrapanapi.systems.System that manages Projects should have
"""
@abstractmethod
def get_project(self, name, **kwargs):
"""
Get project from system with name 'name'

This should return only ONE matching entity. If multiple entities match
the criteria, a MultipleItemsError should be raised

Returns:
wrapanapi.entities.Project if it exists
Raises:
wrapanapi.exceptions.MultipleItemsError if multiple matches are found
"""

@abstractmethod
def create_project(self, name, **kwargs):
"""
Create project on system with name 'name'

Returns:
wrapanapi.entities.Project for newly created project
"""

@abstractmethod
def list_project(self, **kwargs):
"""
List projects on system

Returns:
list of wrapanapi.entities.Template
"""

@abstractmethod
def find_projects(self, name, **kwargs):
"""
Find project on system based on name or other filters in kwargs

Should return an empty list if no matches were found

Returns:
list of wrapanapi.entities.Project for matches found
"""

def does_project_exist(self, name):
"""
Checks if a project with 'name' exists on the system

If multiple projects with the same name exists, this still returns 'True'
"""
try:
return bool(self.get_project(name))
except MultipleItemsError:
return True
except NotFoundError:
return False
5 changes: 5 additions & 0 deletions wrapanapi/entities/vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,11 @@ class VmState(object):
UNKNOWN = 'VmState.UNKNOWN'
SHELVED = 'VmState.SHELVED'
SHELVED_OFFLOADED = 'VmState.SHELVED_OFFLOADED'
# Openshift Pod States
PENDING = 'VmState.PENDING'
SUCCEEDED = 'VmState.SUCCEEDED'
FAILED = 'VmState.FAILED'
UNKNOWN = 'VmState.UNKNOWN'

@classmethod
def valid_states(cls):
Expand Down
5 changes: 3 additions & 2 deletions wrapanapi/systems/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,10 @@
from .scvmm import SCVMMSystem
from .vcloud import VmwareCloudSystem
from .virtualcenter import VMWareSystem
from .openshift import OpenshiftSystem

__all__ = [
'EC2System', 'GoogleCloudSystem', 'HawkularSystem', 'LenovoSystem',
'AzureSystem', 'NuageSystem', 'OpenstackSystem', 'OpenstackInfraSystem', 'RedfishSystem',
'RHEVMSystem', 'SCVMMSystem', 'VmwareCloudSystem', 'VMWareSystem'
'AzureSystem', 'NuageSystem', 'OpenshiftSystem', 'OpenstackSystem', 'OpenstackInfraSystem',
'RedfishSystem', 'RHEVMSystem', 'SCVMMSystem', 'VmwareCloudSystem', 'VMWareSystem'
]
Loading