Пример #1
0
def get_owner(conn, uuid):
    """Get VM owner by id
    @param uuid: uuid of the VM
    """
    ctid = get_ctid_by_uuid(conn, uuid)
    parser = SimpleConfigParser()
    parser.read('/etc/vz/conf/%s.conf' % ctid)
    conf = parser.items()
    return conf['ON_OWNER'].strip().replace('"', '')\
        if 'ON_OWNER' in conf else ''
Пример #2
0
def get_owner(conn, uuid):
    """Get VM owner by id
    @param uuid: uuid of the VM
    """
    ctid = get_ctid_by_uuid(conn, uuid)
    parser = SimpleConfigParser()
    parser.read('/etc/vz/conf/%s.conf' % ctid)
    conf = parser.items()
    return conf['ON_OWNER'].strip().replace('"', '')\
        if 'ON_OWNER' in conf else ''
Пример #3
0
def generate_nonubc_config(conf_filename, settings):
    """ Generates Non-UBC part of  configuration file for VZ container """
    parser = SimpleConfigParser()
    parser.read(conf_filename)
    config_dict = parser.items()
    # Parameters to read. Others will be generated using ovf settings.
    include_params = ["VE_ROOT", "VE_PRIVATE", "OSTEMPLATE", "ORIGIN_SAMPLE"]
    config_dict = dict((k, v) for k, v in config_dict.iteritems() if k in include_params)
    config_str = "\n".join("%s=%s" % (k, v) for k, v in config_dict.iteritems())

    # set UUID if provided
    if settings.get('uuid'):
        config_str += "\n\n#UUID: %s" % settings.get('uuid')
    return config_str
Пример #4
0
def get_bmounts(ctid):
    """Return ON_BMOUNT for the VM with given CTID"""
    parser = SimpleConfigParser()
    try:
        parser.read('/etc/vz/conf/%s.conf' % ctid)
    except IOError:
        # File not found in case we are doing a new conf
        return ''
    conf = parser.items()
    if 'ON_BMOUNT' in conf:
        if conf['ON_BMOUNT'].strip().startswith('"'):
            conf['ON_BMOUNT'] = conf['ON_BMOUNT'][1:]
        if conf['ON_BMOUNT'].strip().endswith('"'):
            conf['ON_BMOUNT'] = conf['ON_BMOUNT'][:-1]
        return conf['ON_BMOUNT']
    else:
        return ''
Пример #5
0
def get_bmounts(ctid):
    """Return ON_BMOUNT for the VM with given CTID"""
    parser = SimpleConfigParser()
    try:
        parser.read('/etc/vz/conf/%s.conf' % ctid)
    except IOError:
        # File not found in case we are doing a new conf
        return ''
    conf = parser.items()
    if 'ON_BMOUNT' in conf:
        if conf['ON_BMOUNT'].strip().startswith('"'):
            conf['ON_BMOUNT'] = conf['ON_BMOUNT'][1:]
        if conf['ON_BMOUNT'].strip().endswith('"'):
            conf['ON_BMOUNT'] = conf['ON_BMOUNT'][:-1]
        return conf['ON_BMOUNT']
    else:
        return ''
Пример #6
0
def generate_nonubc_config(conf_filename, settings):
    """ Generates Non-UBC part of  configuration file for VZ container """
    parser = SimpleConfigParser()
    parser.read(conf_filename)
    config_dict = parser.items()
    # Parameters to read. Others will be generated using ovf settings.
    include_params = ["VE_ROOT", "VE_PRIVATE", "OSTEMPLATE", "ORIGIN_SAMPLE"]
    config_dict = dict(
        (k, v) for k, v in config_dict.iteritems() if k in include_params)
    config_str = "\n".join("%s=%s" % (k, v)
                           for k, v in config_dict.iteritems())

    # set UUID if provided
    if settings.get('uuid'):
        config_str += "\n\n#UUID: %s" % settings.get('uuid')

    # Add ON_BMOUNT if needed
    if settings.get('bind_mounts'):
        config_str += "\nON_BMOUNT=\"%s\"" % settings.get('bind_mounts')
    return config_str