#!/usr/bin/python
# vim: ts=4 sts=4 sw=4 et si
#
# Copyright (c) 2016-2017, Parallels International GmbH
#
# Our contact details: Parallels International GmbH, Vordergasse 59, 8200
# Schaffhausen, Switzerland.
#

from __future__ import print_function
import os
import sys
sys.path.append('/usr/share/shaman')
import shaman_functions as shaman

def error(msg):
    print(msg, file = sys.stderr)

def get_env(name):
    '''Get the value of a given environment variable'''
    val = os.environ.get(name)
    if not val:
        error('%r environment variable undefined' % name)
        sys.exit(1)
    return val

answer = {
    'cpupools' : 'yes',
    'relocate-broken' : 'yes',
    'type' : 'CT:VZ7',
    'has-flavors' : 'yes'
}

prop = get_env('PROPERTY_NAME')
if prop == 'all':
    for k, v in answer.iteritems():
        print('%s=%s' % (k, v))
elif prop == 'flavor':
    try:
        print(shaman.CtConfig(get_env('RESOURCE_PATH')).get_flavor())
    except Exception:
        print('')
else:
    print(answer.get(prop, ''))

