コード例 #1
0
ファイル: smn.py プロジェクト: hodigy/python-otcclient-1
    def list_subscriptions():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/notifications/topics?offset=0&limit=10"
        print "PROJECT_ID=" + OtcConfig.PROJECT_ID
        print "URL=" + url
        URN = "urn:smn:eu-de:xxxx:CTS-Test"
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/notifications/topics/" + URN + "/subscriptions?offset=0&limit=10"

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

        if OtcConfig.INSTANCE_ID is None:
            ret = utils_http.get(url)
            print "RETURN=" + ret
            smn.otcOutputHandler().print_output(ret,
                                                mainkey="subscriptions",
                                                listkey={
                                                    "topic_urn", "protocol",
                                                    "subscription_urn",
                                                    "endpoint", "status"
                                                })
        else:
            ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID)
            maindata = json.loads(ret)
            if "itemNotFound" in maindata:
                raise RuntimeError("Not found!")
            smn.otcOutputHandler().print_output(ret, mainkey="server")
        return ret
コード例 #2
0
    def describe_jobexec():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/" + OtcConfig.PROJECT_ID + "/job-executions"

        if OtcConfig.JOBEXEC_ID is None:
            ret = utils_http.get(url)
            sahara.otcOutputHandler().print_output(ret, mainkey="")
        else:
            ret = utils_http.get(url + '/' + OtcConfig.JOBEXEC_ID)
            maindata = json.loads(ret)
            if "itemNotFound" in maindata:
                raise RuntimeError("Not found!")
            sahara.otcOutputHandler().print_output(ret, mainkey="")
        return ret
コード例 #3
0
ファイル: mrs.py プロジェクト: nixworks/python-otcclient
 def describe_clusters():        
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/cluster_infos"
     url = url.replace("iam", "mrs") 
     if OtcConfig.CLUSTER_ID is None: 
         ret = utils_http.get(url)
         mrs.otcOutputHandler().print_output(ret, mainkey = "")
     else:            
         ret = utils_http.get(url + '/' + OtcConfig.CLUSTER_ID )        
         maindata = json.loads(ret)
         if "itemNotFound" in  maindata:
             raise RuntimeError("Not found!")                      
         mrs.otcOutputHandler().print_output(ret,mainkey="") 
     return ret
コード例 #4
0
 def describe_jobexec():
     url = "https://" + OtcConfig.DEFAULT_HOST +  "/v1.1/" + OtcConfig.PROJECT_ID + "/job-executions"
     
     if OtcConfig.JOBEXEC_ID is None: 
         ret = utils_http.get(url)            
         sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     else:            
         ret = utils_http.get(url + '/' + OtcConfig.JOBEXEC_ID )        
         maindata = json.loads(ret)
         if "itemNotFound" in  maindata:
             raise RuntimeError("Not found!")                      
         sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
コード例 #5
0
 def describe_clusters():        
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/cluster_infos"
     url = url.replace("iam", "mrs") 
     if OtcConfig.CLUSTER_ID is None:
         print(url) 
         ret = utils_http.get(url)
         mrs.otcOutputHandler().print_output(ret, mainkey = "")
     else:            
         ret = utils_http.get(url + '/' + OtcConfig.CLUSTER_ID )        
         maindata = json.loads(ret)
         if "itemNotFound" in  maindata:
             raise RuntimeError("Not found!")                      
         mrs.otcOutputHandler().print_output(ret,mainkey="") 
     return ret
コード例 #6
0
ファイル: ecs.py プロジェクト: BuloZB/python-otcclient
    def describe_security_groups():
        if (not (OtcConfig.SECUGROUPNAME is None)) or (not (OtcConfig.SECUGROUP is None)):

            if (not (OtcConfig.SECUGROUPNAME is None)):
                ecs.convertSECUGROUPNameToId() 
                
            url = ecs.baseurl+ "/v2.0/security-group-rules?security_group_id=" + OtcConfig.SECUGROUP        
            ret = utils_http.get(url)                     
            ecs.otcOutputHandler().print_output(ret, mainkey= "security_group_rules", listkey={"id","direction", "protocol","port_range_min","port_range_max" })
        else:             
            url=ecs.baseurl+ "/v1/" + OtcConfig.PROJECT_ID + "/security-groups"
            ret = utils_http.get(url)            
            ecs.otcOutputHandler().print_output(ret, mainkey= "security_groups", listkey={"id", "name", "vpc_id" })                    
        return ret
