| 1 |
# Copyright(c) 2018 WindRiver Systems |
| 2 |
# |
| 3 |
# Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 |
# you may not use this file except in compliance with the License. |
| 5 |
# You may obtain a copy of the License at |
| 6 |
# |
| 7 |
# http://www.apache.org/licenses/LICENSE-2.0 |
| 8 |
# |
| 9 |
# Unless required by applicable law or agreed to in writing, software |
| 10 |
# distributed under the License is distributed on an "AS IS" BASIS, |
| 11 |
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 |
# See the License for the specific language governing permissions and |
| 13 |
# limitations under the License. |
| 14 |
|
| 15 |
from oslo_config import cfg |
| 16 |
|
| 17 |
|
| 18 |
# Note: this string is being used for regex parsing later with re module. |
| 19 |
# |
| 20 |
# Use Python's raw string notation for regular expressions and |
| 21 |
# uses the backslash character ('\') to indicate special |
| 22 |
# forms or to allow special characters to be used without invoking |
| 23 |
# their special meaning. |
| 24 |
SOCK = r'/var/lib/libvirt/qemu/org\.qemu\.guest_agent\..*\.instance-.*\.sock' |
| 25 |
|
| 26 |
monitor_opts = [ |
| 27 |
cfg.IntOpt('guest_monitoring_interval', |
| 28 |
default=10, |
| 29 |
help=''' |
| 30 |
Guest monitoring interval of VM status (in seconds). |
| 31 |
* The value should not be too low as there should not be false negative |
| 32 |
* for reporting QEMU_GUEST_AGENT failures |
| 33 |
* VM needs time to do powering-off. |
| 34 |
* guest_monitoring_interval should be greater than |
| 35 |
* the time to SHUTDOWN VM gracefully. |
| 36 |
* e.g. | 565da9ba-3c0c-4087-83ca | iim1 | ACTIVE | powering-off | Running |
| 37 |
'''), |
| 38 |
cfg.IntOpt('guest_monitoring_timeout', |
| 39 |
default=2, |
| 40 |
help='Guest monitoring timeout (in seconds).'), |
| 41 |
cfg.IntOpt('guest_monitoring_failure_threshold', |
| 42 |
default=3, |
| 43 |
help='Failure threshold before sending notification.'), |
| 44 |
cfg.StrOpt('qemu_guest_agent_sock_path', |
| 45 |
default=SOCK, |
| 46 |
help=r''' |
| 47 |
* The file path of qemu guest agent sock. |
| 48 |
* Please use Python raw string notation as regular expressions. |
| 49 |
e.g. r'/var/lib/libvirt/qemu/org\.qemu\.guest_agent\..*\.instance-.*\.sock' |
| 50 |
'''), |
| 51 |
] |
| 52 |
|
| 53 |
|
| 54 |
def register_opts(conf): |
| 55 |
conf.register_opts(monitor_opts, group='introspectiveinstancemonitor') |
| 56 |
|
| 57 |
|
| 58 |
def list_opts(): |
| 59 |
return { |
| 60 |
'introspectiveinstancemonitor': monitor_opts |
| 61 |
} |