Exemplo n.º 1
0
def load_values(lang=None):
    # load UCR variables
    ucr.load()
    values = dict([
        (ikey,
         ucr[ikey].decode('utf-8', 'replace') if ucr[ikey] else ucr[ikey])
        for ikey in UCR_VARIABLES
    ])

    # net
    from univention.management.console.modules.setup.network import Interfaces
    interfaces = Interfaces()
    values['interfaces'] = interfaces.to_dict()
    values['physical_interfaces'] = [
        idev['name'] for idev in detect_interfaces()
    ]

    # see whether the system has been joined or not
    values['joined'] = is_system_joined()

    # root password
    values['root_password'] = ''

    # memory
    values['memory_total'] = psutil.virtual_memory(
    ).total / 1024.0 / 1024.0  # MiB

    # get timezone
    values['timezone'] = ''
    if os.path.exists('/etc/timezone'):
        with open('/etc/timezone') as fd:
            values['timezone'] = fd.readline().strip().decode(
                'utf-8', 'replace')

    # read license agreement for app appliance
    if lang and ucr.get('umc/web/appliance/data_path'):
        prefix = ucr.get('umc/web/appliance/data_path')
        license_path = '%sLICENSE_AGREEMENT' % prefix
        localized_license_path = '%s_%s' % (license_path, lang.upper())
        english_license_path = '%s_EN' % license_path
        for ipath in (localized_license_path, license_path,
                      english_license_path):
            if os.path.exists(ipath):
                with open(ipath) as license_file:
                    values['license_agreement'] = (''.join(
                        license_file.readlines())).decode('utf-8', 'replace')
                    break

    # check for installed system activation
    values['system_activation_installed'] = os.path.exists(
        '/usr/sbin/univention-system-activation')

    return values
Exemplo n.º 2
0
def pre_save(newValues):
	'''Modify the final dict before saving it to the profile file.'''

	# network interfaces
	from univention.management.console.modules.setup.network import Interfaces
	if 'interfaces' in newValues:
		interfaces = Interfaces()
		interfaces.from_dict(newValues.pop('interfaces'))
		interfaces.check_consistency()
		newValues.update(dict((key, value or '') for key, value in interfaces.to_ucr().iteritems()))