コード例 #7
0
ファイル: ecs.py プロジェクト: kamilstas/python-otcclient
    def describe_security_groups():
        if (not (OtcConfig.SECUGROUPNAME is None)) or (not (OtcConfig.SECUGROUP is None)):

            if (not (OtcConfig.SECUGROUPNAME is None)):
                ecs.convertSECUGROUPNameToId() 
                
            url = "https://" + OtcConfig.DEFAULT_HOST+ "/v2.0/security-group-rules?security_group_id=" + OtcConfig.SECUGROUP        
            ret = utils_http.get(url)                     
            ecs.otcOutputHandler().print_output(ret, mainkey= "security_group_rules", listkey={"id","direction", "protocol","port_range_min","port_range_max" })
        else:             
            url="https://" + OtcConfig.DEFAULT_HOST+ "/v1/" + OtcConfig.PROJECT_ID + "/security-groups"
            ret = utils_http.get(url)            
            ecs.otcOutputHandler().print_output(ret, mainkey= "security_groups", listkey={"id", "name", "vpc_id" })                    
        return ret
コード例 #8
0
    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)
            elb.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
コード例 #9
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
コード例 #10
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
コード例 #11
0
ファイル: elb.py プロジェクト: kamilstas/python-otcclient
 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
コード例 #12
0
    def tenantusage():
        if not OtcConfig.TENANT:
            raise Exception(
                "Tenant list mandatory\neg:[{'projectid': 'xxxxxxxxxxxxxxxxxxxx','rowdelta': '1'}]"
            )
        if not OtcConfig.FILE1:
            raise Exception(
                "Template file mandatory\neg: --file1 mytemplatefile1.xlsx")

        tenants = json.loads(str(OtcConfig.TENANT).replace("'", "\""))

        for tenant in tenants:
            OtcConfig.PROJECT_ID = tenant["projectid"]
            sumvcpus = 0
            sumram = 0

            url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/servers/detail"
            ret = utils_http.get(url)
            print(ret)
            servers = json.loads(ret)
            servercount = len(servers["servers"])

            for s in servers["servers"]:
                f = customrep._get_flavor(s.get("flavor").get("id"))
                sumram += int(f.get("ram"))
                sumvcpus += int(f.get("vcpus"))

            url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/cloudvolumes" + "/detail"
            ret = utils_http.get(url)
            volumes = json.loads(ret)
            volumesum = 0
            for v in volumes["volumes"]:
                if v["status"] == "in-use":
                    volumesum += v.get("size")

            print("SUMVMs:", servercount)
            print("SUM vCPU:", sumvcpus)
            print("SUM RAM:", sumram)
            print("SUM Volume:", volumesum)

            datecolumn = getcoldatehour55(datetime.now())
            update_xlsx(datecolumn,
                        int(tenant["rowdelta"]),
                        cpus=sumvcpus,
                        ram=sumram,
                        servercount=servercount,
                        volumesum=volumesum,
                        report_file=OtcConfig.FILE1)
コード例 #13
0
 def describe_auto_scaling_instances():
     if not (OtcConfig.SCALINGGROUP_NAME is None):
         autoscaling.convertASNameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group_instance/" + OtcConfig.SCALINGGROUP_ID + "/list"
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_group_instances",listkey={"instance_name","instance_id", "scaling_group_name", "life_cycle_state"} )
     return ret
コード例 #14
0
ファイル: dms.py プロジェクト: hodigy/python-otcclient-1
 def describe_queues():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID +  "/queues"    
     ret = utils_http.get(url)
     print (url)
     print (ret)        
     
     return ret
