def delete_auto_scaling_instance_from_group():
     if not OtcConfig.INSTANCE_NAME is None:
         getplugin("ecs").convertINSTANCENameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group_instance/" + OtcConfig.INSTANCE_ID
     ret = utils_http.delete(url)
     print(ret)
     return ret
예제 #2
0
    def delete_jobbinary():
        if not (OtcConfig.JOBBINARY is None):
            getplugin("sahara").convertJOBBINARYNameToId()

        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/job-binaries/" + OtcConfig.JOBBINARY_ID
        ret = utils_http.delete(url)
        sahara.otcOutputHandler().print_output(ret, mainkey = "") 
        return ret
예제 #3
0
    def update_jobobject():               
        if not (OtcConfig.JOB is None):
            getplugin("sahara").convertJOBNameToId()

        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/jobs/" + OtcConfig.JOB_ID               
        REQ_UPDADTE_JOBOBJECT=utils_templates.create_request("update_jobobject")
        ret = utils_http.patch(url, REQ_UPDADTE_JOBOBJECT)
        sahara.otcOutputHandler().print_output(ret, mainkey = "") 
예제 #4
0
 def validateConfig():        
     if OtcConfig.USERNAME != None and len(OtcConfig.USERNAME) == 32 and OtcConfig.PASSWORD != None and len(OtcConfig.PASSWORD) == 32 and OtcConfig.DOMAIN != None and len(OtcConfig.DOMAIN) == 23:
         getplugin("ecs").getIamToken()
         #cls.otcServiceCalls.getIamToken()
     elif OtcConfig.ak != None and len(OtcConfig.ak) == 32 and OtcConfig.sk != None and len(OtcConfig.sk) == 32:
         raise RuntimeError("TODO: ERROR NOT IMPLEMENTED !!!")
     else:
         raise ValueError()
예제 #5
0
 def delete_jobobject():
     if not (OtcConfig.JOB is None):
         getplugin("sahara").convertJOBNameToId()
     
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/jobs/" + OtcConfig.JOB_ID        
     ret = utils_http.delete(url)
     print (url)
     print (ret)        
     sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
예제 #6
0
 def add_node():
     #vpc_id
     if not (OtcConfig.CLUSTER is None):
         getplugin("cce").convertClusterNameToId()
                        
     url = "https://cce.eu-de.otc.t-systems.com" + "/api/v1/clusters/" + OtcConfig.CLUSTER_ID  + "/hosts"
     req = utils_templates.create_request("cce_add_node")
     ret = utils_http.post(url, req)
     cce.otcOutputHandler().print_output(ret,mainkey="")     
     return ret
예제 #7
0
 def create_backend_member():
     if not (OtcConfig.LISTENER_NAME is None):
         elb.convertLISTENERNameToId()
     if not OtcConfig.INSTANCE_NAME is None:
         getplugin("ecs").convertINSTANCENameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners/" + OtcConfig.LISTENER_ID + "/members"
     REQ_CREATE_BACKEND_MEMBER = utils_templates.create_request("add_backend_member")
     ret = utils_http.post(url, REQ_CREATE_BACKEND_MEMBER)
     print(ret)
     return ret
예제 #8
0
 def describe_clusterhosts():                 
     if not (OtcConfig.CLUSTER is None):
         getplugin("mrs").convertCLUSTERNameToId()
      
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/clusters/" + OtcConfig.CLUSTER_ID + "/hosts"        
     url = url.replace("iam", "mrs")
                                  
     ret = utils_http.get( url )
                         
     mrs.otcOutputHandler().print_output(ret,mainkey="") 
     return ret
예제 #9
0
 def delete_datasource():
     if not (OtcConfig.DATASOURCE is None):
         getplugin("sahara").convertDATASOURCENameToId()
     
     if OtcConfig.DATASOURCE_ID is  None:
         raise RuntimeError("Not found!")                      
     
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/data-sources/" + OtcConfig.DATASOURCE_ID
     ret = utils_http.delete(url)
     sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
 def create_auto_scaling_configuration():
     if not OtcConfig.INSTANCE_TYPE_NAME is None:
         getplugin("ecs").convertFlavorNameToId()
     if not OtcConfig.IMAGENAME is None:
         getplugin("ecs").convertIMAGENameToId()
     REQ_CREATE_SC=utils_templates.create_request("create_as_configuration")
     #print(REQ_CREATE_SC)
     url = "https://" + OtcConfig.DEFAULT_HOST+ "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_configuration"
     ret = utils_http.post(url, REQ_CREATE_SC)
     autoscaling.otcOutputHandler().print_output(ret,mainkey="")
     return ret
예제 #11
0
    def update_jobbinary():               
        if not (OtcConfig.JOBBINARY is None):
            getplugin("sahara").convertJOBBINARYNameToId()

        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/job-binaries/" + OtcConfig.JOBBINARY_ID
                  
        REQ_UPDADTE_JOBBINARY=utils_templates.create_request("update_jobbinary")
        ret = utils_http.put(url, REQ_UPDADTE_JOBBINARY)
        print (url)
        print (ret)        
        sahara.otcOutputHandler().print_output(ret, mainkey = "") 
