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

Merge 0.3 in master #81

Merged
merged 8 commits into from
Feb 8, 2018
2 changes: 1 addition & 1 deletion helpers/storagedriver.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
from ovs.dal.hybrids.storagedriver import StorageDriver
from ovs.dal.lists.storagedriverlist import StorageDriverList
from ovs.extensions.generic.configuration import Configuration
from ovs.extensions.generic.sshclient import SSHClient
from ovs.extensions.generic.logger import Logger
from ovs.extensions.generic.sshclient import SSHClient
from ovs.extensions.services.servicefactory import ServiceFactory


Expand Down
44 changes: 44 additions & 0 deletions setup/storagedriver.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# 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.lib.helpers.toolbox import Toolbox
from ovs.extensions.generic.logger import Logger
from ..helpers.storagedriver import StoragedriverHelper
from ..helpers.vpool import VPoolHelper


class StoragedriverSetup(object):
LOGGER = Logger('setup-ci_storagedriver_setup')

# These will be all possible settings for the StorageDriver. Messing them up is their own responsibility (they should not bypass the API by default!!)
STORAGEDRIVER_PARAMS = {"volume_manager": (dict, None, False),
"backend_connection_manager": (dict, None, False)}

@staticmethod
def change_config(vpool_name, vpool_details, storagerouter_ip, *args, **kwargs):

# Settings volumedriver
storagedriver_config = vpool_details.get('storagedriver')
if storagedriver_config is not None:
Toolbox.verify_required_params(StoragedriverSetup.STORAGEDRIVER_PARAMS, storagedriver_config)
StoragedriverSetup.LOGGER.info('Updating volumedriver configuration of vPool `{0}` on storagerouter `{1}`.'.format(vpool_name, storagerouter_ip))
vpool = VPoolHelper.get_vpool_by_name(vpool_name)
storagedriver = [sd for sd in vpool.storagedrivers if sd.storagerouter.ip == storagerouter_ip][0]
if not storagedriver:
error_msg = 'Unable to find the storagedriver of vPool {0} on storagerouter {1}'.format(vpool_name, storagerouter_ip)
raise RuntimeError(error_msg)
StoragedriverHelper.change_config(storagedriver, storagedriver_config)
vpool.invalidate_dynamics('configuration')
StoragedriverSetup.LOGGER.info('Updating volumedriver config of vPool `{0}` should have succeeded on storagerouter `{1}`'.format(vpool_name, storagerouter_ip))