[node-patches] Change in ovirt-node[master]: Add snmp_enabled parameter for snmp auto configuration
hadong0720 at gmail.com
hadong0720 at gmail.com
Wed Dec 25 07:46:00 UTC 2013
hadong has uploaded a new change for review.
Change subject: Add snmp_enabled parameter for snmp auto configuration
......................................................................
Add snmp_enabled parameter for snmp auto configuration
Change-Id: I113f9835d9ac76deaab50bd9e8dfcb034328e441
Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1046186
Signed-off-by: hadong <hadong0720 at gmail.com>
---
M ovirt-node.spec.in
M plugins/Makefile.am
A plugins/snmp-args
M plugins/snmp_autoinstall.py
M scripts/ovirt-init-functions.sh.in
M src/ovirtnode/install.py
M src/ovirtnode/ovirtfunctions.py
7 files changed, 44 insertions(+), 10 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/27/22727/1
diff --git a/ovirt-node.spec.in b/ovirt-node.spec.in
index d364659..cb8b553 100644
--- a/ovirt-node.spec.in
+++ b/ovirt-node.spec.in
@@ -539,6 +539,7 @@
%{python_sitelib}/ovirt/node/setup/snmp/snmp_model.py*
%{python_sitelib}/ovirt/node/setup/snmp/snmp_page.py*
%{_sysconfdir}/ovirt-plugins.d/snmp.minimize
+%{_sysconfdir}/ovirt-commandline.d/snmp-args
%{_sysconfdir}/ovirt-config-boot.d/snmp_autoinstall.py*
diff --git a/plugins/Makefile.am b/plugins/Makefile.am
index 71134e3..e23df84 100644
--- a/plugins/Makefile.am
+++ b/plugins/Makefile.am
@@ -33,7 +33,8 @@
puppet.minimize
dist_pluginsargs_DATA = \
- puppet-args
+ puppet-args \
+ snmp-args
dist_pyovirtconfigboot_PYTHON = \
snmp_autoinstall.py \
diff --git a/plugins/snmp-args b/plugins/snmp-args
new file mode 100644
index 0000000..906c74c
--- /dev/null
+++ b/plugins/snmp-args
@@ -0,0 +1,2 @@
+snmp_enabled
+snmp_password
diff --git a/plugins/snmp_autoinstall.py b/plugins/snmp_autoinstall.py
index 8472bc2..af29648 100644
--- a/plugins/snmp_autoinstall.py
+++ b/plugins/snmp_autoinstall.py
@@ -17,9 +17,37 @@
# MA 02110-1301, USA. A copy of the GNU General Public License is
# also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt_config_setup.snmp import enable_snmpd
+from ovirt.node.utils.console import TransactionProgress
+from ovirt.node.setup.snmp import snmp_model
import ovirtnode.ovirtfunctions as _functions
+from ovirt.node.plugins import Changeset
args = _functions.get_cmdline_args()
-if "snmp_password" in args:
- enable_snmpd(args["snmp_password"])
+keys = ["snmp_enabled", "snmp_password"]
+
+keys_to_model = {"snmp_enabled": "snmp.enabled",
+ "snmp_password": "snmp.password",
+ }
+
+changes = dict((keys_to_model[key], args[key]) for key in keys if key in args)
+
+if __name__ == "__main__":
+ snmp = snmp_model.SNMP()
+ cfg = snmp.retrieve()
+ effective_model = Changeset({
+ "snmp.enabled": True if cfg["enabled"] else False,
+ "snmp.password": "",
+ })
+ effective_model.update(changes)
+ is_enabled = effective_model["snmp.enabled"]
+ pw = effective_model["snmp.password"] or \
+ _functions.OVIRT_VARS["OVIRT_SNMP_PASSWORD"] \
+ if "OVIRT_SNMP_PASSWORD" in _functions.OVIRT_VARS \
+ else ""
+ snmp.update(is_enabled)
+ if is_enabled and len(pw) > 0:
+ tx = snmp.transaction(snmp_password=pw)
+ TransactionProgress(tx, is_dry=False).run()
+ # clear ovirt_snmp_passwd from /etc/default/ovirt
+ pw_keys = ("OVIRT_SNMP_PASSWORD",)
+ snmp.clear(keys=pw_keys)
diff --git a/scripts/ovirt-init-functions.sh.in b/scripts/ovirt-init-functions.sh.in
index d9218c7..667e2bb 100644
--- a/scripts/ovirt-init-functions.sh.in
+++ b/scripts/ovirt-init-functions.sh.in
@@ -334,9 +334,11 @@
# WARNING: use for debugging only, this is not secure!
adminpw=
+ # snmp_enabled=0|1
# snmp_password=<authpassphrase>
# enable snmpd and set password for "root" SNMPv3 USM user
snmp_password=
+ snmp_enabled=
# CIM related options
# cim_enabled=0|1
@@ -649,9 +651,6 @@
enable_cim* | enable_cim | cim_enabled* | cim_enabled)
cim_enabled=1
;;
- snmp_password=*)
- snmp_password=${i#snmp_password=}
- ;;
mem_overcommit* | ovirt_overcommit*)
i=${i#mem_overcommit=}
@@ -843,7 +842,7 @@
# save boot parameters as defaults for ovirt-config-*
- params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs iscsi_name snmp_password install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile nfsv4_domain use_strong_rng disable_aes_ni keyboard_layout logrotate_max_size"
+ params="bootif init init_app vol_boot_size vol_efi_size vol_swap_size vol_root_size vol_config_size vol_logging_size vol_data_size vol_swap2_size vol_data2_size crypt_swap crypt_swap2 upgrade standalone overcommit ip_address ip_netmask ip_gateway ipv6 dns ntp vlan ssh_pwauth syslog_server syslog_port collectd_server collectd_port bootparams hostname firstboot runtime_mode kdump_nfs iscsi_name install netconsole_server netconsole_port stateless cim_enabled wipe_fakeraid iscsi_init iscsi_target_name iscsi_target_host iscsi_target_port iscsi_install network_layout bond_name bond_slaves bond_options tuned_profile nfsv4_domain use_strong_rng disable_aes_ni keyboard_layout logrotate_max_size"
# mount /config unless firstboot is forced
if [ "$firstboot" != "1" ]; then
mount_config
diff --git a/src/ovirtnode/install.py b/src/ovirtnode/install.py
index 3b51723..90cf0f2 100755
--- a/src/ovirtnode/install.py
+++ b/src/ovirtnode/install.py
@@ -300,7 +300,10 @@
self.generate_paths()
logger.info("Installing the image.")
# copy grub.efi to safe location
- shutil.copy("/boot/efi/EFI/redhat/grub.efi", "/tmp")
+ if self.efi_dir_name == "fedora":
+ shutil.copy("/boot/efi/EFI/fedora/grubx64.efi", "/tmp")
+ else:
+ shutil.copy("/boot/efi/EFI/redhat/grub.efi", "/tmp")
if "OVIRT_ROOT_INSTALL" in OVIRT_VARS:
if OVIRT_VARS["OVIRT_ROOT_INSTALL"] == "n":
logger.info("Root Installation Not Required, Finished.")
diff --git a/src/ovirtnode/ovirtfunctions.py b/src/ovirtnode/ovirtfunctions.py
index ace96b5..7f47eda 100644
--- a/src/ovirtnode/ovirtfunctions.py
+++ b/src/ovirtnode/ovirtfunctions.py
@@ -1142,7 +1142,7 @@
# -O /dev/null
hookdir="/etc/ovirt-config-boot.d"
for hook in os.listdir(hookdir):
- if not is_auto_install():
+ if is_auto_install():
hookscript = os.path.join(hookdir,hook)
if hook.endswith(".py"):
system_closefds("python " + hookscript)
--
To view, visit http://gerrit.ovirt.org/22727
To unsubscribe, visit http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I113f9835d9ac76deaab50bd9e8dfcb034328e441
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: hadong <hadong0720 at gmail.com>
More information about the node-patches
mailing list