コード例 #1
0
ファイル: demiurge.py プロジェクト: Kendralabs/platform-tests
def demiurge_create_cluster(cluster_name):
    """PUT /clusters/{cluster_name}"""
    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(TapComponent.demiurge)).request(
            method=HttpMethod.PUT,
            path="clusters/{}".format(cluster_name),
            msg="DEMIURGE: create cluster")
コード例 #2
0
def app_broker_bind_service_instance(instance_guid, application_guid):
    """PUT /v$/service_instances/:instanceId/service_bindings/:app_guid"""
    return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request(
        method=HttpMethod.PUT,
        path="service_instances/{}/service_bindings/{}".format(instance_guid, application_guid),
        msg="APP BROKER: bind service instance to app",
    )
コード例 #3
0
ファイル: demiurge.py プロジェクト: Kendralabs/platform-tests
def demiurge_get_clusters():
    """GET /clusters"""
    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(TapComponent.demiurge)).request(
            method=HttpMethod.GET,
            path="clusters",
            msg="DEMIURGE: get list of clusters")
コード例 #4
0
def app_broker_delete_service_instance(instance_guid):
    """DELETE /v$/service_instances/:instanceId"""
    return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request(
        method=HttpMethod.DELETE,
        path="service_instances/{}".format(instance_guid),
        msg="APP BROKER: delete service instance",
    )
コード例 #5
0
def app_broker_get_catalog():
    """GET /v$/catalog"""
    return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request(
        method=HttpMethod.GET,
        path="catalog",
        msg="APP BROKER: get catalog"
    )
コード例 #6
0
def k8s_broker_get_catalog():
    """GET /v$/catalog"""
    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(
            TapComponent.kubernetes_broker)).request(
                method=HttpMethod.GET,
                path="catalog",
                msg="K8S BROKER: get catalog")
コード例 #7
0
def k8s_broker_get_service_status(org_guid, service_id):
    """GET /v$/:org_id/service/:instance_id/status"""
    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(
            TapComponent.kubernetes_broker)).request(
                method=HttpMethod.GET,
                path="{}/service/{}/status".format(org_guid, service_id),
                msg="K8S BROKER: get instance status")
コード例 #8
0
def k8s_broker_delete_instance(instance_guid):
    """DELETE /v$/service_instances/:instanceId"""
    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(
            TapComponent.kubernetes_broker)).request(
                method=HttpMethod.DELETE,
                path="service_instances/{instance_guid}",
                path_params={'instance_guid': instance_guid},
                msg="K8S BROKER: delete instance")
コード例 #9
0
def k8s_broker_delete_service(service_name=None):
    """DELETE /v$/dynamicservice"""
    body = {}
    if service_name is not None:
        body["dynamicService"] = {"serviceName": service_name}
    response = HttpClientFactory.get(
        BrokerConfigurationProvider.get(
            TapComponent.kubernetes_broker)).request(
                method=HttpMethod.DELETE,
                path="dynamicservice",
                body=body,
                msg="K8S BROKER: delete service offering")
    return response
コード例 #10
0
def app_broker_new_service_instance(instance_guid, organization_guid, plan_id, service_id, space_guid, instance_name):
    """PUT /v$/service_instances/:instanceId"""
    query = {
        "organization_guid": organization_guid,
        "plan_id": plan_id,
        "service_id": service_id,
        "space_guid": space_guid,
        "parameters": {"name": instance_name}
    }
    return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request(
        method=HttpMethod.PUT,
        path="service_instances/{}".format(instance_guid),
        body=query,
        msg="APP BROKER: create new service instance",
    )
コード例 #11
0
def app_broker_create_service(app_guid, description, service_name):
    """POST /v$/catalog"""
    query = {
        "app": {
            "metadata": {"guid": app_guid}
        },
        "description": description,
        "name": service_name
    }
    return HttpClientFactory.get(BrokerConfigurationProvider.get(TapComponent.application_broker)).request(
        method=HttpMethod.POST,
        path="catalog",
        body=query,
        msg="APP BROKER: create service in catalog",
    )
コード例 #12
0
def k8s_broker_create_service_offering(org_guid,
                                       space_guid,
                                       service_name=None):
    """PUT /v$/dynamicservice"""

    body_cont_ports = [{"containerPort": 27017, "protocol": "TCP"}]
    body_cont_env = [{
        "name": "MANAGED_BY",
        "value": "TAP"
    }, {
        "name": "MONGODB_PASSWORD",
        "value": "user"
    }, {
        "name": "MONGODB_USERNAME",
        "value": "password"
    }, {
        "name": "MONGODB_DBNAME",
        "value": "test"
    }]
    body_containers = [{
        "name": "k-mongodb30",
        "image": "frodenas/mongodb:3.0",
        "ports": body_cont_ports,
        "env": body_cont_env,
        "resources": {},
        "imagePullPolicy": ""
    }]
    body_ports = [{
        "name": "",
        "protocol": "TCP",
        "port": 27017,
        "targetPort": 0,
        "nodePort": 0
    }]
    body_credentials = {
        "dbname": "$env_MONGODB_DBNAME",
        "hostname": "$hostname",
        "password": "******",
        "port": "$port_27017",
        "ports": {
            "27017/tcp": "$port_27017"
        },
        "uri":
        "mongodb://$env_MONGODB_USERNAME:$env_MONGODB_PASSWORD@$hostname:$port_27017/$env_MONGODB_DBNAME",
        "username": "******"
    }
    body_dynamic_service = {
        "serviceName": service_name,
        "planName": service_name,
        "isPlanFree": True,
        "containers": body_containers,
        "servicePorts": body_ports,
        "credentialsMappings": body_credentials
    }

    body = {
        "organization_guid": org_guid,
        "space_guid": space_guid,
        "updateBroker": True,
        "parameters": None,
        "dynamicService": body_dynamic_service
    }

    return HttpClientFactory.get(
        BrokerConfigurationProvider.get(
            TapComponent.kubernetes_broker)).request(
                method=HttpMethod.PUT,
                path="dynamicservice",
                body=body,
                msg="K8S BROKER: create service offering")