def modify_auto_scaling_group(): if (OtcConfig.SCALINGGROUP_ID is None) and not (OtcConfig.SCALINGGROUP_NAME is None): autoscaling.convertASNameToId() #print(SCALINGGROUP_NAME) #vpc_id if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() #scaling_configuration_id if not (OtcConfig.SCALING_CONFIGURATION_NAME is None): autoscaling.convertASConfigurationNameToId() #lb_listener_id if not (OtcConfig.LISTENER_NAME is None): autoscaling.convertLISTENERNameToId() #network_id if not OtcConfig.SUBNETNAME is None: ecs.convertSUBNETNameToId() #security_group_id if not OtcConfig.SECUGROUPNAME is None: ecs.convertSECUGROUPNameToId() #print(OtcConfig.SECUGROUPNAME) #print(OtcConfig.SECUGROUP) REQ_CREATE_SCG = utils_templates.create_request("modify_as_group") url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group/" + OtcConfig.SCALINGGROUP_ID ret = utils_http.put(url, REQ_CREATE_SCG) autoscaling.otcOutputHandler().print_output(ret, mainkey="") #print(REQ_CREATE_SCG) return ret
def create_load_balancers(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() REQ_CREATE_ELB = utils_templates.create_request("create_loadbalancer") url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" ret = utils_http.post(url, REQ_CREATE_ELB) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" + maindata["message"]) os._exit(1) print("created") return ret
def create_load_balancers(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() REQ_CREATE_ELB = "{ \"name\": \"" + OtcConfig.LOADBALANCER_NAME + "\", \"description\": \"" + OtcConfig.LOADBALANCER_NAME+ "\", \"vpc_id\": \"" + OtcConfig.VPCID +"\", \"bandwidth\": 10, \"type\": \"External\", \"admin_state_up\": true }" url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" ret = utils_http.post(url, REQ_CREATE_ELB) print(ret) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" +maindata["message"]) os._exit( 1 ) print("created") return ret
def create_load_balancers(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() REQ_CREATE_ELB = "{ \"name\": \"" + OtcConfig.LOADBALANCER_NAME + "\", \"description\": \"" + OtcConfig.LOADBALANCER_NAME+ "\", \"vpc_id\": \"" + OtcConfig.VPCID +"\", \"bandwidth\": 10, \"type\": \"External\", \"admin_state_up\": true }" url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/loadbalancers" ret = utils_http.post(url, REQ_CREATE_ELB) print(ret) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" +maindata["message"]) os._exit( 1 ) print("created") return ret
def create_listener(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() REQ_CREATE_LISTENER = utils_templates.create_request("create_listener") print REQ_CREATE_LISTENER url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners" ret = utils_http.post(url, REQ_CREATE_LISTENER) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" + maindata["message"]) os._exit(1) elb.otcOutputHandler().print_output(ret, mainkey="") print(ret) #ecs.otcOutputHandler().print_output(ret, mainkey="loadbalancer") return ret
def create_listeners(): if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() #REQ_CREATE_ELB = "{ \"name\": \"" + OtcConfig.LOADBALANCER_NAME + "\", \"description\": \"" + OtcConfig.LOADBALANCER_NAME+ "\", \"vpc_id\": \"" + OtcConfig.VPCID +"\", \"bandwidth\": 10, \"type\": \"External\", \"admin_state_up\": true }" REQ_CREATE_LISTENER = "{ \"name\":\"listener1\", \"description\":\"\", \"loadbalancer_id\":\"0b07acf06d243925bc24a0ac7445267a\", \"protocol\":\"HTTP\", \"port\":88, \"backend_protocol\":\"HTTP\", \"backend_port\":80, \"lb_algorithm\":\"roundrobin\", \"session_sticky\":true, \"sticky_session_type\":\"insert\", \"cookie_timeout\":100 }" #print( REQ_CREATE_ELB ) url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners" ret = utils_http.post(url, REQ_CREATE_LISTENER) print( ret ) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" +maindata["message"]) os._exit( 1 ) print( ret ) #ecs.otcOutputHandler().print_output(ret, mainkey="loadbalancer") return ret
def create_listeners(): raise RuntimeError('NOT TESTED YET!!!!') if not (OtcConfig.LOADBALANCER_NAME is None): elb.convertELBNameToId() if not (OtcConfig.VPCNAME is None): ecs.convertVPCNameToId() #REQ_CREATE_ELB = "{ \"name\": \"" + OtcConfig.LOADBALANCER_NAME + "\", \"description\": \"" + OtcConfig.LOADBALANCER_NAME+ "\", \"vpc_id\": \"" + OtcConfig.VPCID +"\", \"bandwidth\": 10, \"type\": \"External\", \"admin_state_up\": true }" REQ_CREATE_LISTENER = "{ \"name\":\"listener1\", \"description\":\"\", \"loadbalancer_id\":\"0b07acf06d243925bc24a0ac7445267a\", \"protocol\":\"HTTP\", \"port\":88, \"backend_protocol\":\"HTTP\", \"backend_port\":80, \"lb_algorithm\":\"roundrobin\", \"session_sticky\":true, \"sticky_session_type\":\"insert\", \"cookie_timeout\":100 }" #print( REQ_CREATE_ELB ) url = elb.baseurl+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners" ret = utils_http.post(url, REQ_CREATE_LISTENER) print( ret ) maindata = json.loads(ret) if "code" in maindata: print("Can not create:" +maindata["message"]) os._exit( 1 ) print( ret ) #ecs.otcOutputHandler().print_output(ret, mainkey="loadbalancer") return ret