コード例 #15
0
 def describe_policies():
     if not (OtcConfig.SCALINGGROUP_NAME is None):
         autoscaling.convertASNameToId()            
     url = autoscaling.baseurl+ "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_policy/" + OtcConfig.SCALINGGROUP_ID + "/list"  
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_policies", listkey={"scaling_policy_id", "scaling_group_id", "create_time", "scaling_policy_name","scaling_policy_type","scheduled_policy","cool_down_time","scaling_policy_action","policy_status"})
     return ret
コード例 #16
0
 def describe_auto_scaling_instances():
     if not (OtcConfig.SCALINGGROUP_NAME is None):
         autoscaling.convertASNameToId()            
     url = autoscaling.baseurl+ "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group_instance/" + OtcConfig.SCALINGGROUP_ID + "/list"  
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_group_instances", listkey={"instance_id", "scaling_group_name", "create_time", "health_status","scaling_configuration_name","scaling_configuration_id","instance_name"})
     return ret
コード例 #17
0
 def terminate_job():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/job-executions/" + OtcConfig.JOBEXEC_ID + "/cancel"        
     ret = utils_http.get(url)
     print (url)
     print (ret)        
     sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
コード例 #18
0
 def terminate_job():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/" + OtcConfig.PROJECT_ID + "/job-executions/" + OtcConfig.JOBEXEC_ID + "/cancel"
     ret = utils_http.get(url)
     print(url)
     print(ret)
     sahara.otcOutputHandler().print_output(ret, mainkey="")
     return ret
コード例 #19
0
 def list_clusters():
     url = "https://cce.eu-de.otc.t-systems.com" + "/api/v1/clusters"
     ret = utils_http.get(url)
     #print (ret)
     cce.otcOutputHandler().print_output(json.loads(ret), subkey="metadata", listkey={"name", "uuid", "createAt"})
     #cce.otcOutputHandler().print_output(json.loads(ret),mainkey="")     
     return ret
コード例 #20
0
 def describe_auto_scaling_configuration():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_configuration"
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_configurations", listkey={"scaling_configuration_name",
                                                                                                 "scaling_configuration_id",
                                                                                                  "create_time", "instance_config"})
     return ret
コード例 #21
0
    def list_container_instances():
        if OtcConfig.CLUSTER:
            cce.convertClusterNameToId()

        if OtcConfig.INSTANCE_NAME:
            cce.convertINSTANCENameToId()
        
        if OtcConfig.INSTANCE_ID:
            url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/clusters/" + OtcConfig.CLUSTER_ID + "/hosts"
            ret = utils_http.get(url)
            cce.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)
            cce.otcOutputHandler().print_output(ret,mainkey="")     
        return ret
コード例 #22
0
ファイル: smn.py プロジェクト: hodigy/python-otcclient-1
 def list_subscription(URN=0):
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/notifications/topics/urn:smn:eu-de:xxxxxxxxxx:CTS-Test/subscriptions?offset=0&limit=10"
     if URN is 0:
         URN = "urn:smn:eu-de:xxxx:CTS-Test"
         url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/notifications/topics/" + URN + "/subscriptions?offset=0&limit=10"
         ret = utils_http.get(url)
         return ret
コード例 #23
0
 def describe_cluster():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/" + OtcConfig.PROJECT_ID + "/cluster_infos/" + OtcConfig.CLUSTER_ID
     ret = utils_http.get(url)
     print(url)
     print(ret)
     mrs.otcOutputHandler().print_output(ret, mainkey="")
     return ret
コード例 #24
0
    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
コード例 #25
0
 def describe_cluster():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/cluster_infos/" + OtcConfig.CLUSTER_ID        
     ret = utils_http.get(url)
     print (url)
     print (ret)        
     mrs.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
