Skip to content

Commit

Permalink
Merge pull request #81 from openvstorage/merge_0.3_in_master
Browse files Browse the repository at this point in the history
Merge 0.3 in master
  • Loading branch information
JeffreyDevloo authored Feb 8, 2018
2 parents 0f6561f + 9683f10 commit 46c143a
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 1 deletion.
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))

0 comments on commit 46c143a

Please sign in to comment.