Beispiel #1
0
def create_manifest_app(parse):

    # 'Application' has to be defined
    app_name = parse.get('Application')
    if not app_name:
        return 'Application is not defined', None

    if not check_app_exists(app_name):
        # Create application if it does not exist yet
        res = createapp(app_name)
        if 'error' in res:
            return res['error'], None
        appid = res['aid']
    else:
        # Try different application names
        for i in range(2, 100):

            # If all the applications exists, then exit
            if i is 99:
                return 'Application cannot be created', None

            new_name = "%s (%d)" % (app_name, i)
            if not check_app_exists(new_name):
                res = createapp(new_name)
                if 'error' in res:
                    return res['error'], None
                appid = res['aid']
                break

    return 'ok', appid
Beispiel #2
0
def new_manifest(json):
    try:
        parse = simplejson.loads(json)
    except:
        return 'Error parsing json'

    # 'Application' has to be defined
    app_name = parse.get('Application')
    if not app_name:
        return 'Application is not defined'

    if not check_app_exists(app_name):
        # Create application if it does not exist yet
        res = createapp(app_name)
        appid = simplejson.loads(res.data).get('aid')
    else:
        # Try different application names
        for i in range(2, 99):
            new_name = "%s (%d)" % (app_name, i)
            if not check_app_exists(new_name):
                res = createapp(new_name)
                appid = simplejson.loads(res.data).get('aid')
                break

        # If all the applications exists, then exit
        if i is 99:
            return 'Application can not be created'

    if not parse.get('Services'):
        return 'ok'

    for service in parse.get('Services'):
        if service.get('Type') == 'php':
            msg = MPhp().start(service, appid)
        elif service.get('Type') == 'java':
            msg = MJava().start(service, appid)
        elif service.get('Type') == 'mysql':
            msg = MMySql().start(service, appid)
        elif service.get('Type') == 'scalaris':
            msg = MScalaris().start(service, appid)
        elif service.get('Type') == 'hadoop':
            msg = MHadoop().start(service, appid)
        elif service.get('Type') == 'selenium':
            msg = MSelenium().start(service, appid)
        elif service.get('Type') == 'xtreemfs':
            msg = MXTreemFS().start(service, appid)
        elif service.get('Type') == 'taskfarm':
            msg = MTaskFarm().start(service, appid)
        else:
            return 'Service %s does not exists' % service.get('Type')

        if msg is not 'ok':
            return msg

    return 'ok'
Beispiel #3
0
def new_manifest(json):
    try:
        parse = simplejson.loads(json)
    except:
        return 'Error parsing json'

    # 'Application' has to be defined
    app_name = parse.get('Application')
    if not app_name:
        return 'Application is not defined'

    if not check_app_exists(app_name):
        # Create application if it does not exist yet
        res = createapp(app_name)
        appid = simplejson.loads(res.data).get('aid')
    else:
        # Try different application names
        for i in range(2, 99):
            new_name = "%s (%d)" % (app_name, i)
            if not check_app_exists(new_name):
                res = createapp(new_name)
                appid = simplejson.loads(res.data).get('aid')
                break

        # If all the applications exists, then exit
        if i is 99:
            return 'Application can not be created'

    if not parse.get('Services'):
        return 'ok'

    for service in parse.get('Services'):
        if service.get('Type') == 'php':
            msg = MPhp().start(service, appid)
        elif service.get('Type') == 'java':
            msg = MJava().start(service, appid)
        elif service.get('Type') == 'mysql':
            msg = MMySql().start(service, appid)
        elif service.get('Type') == 'scalaris':
            msg = MScalaris().start(service, appid)
        elif service.get('Type') == 'hadoop':
            msg = MHadoop().start(service, appid)
        elif service.get('Type') == 'selenium':
            msg = MSelenium().start(service, appid)
        elif service.get('Type') == 'xtreemfs':
            msg = MXTreemFS().start(service, appid)
        elif service.get('Type') == 'taskfarm':
            msg = MTaskFarm().start(service, appid)
        else:
            return 'Service %s does not exists' % service.get('Type')

        if msg is not 'ok':
            return msg

    return 'ok'
Beispiel #4
0
def new_manifest(json):
    try:
        parse = simplejson.loads(json)
    except:
        return 'Error parsing json'

    # 'Application' has to be defined
    app_name = parse.get('Application')
    if not app_name:
        return 'Application is not defined'

    if not check_app_exists(app_name):
        # Create application if it does not exist yet
        res = createapp(app_name)
        appid = simplejson.loads(res.data).get('aid')
    else:
        # Try different application names
        for i in range(2, 99):
            new_name = "%s (%d)" % (app_name, i)
            if not check_app_exists(new_name):
                res = createapp(new_name)
                appid = simplejson.loads(res.data).get('aid')
                break

        # If all the applications exists, then exit
        if i is 99:
            return 'Application can not be created'

    if not parse.get('Services'):
        return 'ok'

    for service in parse.get('Services'):
        if service.get('Type') == "mysql":
            service['Type'] = "galera"

        try:
            cls = get_manifest_class(service.get('Type'))
        except Exception:
            return 'Service %s does not exists' % service.get('Type')

        msg = cls().start(service, appid)

        if msg is not 'ok':
            log('new_manifest: error starting %s service -> %s' % (service,
                msg))
            return msg

    return 'ok'
Beispiel #5
0
def new_manifest(json):
    try:
        parse = simplejson.loads(json)
    except:
        return 'Error parsing json'

    # 'Application' has to be defined
    app_name = parse.get('Application')
    if not app_name:
        return 'Application is not defined'

    if not check_app_exists(app_name):
        # Create application if it does not exist yet
        res = createapp(app_name)
        appid = simplejson.loads(res.data).get('aid')
    else:
        # Try different application names
        for i in range(2, 99):
            new_name = "%s (%d)" % (app_name, i)
            if not check_app_exists(new_name):
                res = createapp(new_name)
                appid = simplejson.loads(res.data).get('aid')
                break

        # If all the applications exists, then exit
        if i is 99:
            return 'Application can not be created'

    if not parse.get('Services'):
        return 'ok'

    for service in parse.get('Services'):
        try:
            cls = get_manifest_class(service.get('Type'))
        except Exception:
            return 'Service %s does not exists' % service.get('Type')

        msg = cls().start(service, appid)

        if msg is not 'ok':
            log('new_manifest: error starting %s service -> %s' %
                (service, msg))
            return msg

    return 'ok'