def delete_namespace(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/namespaces/" + OtcConfig.NAMESPACE ret = utils_http.delete(url) ecs.otcOutputHandler().print_output(ret, mainkey="") return ret
def rename_namespace(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/namespaces" req = utils_templates.create_request("cce_rename_namespace") ret = utils_http.post(url, req) ecs.otcOutputHandler().print_output(ret, mainkey="") return ret
def modify_service(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/namespaces/" + OtcConfig.NAMESPACE + "/services/" + OtcConfig.SERVICE_NAME req = utils_templates.create_request("cce_create_service") ret = utils_http.put(url, req) ecs.otcOutputHandler().print_output(ret, mainkey="") return ret
def describe_clusters(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() if OtcConfig.CLUSTER_ID: url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/clusters/" + OtcConfig.CLUSTER_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret, mainkey="") else: return cce.list_clusters()
def describe_health_check(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/healthcheck/" + OtcConfig.HEALTHCHECK_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret,mainkey="") return ret
def describe_listeners(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() url = elb.baseurl + "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners" + "?loadbalancer_id=" + OtcConfig.LOADBALANCER_ID ret = utils_http.get(url) mod = ret.replace("[", "").replace("]", "") ecs.otcOutputHandler().print_output(mod, mainkey="") return ret
def describe_health_check(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/healthcheck/" + OtcConfig.HEALTCHECK_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret,mainkey="") return ret
def describe_listeners(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners" + "?loadbalancer_id=" + OtcConfig.LOADBALANCER_ID ret = utils_http.get(url) mod = ret.replace("[","").replace("]","") ecs.otcOutputHandler().print_output(mod,mainkey="") return ret
def describe_pod_templates(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() if OtcConfig.POD: url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/namespaces/" + OtcConfig.NAMESPACE + "/podtemplates/" + OtcConfig.POD else: url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/namespaces/" + OtcConfig.NAMESPACE + "/podtemplates" ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret, mainkey="") return ret
def describe_load_balancers(): url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if OtcConfig.LOADBALANCER_ID: url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" + "/" + OtcConfig.LOADBALANCER_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret,mainkey="") else: url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" ret = utils_http.get(url) elb.otcOutputHandler().print_output(ret, mainkey="loadbalancers", listkey={"vip_address","update_time","create_time","id","name","status","bandwidth","admin_state_up","type","description" } ) return ret
def describe_load_balancers(): url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if OtcConfig.LOADBALANCER_ID: url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" + "/" + OtcConfig.LOADBALANCER_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret,mainkey="") else: url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" ret = utils_http.get(url) elb.otcOutputHandler().print_output(ret, mainkey="loadbalancers", listkey={"vip_address","update_time","create_time","id","name","status","bandwidth","admin_state_up","type","description" } ) return ret
def list_container_instances(): if OtcConfig.CLUSTER: cce.convertClusterNameToId() if OtcConfig.INSTANCE_NAME: ecs.convertINSTANCENameToId() if OtcConfig.INSTANCE_ID: url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/clusters/" + OtcConfig.CLUSTER_ID + "/hosts" ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret, mainkey="") else: url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/clusters/" + OtcConfig.CLUSTER_ID + "/hosts/" + OtcConfig.INSTANCE_ID ret = utils_http.get(url) ecs.otcOutputHandler().print_output(ret, mainkey="") return ret
def describe_quotas(): url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/quotas" ret = utils_http.get(url) print( ret ) ecs.otcOutputHandler().print_output(ret,mainkey="") return ret
def describe_quotas(): url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/quotas" ret = utils_http.get(url) print( ret ) ecs.otcOutputHandler().print_output(ret,mainkey="") return ret