コード例 #26
0
ファイル: mrs.py プロジェクト: nixworks/python-otcclient
 def describe_job_details():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/job-exes/" + OtcConfig.JOB-EXEC-ID
     ret = utils_http.get(url)
     print (url)
     print (ret)        
     mrs.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
コード例 #27
0
ファイル: ecs.py プロジェクト: kamilstas/python-otcclient
    def describe_instances():  
        url = "https://" + OtcConfig.DEFAULT_HOST +  "/v2/" + OtcConfig.PROJECT_ID + "/servers"
        
        if not OtcConfig.INSTANCE_NAME is None:
            ecs.convertINSTANCENameToId() 

        if OtcConfig.INSTANCE_ID is None: 
            ret = utils_http.get(url)        
            ecs.otcOutputHandler().print_output(ret, mainkey = "servers", listkey={"id", "name"})
        else:            
            ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID )        
            maindata = json.loads(ret)
            if "itemNotFound" in  maindata:
                raise RuntimeError("Not found!")                      
            ecs.otcOutputHandler().print_output(ret,mainkey="server") 
        return ret
コード例 #28
0
 def describe_auto_scaling_configuration():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_configuration"
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_configurations" #, subkey="instance_config"
     , listkey={"scaling_configuration_name","scaling_configuration_id","create_time"#, "instance_config"
             }
             )
     return ret
コード例 #29
0
    def describe_clusters():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/bigdata/api/v1/clusters?pageSize=10&currentPage=1&clusterState=existing"

        if OtcConfig.CLUSTER_ID is None:
            ret = utils_http.get(url)
            print(url)
            print(ret)
            mrs.otcOutputHandler().print_output(ret,
                                                mainkey="clusters",
                                                listkey={"id", "name"})
        else:
            ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID)
            maindata = json.loads(ret)
            if "itemNotFound" in maindata:
                raise RuntimeError("Not found!")
            mrs.otcOutputHandler().print_output(ret, mainkey="server")
        return ret
コード例 #30
0
ファイル: ecs.py プロジェクト: BuloZB/python-otcclient
    def describe_instances():  
        url = ecs.baseurl +  "/v2/" + OtcConfig.PROJECT_ID + "/servers"
        
        if not OtcConfig.INSTANCE_NAME is None:
            ecs.convertINSTANCENameToId() 

        if OtcConfig.INSTANCE_ID is None: 
            ret = utils_http.get(url)        
            ecs.otcOutputHandler().print_output(ret, mainkey = "servers", listkey={"id", "name"})
        else:            
            ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID )        
            maindata = json.loads(ret)
            if "itemNotFound" in  maindata:
                raise RuntimeError("Not found!") 
                os._exit( 1 )             
            ecs.otcOutputHandler().print_output(ret,mainkey="server") 
        return ret
コード例 #31
0
 def describe_jobs():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/job-exes"
     
     ret = utils_http.get(url)
     print (url)
     print (ret)        
     mrs.otcOutputHandler().print_output(ret, mainkey = "") 
     return ret
コード例 #32
0
 def describe_quotas_of_group():
     if not (OtcConfig.SCALINGGROUP_NAME is None):
         autoscaling.convertASNameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/quotas/" + OtcConfig.SCALINGGROUP_ID
     ret = utils_http.get(url)
     parsed = json.loads(ret)
     autoscaling.otcOutputHandler().print_output(parsed["quotas"]["resources"], mainkey="", listkey={"type", "used", "quota", "max"})
     return ret
コード例 #33
0
    def convertLISTENERIdToHealthCheckId():
        url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners/" + OtcConfig.LISTENER_ID

        JSON = utils_http.get(url)
        parsed  = json.loads(JSON)
        OtcConfig.HEALTHCHECK_ID = parsed["healthcheck_id"]
        ret = OtcConfig.HEALTHCHECK_ID
        return ret
コード例 #34
0
    def list_services():
        if OtcConfig.CLUSTER:
            cce.convertClusterNameToId()
        url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/services"
        ret = utils_http.get(url)

        cce.otcOutputHandler().print_output(ret, mainkey="")
        return ret