예제 #12
0
    def execute_jobobject():

        if not (OtcConfig.JOB is None):
            getplugin("sahara").convertJOBNameToId()
        REQ_EXECUTE=utils_templates.create_request("execute_jobobject")                       
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/jobs/" + OtcConfig.JOB_ID +"/execute"
        ret = utils_http.post(url, REQ_EXECUTE)
        if OtcConfig.DEBUG:        
            print(REQ_EXECUTE)
            print (url)
            print (ret)        
        sahara.otcOutputHandler().print_output(ret, mainkey = "")     
        return ret
예제 #13
0
 def add_as():
     if not (OtcConfig.CLUSTER is None):
         getplugin("mrs").convertCLUSTERNameToId()
      
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/autoscaling-policy/" + OtcConfig.CLUSTER_ID         
     url = url.replace("iam", "mrs")
                                             
     REQ_ADD_NODE=utils_templates.create_request("add_as")               
      
     ret = utils_http.post(url, REQ_ADD_NODE)
     print (url)
     print (ret)        
     mrs.otcOutputHandler().print_output(ret, mainkey = "") 
    def batch_add_delete_auto_scaling_instances():
        if not (OtcConfig.SCALINGGROUP_NAME is None):
            autoscaling.convertASNameToId()

        if (OtcConfig.INSTANCE_ID is None) and not OtcConfig.INSTANCE_NAME is None:
            getplugin("ecs").convertINSTANCENameToId()

        REQ_BATCH_INST=utils_templates.create_request("batch_remove_add_instance")

        url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group_instance/"+ OtcConfig.SCALINGGROUP_ID +"/action"
        ret = utils_http.post(url, REQ_BATCH_INST)
        #print(REQ_BATCH_INST)
        autoscaling.otcOutputHandler().print_output(ret,mainkey="")
        return ret
예제 #15
0
    def create_cluster():
        #vpc_id
        if not (OtcConfig.VPCNAME is None):
            getplugin("ecs").convertVPCNameToId()
                  
        #network_id
        if not OtcConfig.SUBNETNAME is None:
            getplugin("ecs").convertSUBNETNameToId()
        url = "https://cce.eu-de.otc.t-systems.com" + "/api/v1/clusters"
        req = utils_templates.create_request("cce_create_cluster")

        ret = utils_http.post(url, req)         
        cce.otcOutputHandler().print_output(ret,mainkey="")     
        return ret
