Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

ainfo satprep_prepare_maintenance

Christian Stankowic edited this page May 20, 2015 · 5 revisions

satprep_prepare_maintenance.py is used to create VM snapshots and schedule downtimes for affected systems. Check out the tested setups wiki page for supported platforms. The script requires a snapshot report including information about affected hosts. If the report includes information about patches requiring reboots (reboot_suggested errata flag or kernel package name) and the system's monitoring (custom key SYSTEM_MONITORING) and snapshot state (custom key SYSTEM_VIRT) it will only schedule downtime and create snapshot for appropriate hosts.

Before doing patch tasks it is preferable to run the script again in -V / --verify-only mode. This makes sure that downtimes and VM snapshots have been created. During this check a verification file (e.g. 20151603_satprep.vlog) is created. This file includes information about downtimes and VM snapshots - the satprep_diff.py script will use this log to pre-select checkboxes on your PDF reports.

#Parameters

##Generic Options

Parameter Description
-c / --comment defines a comment for downtimes and snapshots (default: 'System maintenance scheduled by satprep')
-d / --debug enable debugging outputs
-f / --no-intelligence disables checking for patches requiring reboot, simply schedules downtimes and creates snapshots for all hosts mentioned in the CSV report (default: no)
-n / --dry-run only simulates tasks that would be executed (default: no)
-T / --tidy unschedules downtimes and removes previously created snapshots (default: no)
-V / --verify-only verifies that all required downtimes and snapshots have been created and quits (default: no)

##Monitoring Options

Parameter Description
-k / --skip-monitoring skips creating/removing downtimes (default: no)
-a / --mon-authfile defines an auth file to use instead of shell variables - see the [[wiki
-u / --monitoring-url defines the default Nagios/Icinga/Thruk/Shinken URL to use, might be overwritten by custom system keys (default: http://localhost/icinga)
-t / --hours sets the time period in hours hosts should be scheduled for downtime (default: 2)
-x / --no-auth disables HTTP basic auth (default: no)
-A / --user-agent sets a custom HTTP user agent
-g / --downtime-hostgroup defines hostgroups which should be scheduled for downtime. This disables scheduling downtime for particular hosts.

##VM Options

Parameter Description
-K / --skip-snapshot skips creating/removing snapshots (default: no)
-H / --libvirt-uri defines the default URI used by libvirt, might be overwritten by custom system keys
-C / --virt-authfile defines an auth file to use for virtualization

##Report Options

Parameter Description
-p / --prod-only only prepares maintenance for productive hosts (default: no)
-D / --nonprod-only only prepares maintenance for non-productive hosts (default: no)
-e / --exclude defines hosts that should be exluded from preparing maintenance

#Examples Create snapshots and downtimes on a vSphere ESXi host and Icinga server:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -u "http://mysrv/icinga" -H "esx://myesx?no_verify=1"
Monitoring Username:
Monitoring Password:
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostA' (hours=2, comment=System maintenance scheduled by satprep)...
Virtualization Username:
Virtualization Password:
INFO:satprep_prepare_maintenance:Creating a snapshot ('20151603_satprep') for VM 'myHostA')...

Schedule downtime for affected production hosts on local Icinga installation, skip creating snapshots if needed:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -K -p
Monitoring Username:
Monitoring Password:
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostA' (hours=2, comment=System maintenance scheduled by satprep)...
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostB' (hours=2, comment=System maintenance scheduled by satprep)...
...

Schedule downtime for affected non-production hosts on remote OMD site (Icinga installation) specifying a custom comment and time period, also skip creating snapshots:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -u "http://omd.localdomain.loc/mysite/icinga" -c "System maintenance on 03/16/2015" -t 1 -K -D
Monitoring Username:
Monitoring Password:
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostA' (hours=1, comment=System maintenance on 03/16/2015)...
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostB' (hours=1, comment=System maintenance on 03/16/2015)...
...

Skip checking whether downtimes and snapshots are required - just create them, set a different HTTP user agent and ignore myHostC:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -f -a "Foobrowser v1.2" -e myHostC.localdomain.loc
Monitoring Username:
Monitoring Password:
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostA' (hours=2, comment=System maintenance scheduled by satprep)...
INFO:satprep_prepare_maintenance:Scheduling downtime for host 'myHostB' (hours=2, comment=System maintenance scheduled by satprep)...
Virtualization Username:
Virtualization Password:
INFO:satprep_prepare_maintenance:Creating a snapshot ('20151603_satprep') for VM 'myHostA')...
INFO:satprep_prepare_maintenance:Creating a snapshot ('20151603_satprep') for VM 'myHostB')...

Only simulate preparing maintenance on remote Icinga instance and ESXi server:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -n -u "http://omd.localdomain.loc/mysite/icinga" -H "esx://myesx?no_verify=1"
Monitoring Username:
Monitoring Password:
INFO:satprep_prepare_maintenance:I'd like to schedule downtime for host 'myHostA' for 2 hours using the comment 'System maintenance scheduled by satprep'...
INFO:satprep_prepare_maintenance:I'd like to schedule downtime for host 'myHostB' for 2 hours using the comment 'System maintenance scheduled by satprep'...
INFO:satprep_prepare_maintenance:I'd like to create a snapshot ('20150316_satprep') for VM 'myHostA'...
INFO:satprep_prepare_maintenance:I'd like to create a snapshot ('20150316_satprep') for VM 'myHostB'...

Create snapshots and schedule downtimes for 2 Icinga hostgroups:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -u "http://mysrv/icinga" -g myGroupA -g mygroupB
Monitoring Username:
Monitoring Password:
Successfully scheduled downtime for hostgroup 'myGroupA'
Successfully scheduled downtime for hostgroup 'myGroupB'
...

Unschedule previously scheduled downtimes and remove snapshots:

$ ./satprep_prepare_maintenance.py errata-snapshot-report*.csv -u "http://omd.localdomain.loc/mysite/icinga" -H "esx://myesx?no_verify=1" -T
Monitoring Username:
Monitoring Password:
Successfully (un)scheduled downtime for host 'myHostA'
Successfully (un)scheduled downtime for host 'myHostB'
Virtualization Username:
Virtualization Password:
Creating a snapshot ('20151603_satprep') for VM 'myHostA')...
Creating a snapshot ('20151603_satprep') for VM 'myHostB')...
Clone this wiki locally