Esempio n. 1
0
def axmon_deployment_external_route_delete(applicationname, deploymentname,
                                           dns_name):
    deployment = Deployment(deploymentname, applicationname)
    selector = deployment.get_labels()
    er = ExternalRoute(dns_name, applicationname, selector, 80)
    er.delete()
    return jsonify(result="ok")
Esempio n. 2
0
def axmon_deployment_external_route(applicationname, deploymentname):
    """
    Creates an external route for a deployment in an application. Note this is used to create
    external routes out of sync with service templates and generally not fully supported.
    Data for post is in the following format
    {
        "dns_name": the dns domain name to be used
        "target_port": the port to point to in the deployment
        "whitelist": An list of cidrs
        "visibility": "world" or "organization"
    }
    """
    (
        dns_name,
        target_port,
        whitelist,
        visibility,
    ) = _get_required_arguments('dns_name', 'target_port', 'whitelist',
                                'visibility')
    deployment = Deployment(deploymentname, applicationname)
    selector = deployment.get_labels()
    er = ExternalRoute(dns_name, applicationname, selector, target_port,
                       whitelist, visibility)
    elb_addr = visibility_to_elb_addr(visibility)
    return jsonify(result=er.create(elb_addr))
Esempio n. 3
0
File: rest.py Progetto: nuaays/argo
def axmon_deployment_status(applicationname, deploymentname):
    """
    Get status of a deployment in an application. This is idempotent
    Returns:
        A json dict on success in the following format
        { 'result': 'ok' }
    """
    deployment = Deployment(deploymentname, applicationname)
    status = deployment.status()
    return jsonify(result=status)
Esempio n. 4
0
File: rest.py Progetto: nuaays/argo
def axmon_deployment_scale_update(applicationname, deploymentname):
    """
    Change the scale of a deployment. The body should have the following format
    {
        "replicas": integer
    }
    Returns:
        A json dict on success in the following format
        { 'result': 'ok' }
    """
    (replicas,) = _get_required_arguments('replicas')
    deployment = Deployment(deploymentname, applicationname)
    deployment.scale(replicas)
    return jsonify(result="ok")
Esempio n. 5
0
File: rest.py Progetto: nuaays/argo
def axmon_deployment_delete(applicationname, deploymentname):
    """
    Delete a deployment in an application. This is idempotent
    Query Param:
      timeout: In seconds or None for infinity
    Returns:
        A json dict on success in the following format
        { 'result': 'ok' }
    """
    timeout = request.args.get('timeout', None)
    if timeout is not None:
        timeout = int(timeout)
    deployment = Deployment(deploymentname, applicationname)
    deployment.delete(timeout=timeout)
    return jsonify(result="ok")
Esempio n. 6
0
File: rest.py Progetto: nuaays/argo
def axmon_deployment_create(applicationname):
    """
    Create a deployment in an application. This is idempotent
    The body of the post is the deployment template template in the 'template' field.
    Returns:
        A json dict on success in the following format
        { 'result': 'ok' }
    """
    data = request.get_json()
    _app.logger.debug("Deployment create for {}".format(json.dumps(data)))
    s = DeploymentService()
    s.parse(data)

    assert applicationname == s.template.application_name, \
        "Application name {} does not match the one in template {}".format(applicationname, s.template.application_name)

    deployment = Deployment(s.template.deployment_name, applicationname)
    deployment.create(s)
    return jsonify(result="ok")