Skip to content

Commit 46c143a

Browse files
Merge pull request #81 from openvstorage/merge_0.3_in_master
Merge 0.3 in master
2 parents 0f6561f + 9683f10 commit 46c143a

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

helpers/storagedriver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@
1717
from ovs.dal.hybrids.storagedriver import StorageDriver
1818
from ovs.dal.lists.storagedriverlist import StorageDriverList
1919
from ovs.extensions.generic.configuration import Configuration
20-
from ovs.extensions.generic.sshclient import SSHClient
2120
from ovs.extensions.generic.logger import Logger
21+
from ovs.extensions.generic.sshclient import SSHClient
2222
from ovs.extensions.services.servicefactory import ServiceFactory
2323

2424

setup/storagedriver.py

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Copyright (C) 2016 iNuron NV
2+
#
3+
# This file is part of Open vStorage Open Source Edition (OSE),
4+
# as available from
5+
#
6+
# http://www.openvstorage.org and
7+
# http://www.openvstorage.com.
8+
#
9+
# This file is free software; you can redistribute it and/or modify it
10+
# under the terms of the GNU Affero General Public License v3 (GNU AGPLv3)
11+
# as published by the Free Software Foundation, in version 3 as it comes
12+
# in the LICENSE.txt file of the Open vStorage OSE distribution.
13+
#
14+
# Open vStorage is distributed in the hope that it will be useful,
15+
# but WITHOUT ANY WARRANTY of any kind.
16+
from ovs.lib.helpers.toolbox import Toolbox
17+
from ovs.extensions.generic.logger import Logger
18+
from ..helpers.storagedriver import StoragedriverHelper
19+
from ..helpers.vpool import VPoolHelper
20+
21+
22+
class StoragedriverSetup(object):
23+
LOGGER = Logger('setup-ci_storagedriver_setup')
24+
25+
# These will be all possible settings for the StorageDriver. Messing them up is their own responsibility (they should not bypass the API by default!!)
26+
STORAGEDRIVER_PARAMS = {"volume_manager": (dict, None, False),
27+
"backend_connection_manager": (dict, None, False)}
28+
29+
@staticmethod
30+
def change_config(vpool_name, vpool_details, storagerouter_ip, *args, **kwargs):
31+
32+
# Settings volumedriver
33+
storagedriver_config = vpool_details.get('storagedriver')
34+
if storagedriver_config is not None:
35+
Toolbox.verify_required_params(StoragedriverSetup.STORAGEDRIVER_PARAMS, storagedriver_config)
36+
StoragedriverSetup.LOGGER.info('Updating volumedriver configuration of vPool `{0}` on storagerouter `{1}`.'.format(vpool_name, storagerouter_ip))
37+
vpool = VPoolHelper.get_vpool_by_name(vpool_name)
38+
storagedriver = [sd for sd in vpool.storagedrivers if sd.storagerouter.ip == storagerouter_ip][0]
39+
if not storagedriver:
40+
error_msg = 'Unable to find the storagedriver of vPool {0} on storagerouter {1}'.format(vpool_name, storagerouter_ip)
41+
raise RuntimeError(error_msg)
42+
StoragedriverHelper.change_config(storagedriver, storagedriver_config)
43+
vpool.invalidate_dynamics('configuration')
44+
StoragedriverSetup.LOGGER.info('Updating volumedriver config of vPool `{0}` should have succeeded on storagerouter `{1}`'.format(vpool_name, storagerouter_ip))

0 commit comments

Comments
 (0)