예제 #16
0
    def create_load_balancers():
        if not (OtcConfig.LOADBALANCER_NAME is None):
            elb.convertELBNameToId()
        if not (OtcConfig.VPCNAME is None):
            getplugin("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
예제 #17
0
    def get_image():
        if not (OtcConfig.IMAGENAME is None):
            getplugin("ecs").convertIMAGENameToId()

        if OtcConfig.IMAGE_ID is None:
            # error handling
            raise RuntimeError("Please define image id!")

        # image id filled until now
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/images/" + OtcConfig.IMAGE_ID + "/file"
        REQ_REG_IMAGE = "{\"image_url\":\"" + OtcConfig.IMAGE_URL + "\" }"
        ret = utils_http.post(url, REQ_REG_IMAGE)
        if len(ret) != 0:
            print("Image registration error!" + ret)
        return ret
예제 #18
0
 def describe_jobs():
     if not (OtcConfig.JOB is None):
         getplugin("sahara").convertJOBNameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/jobs"        
     
     if OtcConfig.JOB_ID is None: 
         ret = utils_http.get(url)
         sahara.otcOutputHandler().print_output(ret, mainkey = "")
     else:            
         ret = utils_http.get(url + '/' + OtcConfig.JOB_ID )        
         maindata = json.loads(ret)
         if "itemNotFound" in  maindata:
             raise RuntimeError("Not found!")                      
         sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
예제 #19
0
    def update_datasource():
                       
        if not (OtcConfig.DATASOURCE_ID is None):
            getplugin("sahara").convertDATASOURCENameToId()
        
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/data-sources/" + OtcConfig.DATASOURCE_ID
          
        
        REQ_UPDADTE_DATASORCE=utils_templates.create_request("update_datasource")

        ret = utils_http.put(url, REQ_UPDADTE_DATASORCE)
        print(REQ_UPDADTE_DATASORCE)
        print (url)
        print (ret)        
        sahara.otcOutputHandler().print_output(ret, mainkey = "") 
예제 #20
0
    def create_cluster():               
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/run-job-flow"
        #vpc_id
        if not (OtcConfig.VPCNAME is None):
            getplugin("ecs").convertVPCNameToId()
          
        #network_id
        if not OtcConfig.SUBNETNAME is None:
            getplugin("ecs").convertSUBNETNameToId()

        
        REQ_CREATE_CLUSTER=utils_templates.create_request("create_cluster_with_job")

        ret = utils_http.post(url, REQ_CREATE_CLUSTER)
        print(REQ_CREATE_CLUSTER)
        print (url)
        print (ret)        
        mrs.otcOutputHandler().print_output(ret, mainkey = "") 
예제 #21
0
    def create_listener():

        if not (OtcConfig.LOADBALANCER_NAME is None):
            elb.convertELBNameToId()
        if not (OtcConfig.VPCNAME is None):
            getplugin("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 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):
            getplugin("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:
            getplugin("ecs").convertSUBNETNameToId()
        #security_group_id
        if not OtcConfig.SECUGROUPNAME is None:
            getplugin("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
예제 #23
0
    def create_instance():
        if not OtcConfig.VPCNAME is None:
            getplugin("ecs").convertVPCNameToId()
        if not OtcConfig.SUBNETNAME is None:
            getplugin("ecs").convertSUBNETNameToId()
        if not OtcConfig.SECUGROUPNAME is None:
            getplugin("ecs").convertSECUGROUPNameToId()
        if not OtcConfig.AZ is None:
            dcs.convertAZnameToId()
        if OtcConfig.INSTANCE_TYPE_NAME is None:
            OtcConfig.INSTANCE_TYPE_NAME = "OTC_DCS_SINGLE:1"
        if OtcConfig.INSTANCE_NAME is None:
           OtcConfig.INSTANCE_NAME = "dcs"

        (OtcConfig.INSTANCE_DCS_TYPE,OtcConfig.INSTANCE_DCS_SIZE) = str(OtcConfig.INSTANCE_TYPE_NAME).split(':')
        REQ_CREATE_DCS=utils_templates.create_request("create_instance")
        #print (REQ_CREATE_DCS)

        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID +  "/instances"
        url = url.replace('iam', 'dcs')
        #print (url)
        ret = utils_http.post(url, REQ_CREATE_DCS )

        print (ret)

        return ret
예제 #24
0
    def create_cluster():        
        url = "https://" + OtcConfig.DEFAULT_HOST + "/rds/v1/"+ OtcConfig.PROJECT_ID +"/instances"
        url = url.replace('iam', 'rds')
        # url = string.replace(url, 'iam', 'rds')
        #vpc_id
        
        if not (OtcConfig.VPCNAME is None):
            getplugin("ecs").convertVPCNameToId()
        
        #network_id
        if not OtcConfig.SUBNETNAME is None:
            getplugin("ecs").convertSUBNETNameToId()

        if (not (OtcConfig.SECUGROUPNAME is None)):
            getplugin("ecs").convertSECUGROUPNameToId()


        if (OtcConfig.DBTYPE is None):
            OtcConfig.DBTYPE = "MySQL"

        if (OtcConfig.DBVERSION is None):
            OtcConfig.DBVERSION = "5.7.20"

        if (OtcConfig.DISK_SIZE is None):
            OtcConfig.DISK_SIZE = 100

        if (OtcConfig.DISK_TYPE is None):
            OtcConfig.DISK_TYPE = "COMMON"

        REQ_CREATE_CLUSTER=utils_templates.create_request("create_cluster")

        ret = utils_http.post(url, REQ_CREATE_CLUSTER)
        print(REQ_CREATE_CLUSTER)
        rds.otcOutputHandler().print_output(ret, mainkey = "")
예제 #25
0
    def create_cluster():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/rds/v1/" + OtcConfig.PROJECT_ID + "/instances"
        url = string.replace(url, 'iam', 'rds')
        #vpc_id
        if not (OtcConfig.VPCNAME is None):
            getplugin("ecs").convertVPCNameToId()

        #network_id
        if not OtcConfig.SUBNETNAME is None:
            getplugin("ecs").convertSUBNETNameToId()

        if (not (OtcConfig.SECUGROUPNAME is None)):
            getplugin("ecs").convertSECUGROUPNameToId()

        if not OtcConfig.SUBNETNAME is None:
            ecs.convertSUBNETNameToId()

        if (OtcConfig.DBTYPE is None):
            OtcConfig.DBTYPE = "MySQL"

        if (OtcConfig.DBVERSION is None):
            OtcConfig.DBVERSION = "5.7.20"

        if (OtcConfig.DISK_SIZE is None):
            OtcConfig.DISK_SIZE = 100

        if (OtcConfig.DISK_TYPE is None):
            OtcConfig.DISK_TYPE = "COMMON"

        REQ_CREATE_CLUSTER = utils_templates.create_request("create_cluster")

        ret = utils_http.post(url, REQ_CREATE_CLUSTER)
        print REQ_CREATE_CLUSTER
        print(url)
        print(ret)
        rds.otcOutputHandler().print_output(ret, mainkey="")
예제 #26
0
 def otcOutputHandler(): 
     return getplugin(OtcConfig.OUTPUT_FORMAT)
예제 #27
0
 def otcOutputHandler():
     return getplugin(OtcConfig.OUTPUT_FORMAT)
예제 #28
0
 def update_image_metadata():
     if not (OtcConfig.IMAGENAME is None):
         getplugin("ecs").convertIMAGENameToId()
     ims.create_image_metadata()
예제 #29
0
 def update_image_metadata():
     if not (OtcConfig.IMAGENAME is None):
         getplugin("ecs").convertIMAGENameToId()
     ims.create_image_metadata()