Exemple #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")
Exemple #2
0
    def _create_deployment_resources(self):
        res = AXResources()

        for route in self.spec.template.internal_routes:
            # ignore empty port spec
            if len(route.ports) == 0:
                logger.debug(
                    "Skipping internal route {} as port spec is empty".format(
                        route.name))
                continue
            ir = InternalRoute(route.name, self.application)
            ir.create(route.to_dict()["ports"],
                      selector={"deployment": self.name},
                      owner=self.name)
            res.insert(ir)
            logger.debug("Created route {}".format(ir))

        for route in self.spec.template.external_routes:

            dns_name = route.dns_name()
            if dns_name.endswith("."):
                dns_name = dns_name[:-1]

            r = ExternalRoute(dns_name, self.application,
                              {"deployment": self.name}, route.target_port,
                              route.ip_white_list, route.visibility)
            try:
                elb_addr = visibility_to_elb_addr(route.visibility)
                elb_name = visibility_to_elb_name(route.visibility)
            except AXNotFoundException:
                if route.visibility == ExternalRouteVisibility.VISIBILITY_WORLD:
                    raise AXNotFoundException(
                        "Could not find the public ELB. Please report this error to Applatix Support at [email protected]"
                    )
                else:
                    assert route.visibility == ExternalRouteVisibility.VISIBILITY_ORGANIZATION, "Only world and organization are currently supported as visibility attributes"
                    raise AXNotFoundException(
                        "Please create a private ELB using the template named 'ax_private_elb_creator_workflow' before using 'visibility=organization'"
                    )

            name = r.create(elb_addr, elb_name=elb_name)
            res.insert(r)
            logger.debug("Created external route {} for {}/{}/{}".format(
                name, self.application, self.name, dns_name))

        main_container = self.spec.template.get_main_container()
        for key_name, vol in iteritems(main_container.inputs.volumes):
            assert "resource_id" in vol.details, "Volume resource_id absent in volume details"
            name = vol.details.get("axrn", None)
            resource_id = vol.details.get("resource_id", None)
            assert name is not None and resource_id is not None, "axrn and resource_id are required details for volume {}".format(
                key_name)
            nv_res = AXNamedVolumeResource(name, resource_id)
            nv_res.create()
            res.insert(nv_res)
            logger.debug(
                "Using named volume resource {} in application {}".format(
                    name, self.application))

        return res
Exemple #3
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))