コード例 #35
0
    def describe_activitylog():
        if not (OtcConfig.SCALINGGROUP_NAME is None):
            autoscaling.convertASNameToId()
        url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_activity_log/" + OtcConfig.SCALINGGROUP_ID
        ret = utils_http.get(url)

        autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_activity_log", listkey={"id", "status", "description", "instance_value", "desire_value", "scaling_configuration_name", "scaling_value", "start_time", "end_time", "instance_added_list", "instance_deleted_list", "instance_removed_list"})
        return ret
コード例 #36
0
    def convertLISTENERIdToHealthCheckId():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID + "/elbaas/listeners/" + OtcConfig.LISTENER_ID

        JSON = utils_http.get(url)
        parsed = json.loads(JSON)
        OtcConfig.HEALTHCHECK_ID = parsed["healthcheck_id"]
        ret = OtcConfig.HEALTHCHECK_ID
        return ret
コード例 #37
0
 def describe_clusters():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/"+ OtcConfig.PROJECT_ID +"/cluster_infos/" + OtcConfig.CLUSTER_ID
     
     if OtcConfig.CLUSTER_ID is None: 
         ret = utils_http.get(url)
         print (url)
         print (ret)        
         #sahara.otcOutputHandler().print_output(ret, mainkey = "clusters", listkey={"id", "name"})
         sahara.otcOutputHandler().print_output(ret, mainkey = "") 
     else:            
         ret = utils_http.get(url + '/' + OtcConfig.CLUSTER_ID)        
         maindata = json.loads(ret)
         if "itemNotFound" in  maindata:
             raise RuntimeError("Not found!")                      
         sahara.otcOutputHandler().print_output(ret, mainkey = "") 
         #sahara.otcOutputHandler().print_output(ret,mainkey="server") 
     return ret
コード例 #38
0
    def describe_clusters():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/" + OtcConfig.PROJECT_ID + "/cluster_infos/" + OtcConfig.CLUSTER_ID

        if OtcConfig.CLUSTER_ID is None:
            ret = utils_http.get(url)
            print(url)
            print(ret)
            #sahara.otcOutputHandler().print_output(ret, mainkey = "clusters", listkey={"id", "name"})
            sahara.otcOutputHandler().print_output(ret, mainkey="")
        else:
            ret = utils_http.get(url + '/' + OtcConfig.CLUSTER_ID)
            maindata = json.loads(ret)
            if "itemNotFound" in maindata:
                raise RuntimeError("Not found!")
            sahara.otcOutputHandler().print_output(ret, mainkey="")
            #sahara.otcOutputHandler().print_output(ret,mainkey="server")
        return ret
コード例 #39
0
 def _get_flavor(flavorid):
     if not customrep.flavors:   
         url = "https://" + OtcConfig.DEFAULT_HOST + "/v1/" + OtcConfig.PROJECT_ID + "/cloudservers/flavors"        
         ret = utils_http.get(url)
         customrep.flavors = json.loads(ret)            
     for f in customrep.flavors["flavors"]:
         if flavorid == f.get("id"):
             return  f        
