summaryrefslogtreecommitdiffstats
path: root/abs/core-testing/LinHES-config/mv_smolt.py
blob: e4fbaee45fd244586abdbe7cfd4ca2a4c388784c (plain)
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
58
59
# -*- coding: utf-8 -*-
import logging
import mv_common

def read_release(stype):
    if stype == "LinHES":
        rfile = "/etc/LinHES-release"
    else:
        rfile = "/etc/MythVantage-release"

    try:
        f= open(rfile,'r')
        releasename = f.readlines()[0]
        f.close()
    except:
        logging.debug("    Couldn't open %s",rfile)
        releasename = "unknown"

    return releasename


def setup_smolt_type(SystemType,Remotetype,RunFrontend,mythhome,stype):
    logging.debug("____Start of setup_smolt_type____")
    releasename = read_release(stype)

    if SystemType == "Standalone":
        smoltsystem = 6
        MVRELEASE="%s (Standalone)" %releasename
    elif SystemType == "Master_backend":
        if RunFrontend == "1":
            smoltsystem = 2
            MVRELEASE="%s (MBE with Frontend)" %releasename
        else:
            smoltsystem=1
            MVRELEASE="%s (MBE)" %releasename
    elif SystemType == "Slave_backend":
        if RunFrontend == "1" :
            smoltsystem = 4
            MVRELEASE="%s (SLAVE  with Frontend)" %releasename
        else:
            smoltsystem = 5
            MVRELEASE="%s (SLAVE)" %releasename
    elif SystemType == "Frontend_only":
        smoltsystem = 3
        MVRELEASE="%s ( Frontend only)" %releasename

    logging.info("    smolt type is %s : %s", MVRELEASE,smoltsystem)
    smoltfile = mythhome+"/.mythtv/smolt.info"
    cmd = ''' echo  "%s" > /etc/os_myth_release ''' %MVRELEASE
    mv_common.runcmd(cmd)

    cmd = '''echo "systemtype=%s" > %s''' %(smoltsystem,smoltfile)
    mv_common.runcmd(cmd)

    cmd = '''echo "remote=%s" >> %s ''' %(Remotetype,smoltfile)
    mv_common.runcmd(cmd)

    logging.debug("__End of setup_smolt_type")