-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #92 from openvstorage/0.3.x_new_testrail_api
Refactor Testrail Api
- Loading branch information
Showing
60 changed files
with
2,580 additions
and
1,005 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
# Copyright (C) 2016 iNuron NV | ||
# | ||
# This file is part of Open vStorage Open Source Edition (OSE), | ||
# as available from | ||
# | ||
# http://www.openvstorage.org and | ||
# http://www.openvstorage.com. | ||
# | ||
# This file is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License v3 (GNU AGPLv3) | ||
# as published by the Free Software Foundation, in version 3 as it comes | ||
# in the LICENSE.txt file of the Open vStorage OSE distribution. | ||
# | ||
# Open vStorage is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY of any kind. | ||
import json | ||
from ci.api_lib.helpers.api import OVSClient | ||
|
||
|
||
class CIConstants(object): | ||
""" | ||
Collection of multiple constants and constant related instances | ||
""" | ||
|
||
CONFIG_LOC = "/opt/OpenvStorage/ci/config/setup.json" | ||
TEST_SCENARIO_LOC = "/opt/OpenvStorage/ci/scenarios/" | ||
TESTRAIL_LOC = "/opt/OpenvStorage/ci/config/testrail.json" | ||
|
||
with open(CONFIG_LOC, 'r') as JSON_CONFIG: | ||
SETUP_CFG = json.load(JSON_CONFIG) | ||
|
||
HYPERVISOR_INFO = SETUP_CFG['ci'].get('hypervisor') | ||
DOMAIN_INFO = SETUP_CFG['setup']['domains'] | ||
BACKEND_INFO = SETUP_CFG['setup']['backends'] | ||
STORAGEROUTER_INFO = SETUP_CFG['setup']['storagerouters'] | ||
|
||
class classproperty(property): | ||
def __get__(self, cls, owner): | ||
return classmethod(self.fget).__get__(None, owner)() | ||
|
||
@classproperty | ||
def api(cls): | ||
return OVSClient(cls.SETUP_CFG['ci']['grid_ip'], | ||
cls.SETUP_CFG['ci']['user']['api']['username'], | ||
cls.SETUP_CFG['ci']['user']['api']['password'], | ||
) | ||
|
||
@classmethod | ||
def get_vpool_names(cls): | ||
names = [] | ||
for sr_ip, items in cls.STORAGEROUTER_INFO.iteritems(): | ||
vpools = items.get('vpools') | ||
for vp_name, vp_info in vpools.iteritems(): | ||
if vp_name not in names: | ||
names.append(vp_name) | ||
return names |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,4 +86,4 @@ class ImageConvertError(Exception): | |
""" | ||
Raised when an object was queries that doesn't exist | ||
""" | ||
pass | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# Copyright (C) 2016 iNuron NV | ||
# | ||
# This file is part of Open vStorage Open Source Edition (OSE), | ||
# as available from | ||
# | ||
# http://www.openvstorage.org and | ||
# http://www.openvstorage.com. | ||
# | ||
# This file is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Affero General Public License v3 (GNU AGPLv3) | ||
# as published by the Free Software Foundation, in version 3 as it comes | ||
# in the LICENSE.txt file of the Open vStorage OSE distribution. | ||
# | ||
# Open vStorage is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY of any kind. | ||
|
||
from ovs.dal.hybrids.service import Service | ||
from ovs.extensions.generic.sshclient import SSHClient | ||
from ovs.extensions.services.servicefactory import ServiceFactory | ||
from ovs.log.log_handler import LogHandler | ||
from ..helpers.ci_constants import CIConstants | ||
|
||
|
||
class ServiceHelper(CIConstants): | ||
""" | ||
ServiceHelper class | ||
""" | ||
|
||
LOGGER = LogHandler.get(source="setup", name="ci_service_setup") | ||
SERVICE_MANAGER = ServiceFactory.get_manager() | ||
|
||
@staticmethod | ||
def get_service(guid): | ||
""" | ||
Fetch Service object by service guid | ||
:param guid: guid of the service | ||
:return: a Service object | ||
""" | ||
return Service(guid) | ||
|
||
@staticmethod | ||
def restart_service(guid, storagerouter): | ||
""" | ||
Restart a service based on the guid located on storagerouter | ||
:param guid: guid of the service | ||
:param storagerouter: storagerouter where the service is running | ||
:type storagerouter: StorageRouter | ||
:return: | ||
""" | ||
client = SSHClient(storagerouter, username='root') | ||
service = ServiceHelper.get_service(guid) | ||
return ServiceHelper.SERVICE_MANAGER.restart_service(service.name, client=client) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.