Пример #1
0
def add_roles_to_farm(roles_type=None, options=None):
    roles = []
    for r in roles_type:
        LOG.info('Add role with behavior %s to farm' % r)
        role = roles_table.filter({'behavior': r}).first()
        LOG.debug('Added role: %s' % role)
        roles.append(role.keys()[0])
    world.farm.add_role(roles, options=options)
Пример #2
0
def add_role_to_farm(role_type=None, options=None, scripting=None, storages=None):
    role = None
    if CONF.main.role_id:
        role = roles_table[CONF.main.role_id]
    elif role_type:
        role = roles_table.filter({'behavior': role_type}).first()
    else:
        role = roles_table.filter().first()
    if not role:
        raise AssertionError('Not find role in roles table')
    old_roles_ids = [r.id for r in world.farm.roles]
    LOG.info('Add role %s to farm' % role)
    world.farm.add_role(role.keys()[0], options=options, scripting=scripting, storages=storages)
    LOG.info('Add role %s to farm %s\n options: %s\n scripting: %s' % (role.keys()[0], world.farm.id, options, scripting))
    time.sleep(5)
    world.farm.roles.reload()
    for r in world.farm.roles:
        if not r.id in old_roles_ids:
            return r
    return None