本文整理汇总了Python中ovs.dal.lists.storagedriverlist.StorageDriverList.get_storagedrivers_by_storagerouter方法的典型用法代码示例。如果您正苦于以下问题:Python StorageDriverList.get_storagedrivers_by_storagerouter方法的具体用法?Python StorageDriverList.get_storagedrivers_by_storagerouter怎么用?Python StorageDriverList.get_storagedrivers_by_storagerouter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ovs.dal.lists.storagedriverlist.StorageDriverList
的用法示例。
在下文中一共展示了StorageDriverList.get_storagedrivers_by_storagerouter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: post_upgrade
# 需要导入模块: from ovs.dal.lists.storagedriverlist import StorageDriverList [as 别名]
# 或者: from ovs.dal.lists.storagedriverlist.StorageDriverList import get_storagedrivers_by_storagerouter [as 别名]
def post_upgrade(client):
"""
Upgrade actions after the new packages have actually been installed
:param client: SSHClient object
:return: None
"""
# If we can reach Etcd with a valid config, and there's still an old config file present, delete it
from ovs.extensions.db.etcd.configuration import EtcdConfiguration
path = '/opt/OpenvStorage/config/ovs.json'
if EtcdConfiguration.exists('/ovs/framework/cluster_id') and client.file_exists(path):
client.file_delete(path)
# Migrate volumedriver & albaproxy configuration files
import uuid
from ovs.extensions.storageserver.storagedriver import StorageDriverConfiguration
from ovs.dal.lists.storagedriverlist import StorageDriverList
from ovs.extensions.generic.system import System
with remote(client.ip, [StorageDriverConfiguration, os, open, json, System], username='ovs') as rem:
configuration_dir = '{0}/storagedriver/storagedriver'.format(EtcdConfiguration.get('/ovs/framework/paths|cfgdir'))
host_id = rem.System.get_my_machine_id()
if rem.os.path.exists(configuration_dir):
for storagedriver in StorageDriverList.get_storagedrivers_by_storagerouter(rem.System.get_my_storagerouter().guid):
vpool = storagedriver.vpool
if storagedriver.alba_proxy is not None:
config_tree = '/ovs/vpools/{0}/proxies/{1}/config/{{0}}'.format(vpool.guid, storagedriver.alba_proxy.guid)
# ABM config
abm_config = '{0}/{1}_alba.cfg'.format(configuration_dir, vpool.name)
if rem.os.path.exists(abm_config):
with rem.open(abm_config) as config_file:
EtcdConfiguration.set(config_tree.format('abm'), config_file.read(), raw=True)
rem.os.remove(abm_config)
# Albaproxy config
alba_config = '{0}/{1}_alba.json'.format(configuration_dir, vpool.name)
if rem.os.path.exists(alba_config):
with rem.open(alba_config) as config_file:
config = rem.json.load(config_file)
del config['albamgr_cfg_file']
config['albamgr_cfg_url'] = 'etcd://127.0.0.1:2379{0}'.format(config_tree.format('abm'))
EtcdConfiguration.set(config_tree.format('main'), json.dumps(config, indent=4), raw=True)
params = {'VPOOL_NAME': vpool.name,
'VPOOL_GUID': vpool.guid,
'PROXY_ID': storagedriver.alba_proxy.guid}
alba_proxy_service = 'ovs-albaproxy_{0}'.format(vpool.name)
ServiceManager.add_service(name='ovs-albaproxy', params=params, client=client, target_name=alba_proxy_service)
rem.os.remove(alba_config)
# Volumedriver config
current_file = '{0}/{1}.json'.format(configuration_dir, vpool.name)
if rem.os.path.exists(current_file):
readcache_size = 0
with rem.open(current_file) as config_file:
config = rem.json.load(config_file)
config['distributed_transaction_log'] = {}
config['distributed_transaction_log']['dtl_transport'] = config['failovercache']['failovercache_transport']
config['distributed_transaction_log']['dtl_path'] = config['failovercache']['failovercache_path']
config['volume_manager']['dtl_throttle_usecs'] = config['volume_manager']['foc_throttle_usecs']
del config['failovercache']
del config['volume_manager']['foc_throttle_usecs']
sdc = rem.StorageDriverConfiguration('storagedriver', vpool.guid, storagedriver.storagedriver_id)
sdc.configuration = config
sdc.save(reload_config=False)
for mountpoint in config['content_addressed_cache']['clustercache_mount_points']:
readcache_size += int(mountpoint['size'].replace('KiB', ''))
params = {'VPOOL_MOUNTPOINT': storagedriver.mountpoint,
'HYPERVISOR_TYPE': storagedriver.storagerouter.pmachine.hvtype,
'VPOOL_NAME': vpool.name,
'CONFIG_PATH': sdc.remote_path,
'UUID': str(uuid.uuid4()),
'OVS_UID': client.run('id -u ovs').strip(),
'OVS_GID': client.run('id -g ovs').strip(),
'KILL_TIMEOUT': str(int(readcache_size / 1024.0 / 1024.0 / 6.0 + 30))}
vmware_mode = EtcdConfiguration.get('/ovs/framework/hosts/{0}/storagedriver|vmware_mode'.format(host_id))
dtl_service = 'ovs-dtl_{0}'.format(vpool.name)
ServiceManager.add_service(name='ovs-dtl', params=params, client=client, target_name=dtl_service)
if vpool.backend_type.code == 'alba':
alba_proxy_service = 'ovs-albaproxy_{0}'.format(vpool.name)
dependencies = [alba_proxy_service]
else:
dependencies = None
if vmware_mode == 'ganesha':
template_name = 'ovs-ganesha'
else:
template_name = 'ovs-volumedriver'
voldrv_service = 'ovs-volumedriver_{0}'.format(vpool.name)
ServiceManager.add_service(name=template_name, params=params, client=client, target_name=voldrv_service, additional_dependencies=dependencies)
rem.os.remove(current_file)
# Ganesha config, if available
current_file = '{0}/{1}_ganesha.conf'.format(configuration_dir, vpool.name)
if rem.os.path.exists(current_file):
sdc = rem.StorageDriverConfiguration('storagedriver', vpool.guid, storagedriver.storagedriver_id)
contents = ''
for template in ['ganesha-core', 'ganesha-export']:
contents += client.file_read('/opt/OpenvStorage/config/templates/{0}.conf'.format(template))
params = {'VPOOL_NAME': vpool.name,
'VPOOL_MOUNTPOINT': '/mnt/{0}'.format(vpool.name),
'CONFIG_PATH': sdc.remote_path,
'NFS_FILESYSTEM_ID': storagedriver.storagerouter.ip.split('.', 2)[-1]}
for key, value in params.iteritems():
contents = contents.replace('<{0}>'.format(key), value)
client.file_write(current_file, contents)