コード例 #40
0
    def tenantusage():
        if not OtcConfig.TENANT:
            raise Exception("Tenant list mandatory\neg:[{'projectid': 'xxxxxxxxxxxxxxxxxxxx','rowdelta': '1'}]")
        if not OtcConfig.FILE1:
            raise Exception("Template file mandatory\neg: --file1 mytemplatefile1.xlsx")        
        
        tenants = json.loads(str(OtcConfig.TENANT).replace("'", "\""))
                             
        for tenant in tenants:        
            OtcConfig.PROJECT_ID = tenant["projectid"]
            sumvcpus = 0
            sumram = 0

            url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/servers/detail"                        
            ret = utils_http.get(url)        
            servers = json.loads(ret)
            servercount = len(servers["servers"])
            
            for s in servers["servers"]:            
                f = customrep._get_flavor(s.get("flavor").get("id"))
                sumram += int(f.get("ram")) 
                sumvcpus += int(f.get("vcpus"))
    
            url = "https://" + OtcConfig.DEFAULT_HOST + "/v2/" + OtcConfig.PROJECT_ID + "/cloudvolumes" + "/detail"
            ret = utils_http.get(url)
            volumes = json.loads(ret)        
            volumesum = 0
            for v in volumes["volumes"]:
                if v["status"] == "in-use": 
                    volumesum += v.get("size")
                    
            print("SUMVMs:" , servercount) 
            print("SUM vCPU:", sumvcpus)
            print("SUM RAM:", sumram)     
            print("SUM Volume:", volumesum)

            datecolumn = getcoldatehour55(datetime.now())
            update_xlsx(
                        datecolumn,
                        int(tenant["rowdelta"]),
                        cpus=sumvcpus,
                        ram=sumram,
                        servercount=servercount,
                        volumesum=volumesum,
                        report_file=OtcConfig.FILE1
                        )        
コード例 #41
0
 def _get_flavor(flavorid):
     if not customrep.flavors:
         url = "https://" + OtcConfig.DEFAULT_HOST + "/v1/" + OtcConfig.PROJECT_ID + "/cloudservers/flavors"
         ret = utils_http.get(url)
         customrep.flavors = json.loads(ret)
     for f in customrep.flavors["flavors"]:
         if flavorid == f.get("id"):
             return f
コード例 #42
0
ファイル: ecs.py プロジェクト: BuloZB/python-otcclient
 def getECSJOBList():
     """ generated source for method getECSJOBList """        
     url = ecs.baseurl+ "/v1/" + OtcConfig.PROJECT_ID + "/jobs/" + OtcConfig.ECSTASKID
     ret = utils_http.get(url)
     newstatus = str( json.loads(ret)["status"]).upper()
     if newstatus != OtcConfig.ECSCREATEJOBSTATUS:
         sys.stdout.write( "\n" + newstatus )
     OtcConfig.ECSCREATEJOBSTATUS = newstatus         
     return OtcConfig.ECSCREATEJOBSTATUS
コード例 #43
0
 def describe_quotas():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/quotas"
     ret = utils_http.get(url)
     parsed = json.loads(ret)
     autoscaling.otcOutputHandler().print_output(
         parsed["quotas"]["resources"],
         mainkey="",
         listkey={"type", "used", "quota", "max"})
     return ret
コード例 #44
0
 def list_clusters():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/clusters"
     ret = utils_http.get(url)
     cce.otcOutputHandler().print_output(
         json.loads(ret),
         subkey="metadata",
         listkey={"name", "uuid", "createAt"})
     #ecs.otcOutputHandler().print_output(json.loads(ret),mainkey="")
     return ret
コード例 #45
0
    def describe_instance():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID +  "/instances"
        url = url.replace('iam', 'dcs')
        ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID )
        print(url+ '/' + OtcConfig.INSTANCE_ID)
        #print (ret)
        dcs.otcOutputHandler().print_output(ret, mainkey = "")

        return ret
コード例 #46
0
ファイル: ecs.py プロジェクト: kamilstas/python-otcclient
 def getECSJOBList():
     """ generated source for method getECSJOBList """        
     url = "https://" + OtcConfig.DEFAULT_HOST+ "/v1/" + OtcConfig.PROJECT_ID + "/jobs/" + OtcConfig.ECSTASKID
     ret = utils_http.get(url)
     newstatus = str( json.loads(ret)["status"]).upper()
     if newstatus != OtcConfig.ECSCREATEJOBSTATUS:
         sys.stdout.write( "\n" + newstatus )
     OtcConfig.ECSCREATEJOBSTATUS = newstatus         
     return OtcConfig.ECSCREATEJOBSTATUS
