def determine_patches(self): patches = self.ds_globals['patches'] if not os.path.isfile(self.p_file): new_file = os.path.join(os.path.dirname(self.ds_file), 'common-patches.yaml') if os.path.isfile(new_file): logging.warning('Patch file {} not found, falling back to ' '{}'.format(self.p_file, new_file)) self.p_file = new_file else: logging.error('Unable to find common patch file: ' '{}'.format(self.p_file)) raise ApexDeployException( 'Specified common patch file not found: {}'.format( self.p_file)) logging.info('Loading patches from common patch file {}'.format( self.p_file)) common_patches = utils.parse_yaml(self.p_file) logging.debug('Content from common patch file is: {}'.format( pprint.pformat(common_patches))) os_version = self.ds['deploy_options']['os_version'] try: common_patches = common_patches['patches'][os_version] except KeyError: logging.error('Error parsing common patches file, wrong format.') raise ApexDeployException('Invalid format of common patch file') for ptype in ('undercloud', 'overcloud'): if ptype in common_patches: patches[ptype] = utils.unique(patches[ptype] + common_patches[ptype]) return patches
def parse_and_create_nodes(self): """ Parse snapshot node.yaml config file and create overcloud nodes :return: None """ node_file = os.path.join(self.snap_cache_dir, 'node.yaml') if not os.path.isfile(node_file): raise exc.SnapshotDeployException('Missing node definitions from ' ''.format(node_file)) node_data = utils.parse_yaml(node_file) if 'servers' not in node_data: raise exc.SnapshotDeployException('Invalid node.yaml format') for node, data in node_data['servers'].items(): logging.info('Creating node: {}'.format(node)) logging.debug('Node data is:\n{}'.format(pprint.pformat(data))) node_xml = os.path.join(self.snap_cache_dir, '{}.xml'.format(data['vNode-name'])) node_qcow = os.path.join(self.snap_cache_dir, '{}.qcow2'.format(data['vNode-name'])) self.oc_nodes.append( OvercloudNode(ip=data['address'], ovs_ctrlrs=data['ovs-controller'], ovs_mgrs=data['ovs-managers'], role=data['type'], name=node, node_xml=node_xml, disk_img=node_qcow)) logging.info('Node Created') logging.info('Starting nodes') for node in self.oc_nodes: node.start()
def clean_nodes(inventory): inv_dict = utils.parse_yaml(inventory) if inv_dict is None or 'nodes' not in inv_dict: logging.error("Inventory file is empty or missing nodes definition") sys.exit(1) for node, node_info in inv_dict['nodes'].items(): logging.info("Cleaning node: {}".format(node)) try: interface = pyipmi.interfaces.create_interface( 'ipmitool', interface_type='lanplus') connection = pyipmi.create_connection(interface) connection.session.set_session_type_rmcp(node_info['ipmi_ip']) connection.target = pyipmi.Target(0x20) connection.session.set_auth_type_user(node_info['ipmi_user'], node_info['ipmi_pass']) connection.session.establish() connection.chassis_control_power_down() except Exception as e: logging.error("Failure while shutting down node {}".format(e)) sys.exit(1)
def test_parse_yaml(self): assert_is_instance(utils.parse_yaml(NET_SETS), dict)
def test_parse_yaml(self): nose.tools.assert_is_instance( utils.parse_yaml('../config/network/network_settings.yaml'), dict)