def _add_interfaces(ifaces_desired_state, ifaces_current_state): ifaces2add = [ ifaces_desired_state[name] for name in six.viewkeys(ifaces_desired_state) - six.viewkeys(ifaces_current_state) if ifaces_desired_state[name].get('state') != 'absent' ] validator.verify_interfaces_state(ifaces2add, ifaces_desired_state) ifaces_configs = nm.applier.prepare_new_ifaces_configuration(ifaces2add) nm.applier.create_new_ifaces(ifaces_configs)
def _add_interfaces(ifaces_desired_state, ifaces_current_state): ifaces2add = [ ifaces_desired_state[name] for name in six.viewkeys(ifaces_desired_state) - six.viewkeys(ifaces_current_state) if ifaces_desired_state[name].get('state') not in ('absent', 'down') ] validator.verify_interfaces_state(ifaces2add, ifaces_desired_state) ifaces2add += nm.applier.prepare_proxy_ifaces_desired_state(ifaces2add) ifaces_configs = nm.applier.prepare_new_ifaces_configuration(ifaces2add) nm.applier.create_new_ifaces(ifaces_configs) nm.applier.set_ifaces_admin_state(ifaces2add)
def _edit_interfaces(ifaces_desired_state, ifaces_current_state): ifaces2edit = [ _canonicalize_desired_state(ifaces_desired_state[name], ifaces_current_state[name]) for name in six.viewkeys(ifaces_desired_state) & six.viewkeys(ifaces_current_state) ] validator.verify_interfaces_state(ifaces2edit, ifaces_desired_state) iface2prepare = list( filter(lambda state: state.get('state') != 'absent', ifaces2edit)) ifaces_configs = nm.applier.prepare_edited_ifaces_configuration( iface2prepare) nm.applier.edit_existing_ifaces(ifaces_configs) nm.applier.set_ifaces_admin_state(ifaces2edit)