コード例 #47
0
ファイル: ecs.py プロジェクト: kamilstas/python-otcclient
    def list_volumes():
        if not OtcConfig.INSTANCE_NAME is None:
            ecs.convertINSTANCENameToId() 

        url = "https://" + OtcConfig.DEFAULT_HOST+ "/v2/" + OtcConfig.PROJECT_ID + "/servers/"+ OtcConfig.INSTANCE_ID + "/os-volume_attachments"
        ret = utils_http.get( url )
        print ret 
        #ecs.otcOutputHandler().print_output(ret,  mainkey = "volumes", listkey= {"id", "name", "volume_type", "size", "status", "bootable", "availability_zone", "limit", "attachments", "source_volid", "snapshot_id", "description", "created_at"})
        return ret
コード例 #48
0
    def describe_instance():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID + "/instances"
        url = url.replace('iam', 'dcs')
        ret = utils_http.get(url + '/' + OtcConfig.INSTANCE_ID)
        print(url + '/' + OtcConfig.INSTANCE_ID)
        #print (ret)
        dcs.otcOutputHandler().print_output(ret, mainkey="")

        return ret
コード例 #49
0
 def describe_auto_scaling_groups_details():
     if not (OtcConfig.SCALINGGROUP_NAME is None):
         autoscaling.convertASNameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group/" + OtcConfig.SCALINGGROUP_ID
     ret = utils_http.get(url)
     autoscaling.otcOutputHandler().print_output(ret,
                                                 mainkey="scaling_group"#,listkey={"instance_terminate_policy","is_scaling"}
                                                 )
     return ret
コード例 #50
0
 def list_services():
     if OtcConfig.CLUSTER:
         cce.convertClusterNameToId()
     url = "https://" + OtcConfig.DEFAULT_HOST + "/api/v1/services"
     ret = utils_http.get(url)
     
     print (ret)
     cce.otcOutputHandler().print_output(ret,mainkey="")     
     return ret
コード例 #51
0
    def list_instances():
        url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.0/" + OtcConfig.PROJECT_ID +  "/instances"
        url = url.replace('iam', 'dcs')
        ret = utils_http.get(url)
        #print (url)
        #print (ret)
        dcs.otcOutputHandler().print_output(ret, mainkey = "instances", listkey={"instance_id", "name", "capacity","ip","port","used_memory","max_memory","resource_spec_code","engine_version","status","created_at"})

        return ret
コード例 #52
0
 def convertASNameToId():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_group"
     JSON = utils_http.get(url)
     parsed = json.loads(JSON)
     autoscalings = parsed["scaling_groups"]
     ret = None
     for s in autoscalings:
         if s.get("scaling_group_name") == OtcConfig.SCALINGGROUP_NAME:
             ret = s["scaling_group_id"]
     OtcConfig.SCALINGGROUP_ID = ret
コード例 #53
0
    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)

        elb.otcOutputHandler().print_output(ret,mainkey="")
        return ret
コード例 #54
0
 def convertDATASOURCENameToId():
     url = "https://" + OtcConfig.DEFAULT_HOST + "/v1.1/" + OtcConfig.PROJECT_ID + "/data-sources"
     JSON = utils_http.get(url)
     parsed = json.loads(JSON)
     servers = parsed["data_sources"]
     ret = None
     for server in servers:
         if server.get("name") == OtcConfig.DATASOURCE:
             ret = server["id"]
     OtcConfig.DATASOURCE_ID = ret
コード例 #55
0
    def describe_policy_details():
        if not (OtcConfig.SCALING_POLICY_NAME is None):
            autoscaling.convertASPolicyNameToId()

        print(OtcConfig.SCALING_POLICY_ID)
        url = "https://" + OtcConfig.DEFAULT_HOST + "/autoscaling-api/v1/" + OtcConfig.PROJECT_ID + "/scaling_policy/" + OtcConfig.SCALING_POLICY_ID
        ret = utils_http.get(url)
        #autoscaling.otcOutputHandler().print_output(ret, mainkey="scaling_policy",                                                     listkey={"scaling_policy_id", "scaling_group_id"})
        autoscaling.otcOutputHandler().print_output(ret,mainkey="")
        return ret