File: ganeti.bug-script

package info (click to toggle)
ganeti 2.16.0-5
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 16,660 kB
  • sloc: python: 105,115; haskell: 43,768; sh: 3,896; makefile: 2,763
file content (57 lines) | stat: -rwxr-xr-x 1,425 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/python

# Attach some ganeti-specific information to bug reports

import os
import sys
from socket import AF_INET6

def read_ssconf(key):
    try:
        with open("/var/lib/ganeti/ssconf_%s" % key) as ssconf:
            values = ssconf.readlines()
    except EnvironmentError:
        return []

    return [v.strip() for v in values]

out = os.fdopen(3, "w")

try:
    share = os.readlink("/etc/ganeti/share")
except EnvironmentError:
    share = ""

try:
    lib = os.readlink("/etc/ganeti/lib")
except EnvironmentError:
    lib = ""

print >> out, """Version symlinks:
  /etc/ganeti/share -> %s
  /etc/ganeti/lib -> %s""" % (share, lib)

if not os.path.exists("/var/lib/ganeti/ssconf_release_version"):
    out.write("No cluster configuration found.\n")
    sys.exit(0)

version = read_ssconf("release_version")
if version:
    out.write("Cluster config version: %s\n" % version[0])

af_pri = read_ssconf("primary_ip_family")
if af_pri:
    out.write("Address family: %s\n" %
              ("IPv6" if af_pri[0] == str(AF_INET6) else "IPv4"))

hv_list = read_ssconf("hypervisor_list")
out.write("Enabled hypervisors: %s\n" % " ".join(hv_list))

for hv in hv_list:
    hvp = read_ssconf("hvparams_%s" %hv)
    out.write("%s hypervisor parameters:\n" % hv)
    for param in hvp:
        # Skip unset parameters
        if not param.split("=", 1)[-1]:
            continue
        out.write("  " + param + "\n")