本文整理汇总了Python中helper.Helper.safe_print方法的典型用法代码示例。如果您正苦于以下问题:Python Helper.safe_print方法的具体用法?Python Helper.safe_print怎么用?Python Helper.safe_print使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类helper.Helper
的用法示例。
在下文中一共展示了Helper.safe_print方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import safe_print [as 别名]
def __init__(self, config, mode, fuel_cluster_id, rhosp, tag,
cleanup, skip_ivs_version_check, certificate_dir,
upgrade_dir, offline_dir, sriov, dpdk):
# directory for upgrade
self.upgrade_dir = None
self.upgrade_pkgs = []
if upgrade_dir:
self.upgrade_dir = upgrade_dir
self.upgrade_pkgs = [f for f in listdir(upgrade_dir) if isfile(join(upgrade_dir, f))]
# directory for offline installation
self.offline_dir = None
self.offline_pkgs = []
if offline_dir:
self.offline_dir = offline_dir
self.offline_pkgs = [f for f in listdir(offline_dir) if isfile(join(offline_dir, f))]
# sriov for rhosp
self.sriov = sriov
# dpdk for rhosp p-only
self.dpdk = dpdk
# certificate directory
self.certificate_dir = certificate_dir
# fuel cluster id
self.fuel_cluster_id = fuel_cluster_id
# rhosp as installer
self.rhosp = rhosp
# tag, only deploy nodes with this tag
self.tag = tag
# clean up flag
self.cleanup = cleanup
self.skip_ivs_version_check = skip_ivs_version_check
# pip proxy
self.pip_proxy = config.get('pip_proxy')
# neutron_id for ml2 plugin restproxy
self.neutron_id = config.get('neutron_id')
# tenant api version
self.tenant_api_version = const.TENANT_NAME_API_VERSION
# installer pxe interface ip
self.installer_pxe_interface_ip = config.get(
'installer_pxe_interface_ip')
# install to specified nodes
self.deploy_to_specified_nodes_only = config.get(
'deploy_to_specified_nodes_only')
# flags for upgrade
self.install_ivs = True
self.install_bsnstacklib = True
self.install_all = True
# setup node directory
example_yamls = ["/usr/local/etc/bosi/config.yaml",
"/usr/etc/bosi/config.yaml"]
for example_yaml in example_yamls:
if os.path.isfile(example_yaml):
self.setup_node_dir = os.path.dirname(example_yaml)
break
# t5 or t6 mode
self.deploy_mode = const.MODE_DICT.get(mode)
if not self.deploy_mode:
self.deploy_mode = const.T5
# flags for l3 agent
self.deploy_l3_agent = False
if self.deploy_mode == const.T5 and not fuel_cluster_id:
self.deploy_l3_agent = True
# flags for dhcp and metadata agent
self.deploy_dhcp_agent = False
if ((self.deploy_mode == const.T5 or self.deploy_mode == const.T6)
and not fuel_cluster_id):
self.deploy_dhcp_agent = True
# selinux configuration
self.selinux_mode = None
# neutron vlan ranges
self.network_vlan_ranges = config.get('network_vlan_ranges')
network_vlan_range_pattern = re.compile(
const.NETWORK_VLAN_RANGE_EXPRESSION, re.IGNORECASE)
match = network_vlan_range_pattern.match(self.network_vlan_ranges)
if not match:
Helper.safe_print("network_vlan_ranges format is not correct.\n")
exit(1)
self.physnet = match.group(1)
self.lower_vlan = match.group(2)
self.upper_vlan = match.group(3)
#.........这里部分代码省略.........
示例2: __init__
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import safe_print [as 别名]
def __init__(self, config, fuel_cluster_id, tag, cleanup):
# fuel cluster id
self.fuel_cluster_id = fuel_cluster_id
# tag, only deploy nodes with this tag
self.tag = tag
# clean up flag
self.cleanup = cleanup
# flags for upgrade
self.install_ivs = config.get('default_install_ivs')
self.install_bsnstacklib = config.get('default_install_bsnstacklib')
self.install_all = config.get('default_install_all')
# flags for dhcp and metadata agent
self.deploy_dhcp_agent = config.get('default_deploy_dhcp_agent')
# setup node ip and directory
self.setup_node_ip = Helper.get_setup_node_ip()
self.setup_node_dir = os.getcwd()
# t5 or t6 mode
self.deploy_mode = config.get('default_deploy_mode')
if not self.deploy_mode:
self.deploy_mode = const.T5
for node_config in config['nodes']:
node_mode = node_config.get('deploy_mode')
if node_mode and node_mode.lower() == const.T6:
self.deploy_mode = const.T6
break
# selinux configuration
self.selinux_mode = None
if os.path.isfile(const.SELINUX_CONFIG_PATH):
with open(const.SELINUX_CONFIG_PATH, "r") as selinux_config_file:
selinux_mode_match = re.compile(const.SELINUX_MODE_EXPRESSION, re.IGNORECASE)
lines = selinux_config_file.readlines()
for line in lines:
match = selinux_mode_match.match(line)
if match:
self.selinux_mode = match.group(1)
break
# neutron vlan ranges
self.network_vlan_ranges = config['network_vlan_ranges']
network_vlan_range_pattern = re.compile(const.NETWORK_VLAN_RANGE_EXPRESSION, re.IGNORECASE)
match = network_vlan_range_pattern.match(self.network_vlan_ranges)
if not match:
Helper.safe_print("network_vlan_ranges' format is not correct.\n")
exit(1)
self.physnet = match.group(1)
self.lower_vlan = match.group(2)
self.upper_vlan = match.group(3)
# bcf controller information
self.bcf_controllers = config['bcf_controllers']
self.bcf_controller_ips = []
for controller in self.bcf_controllers:
ip = controller.split(':')[0]
self.bcf_controller_ips.append(ip)
self.bcf_controller_user = config['bcf_controller_user']
self.bcf_controller_passwd = config['bcf_controller_passwd']
self.bcf_openstack_management_tenant = config.get('bcf_openstack_management_tenant')
# ivs pkg and debug pkg
self.ivs_pkg_map = {}
self.ivs_url_map = {}
for ivs_url in config['ivs_packages']:
ivs_pkg = os.path.basename(ivs_url)
if '.rpm' in ivs_pkg and 'debuginfo' not in ivs_pkg:
self.ivs_url_map['rpm'] = ivs_url
self.ivs_pkg_map['rpm'] = ivs_pkg
elif '.rpm' in ivs_pkg and 'debuginfo' in ivs_pkg:
self.ivs_url_map['debug_rpm'] = ivs_url
self.ivs_pkg_map['debug_rpm'] = ivs_pkg
elif '.deb' in ivs_pkg and 'dbg' not in ivs_pkg:
self.ivs_url_map['deb'] = ivs_url
self.ivs_pkg_map['deb'] = ivs_pkg
elif '.deb' in ivs_pkg and 'dbg' in ivs_pkg:
self.ivs_url_map['debug_deb'] = ivs_url
self.ivs_pkg_map['debug_deb'] = ivs_pkg
# information will be passed on to nodes
self.skip = False
if 'default_skip' in config:
self.skip = config['default_skip']
self.os = config.get('default_os')
self.os_version = config.get('default_os_version')
self.role = config.get('default_role')
self.user = config.get('default_user')
self.passwd = config.get('default_passwd')
self.uplink_interfaces = config.get('default_uplink_interfaces')
# openstack bsnstacklib version and horizon patch
self.openstack_release = str(config['openstack_release']).lower()
self.bsnstacklib_version = const.OS_RELEASE_TO_BSN_LIB[self.openstack_release]
self.deploy_horizon_patch = const.DEPLOY_HORIZON_PATCH
self.horizon_patch_url = const.HORIZON_PATCH_URL[self.openstack_release]
self.horizon_patch = os.path.basename(self.horizon_patch_url)
#.........这里部分代码省略.........
示例3: __init__
# 需要导入模块: from helper import Helper [as 别名]
# 或者: from helper.Helper import safe_print [as 别名]
def __init__(self, config, mode, fuel_cluster_id, rhosp, tag, cleanup, skip_ivs_version_check):
# fuel cluster id
self.fuel_cluster_id = fuel_cluster_id
# rhosp as installer
self.rhosp = rhosp
# tag, only deploy nodes with this tag
self.tag = tag
# clean up flag
self.cleanup = cleanup
self.skip_ivs_version_check = skip_ivs_version_check
# neutron_id for ml2 plugin restproxy
self.neutron_id = config.get('neutron_id')
# installer pxe interface ip
self.installer_pxe_interface_ip = config.get(
'installer_pxe_interface_ip')
# install to specified nodes
self.deploy_to_specified_nodes_only = config.get(
'deploy_to_specified_nodes_only')
# flags for upgrade
self.install_ivs = config.get('default_install_ivs')
self.install_bsnstacklib = config.get('default_install_bsnstacklib')
self.install_all = True
# flags for dhcp and metadata agent
self.deploy_dhcp_agent = config.get('default_deploy_dhcp_agent')
# flags for l3 agent
self.deploy_l3_agent = config.get('default_deploy_l3_agent')
# setup node ip and directory
self.setup_node_ip = Helper.get_setup_node_ip()
example_yamls = ["/usr/local/etc/bosi/config.yaml",
"/usr/etc/bosi/config.yaml"]
for example_yaml in example_yamls:
if os.path.isfile(example_yaml):
self.setup_node_dir = os.path.dirname(example_yaml)
break
# t5 or t6 mode
self.deploy_mode = const.MODE_DICT.get(mode)
if not self.deploy_mode:
self.deploy_mode = const.T5
# selinux configuration
self.selinux_mode = None
if os.path.isfile(const.SELINUX_CONFIG_PATH):
with open(const.SELINUX_CONFIG_PATH, "r") as selinux_config_file:
selinux_mode_match = re.compile(const.SELINUX_MODE_EXPRESSION,
re.IGNORECASE)
lines = selinux_config_file.readlines()
for line in lines:
match = selinux_mode_match.match(line)
if match:
self.selinux_mode = match.group(1)
break
# neutron vlan ranges
self.network_vlan_ranges = config.get('network_vlan_ranges')
network_vlan_range_pattern = re.compile(
const.NETWORK_VLAN_RANGE_EXPRESSION, re.IGNORECASE)
match = network_vlan_range_pattern.match(self.network_vlan_ranges)
if not match:
Helper.safe_print("network_vlan_ranges' format is not correct.\n")
exit(1)
self.physnet = match.group(1)
self.lower_vlan = match.group(2)
self.upper_vlan = match.group(3)
# bcf controller information
self.bcf_controllers = config['bcf_controllers']
self.bcf_controller_ips = []
for controller in self.bcf_controllers:
ip = controller.split(':')[0]
self.bcf_controller_ips.append(ip)
self.bcf_controller_user = config['bcf_controller_user']
self.bcf_controller_passwd = config['bcf_controller_passwd']
self.bcf_openstack_management_tenant = config.get(
'bcf_openstack_management_tenant')
# ivs pkg and debug pkg
self.ivs_pkg_map = {}
self.ivs_url_map = {}
if config['ivs_packages']:
for ivs_url in config['ivs_packages']:
ivs_pkg = os.path.basename(ivs_url)
if '.rpm' in ivs_pkg and 'debuginfo' not in ivs_pkg:
self.ivs_url_map['rpm'] = ivs_url
self.ivs_pkg_map['rpm'] = ivs_pkg
elif '.rpm' in ivs_pkg and 'debuginfo' in ivs_pkg:
self.ivs_url_map['debug_rpm'] = ivs_url
self.ivs_pkg_map['debug_rpm'] = ivs_pkg
elif '.deb' in ivs_pkg and 'dbg' not in ivs_pkg:
#.........这里部分代码省略.........