You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by GitBox <gi...@apache.org> on 2021/09/29 13:24:55 UTC

[GitHub] [cloudstack-go] Pearl1594 opened a new pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Pearl1594 opened a new pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9


   Modified - generate.go & layout.go
   Remaining changes were made by running:
   ` ./generate -api listApis.json `
   
   Tested these changes by running a sample application to perform operations like listHosts, prepareHostForMaintenance, CancelHostForMaintenance,  etc..


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] Pearl1594 commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
Pearl1594 commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-931137315


   Script used to run tests - details of qa server added:
   ```
   package main
   
   import (
   	"encoding/json"
   	"github.com/apache/cloudstack-go/v2/cloudstack"
   	"log"
   )
   
   func main() {
   	apiUrl := "http://qa.cloudstack.cloud:8080/client/api"
   	secretKey := "PZAM4nrxKbMnlq8RT0GMqAJyYtJGMN5x-PN7owa9vSmE58zObTcn4Yc8pgLeznln1aEUkHH_d2S-QQTt3E2Azw"
   	apiKey := "DN7uIwbqAMASSB1GUGHWvXqUlDDBf7H6A3XI-kNeXahW5LMUoqgfDEDWMv8zWKaj51fDozg8fjqc7tGCSozScA"
   	zoneId := "b6afade4-1919-4f0b-a785-12ff05a4d383"
   
   
   	cs := cloudstack.NewAsyncClient(apiUrl, apiKey, secretKey, false)
   	zone, _, err := cs.Zone.GetZoneByID(zoneId)
   	if err != nil {
   		log.Fatalf("Failed to find zone: %v", err)
   		return
   	}
   
   	if zone.Resourcedetails["resourceHAEnabled"] == "true" {
   		log.Printf("High Availability enabled for zone: %s. Attempting to disable it", zoneId)
   		zoneHAParams := &cloudstack.DisableHAForZoneParams{}
   		zoneHAParams.SetZoneid(zone.Id)
   		resp, err := cs.Zone.DisableHAForZone(zoneHAParams)
   		if err != nil {
   			log.Fatalf("Failed to disable HA for zone due to: %v", err)
   			return
   		}
   		log.Printf("HA for zone - disabled? : %v", resp.Success )
   	}
   
   	if zone.Resourcedetails["resourceHAEnabled"] == "false" {
   		log.Printf("High Availability disabled for zone: %s. Attempting to enable it", zoneId)
   		zoneHAParams := &cloudstack.EnableHAForZoneParams{}
   		zoneHAParams.SetZoneid(zone.Id)
   		resp, err := cs.Zone.EnableHAForZone(zoneHAParams)
   		if err != nil {
   			log.Fatalf("Failed to enable HA for zone due to: %v", err)
   			return
   		}
   		log.Printf("HA for zone - enabled? : %v", resp.Success )
   	}
   
   	p := &cloudstack.ListHostsParams{}
   	p.SetZoneid(zoneId)
   	hosts, err := cs.Host.ListHosts(p)
   	if err != nil {
   		log.Fatalf("Failed to list all hosts in zone: %s due to: %v", zone.Name, err)
   		return
   	}
   	for _, host := range hosts.Hosts {
   		log.Printf("Host - Name: %s \t Host - HA Response: %v", host.Name, host.Hostha)
   	}
   
   	host := hosts.Hosts[0]
   	log.Println(host.Resourcestate)
   	if host.Resourcestate == "Enabled" {
   		log.Printf("Prepare host %s for maintenance", host.Name)
   		prepHostMnt := &cloudstack.PrepareHostForMaintenanceParams{}
   		prepHostMnt.SetId(host.Id)
   		resp, err := cs.Host.PrepareHostForMaintenance(prepHostMnt)
   		if err != nil {
   			log.Fatalf("Failed to prepare host %s for maintenance due to: %v", host.Name, err)
   			return
   		}
   		b, err := json.MarshalIndent(resp, "", "    ")
   		if err != nil {
   			log.Printf("%v", err)
   			return
   		}
   		log.Printf("Host response : %v", string(b))
   	}
   
   	if host.Resourcestate == "Maintenance" {
   		log.Printf("Cancelinng host for maintenance on host: %s", host.Name)
   		cancelHostMnt := &cloudstack.CancelHostMaintenanceParams{}
   		cancelHostMnt.SetId(host.Id)
   		resp, err := cs.Host.CancelHostMaintenance(cancelHostMnt)
   		if err != nil {
   			log.Fatalf("Failed to cancel host for maintenance on %s due to: %v", host.Name, err)
   			return
   		}
   		b, err := json.MarshalIndent(resp, "", "    ")
   		if err != nil {
   			log.Printf("%v", err)
   			return
   		}
   		log.Printf("Host response : %v", string(b))
   	}
   }
   
   ```
   
   #### Output:
   ```
   2021/09/30 15:00:23 High Availability enabled for zone: b6afade4-1919-4f0b-a785-12ff05a4d383. Attempting to disable it
   2021/09/30 15:00:23 HA for zone - disabled? : false
   2021/09/30 15:00:24 Host - Name: SimulatedAgent.200634f3-68d0-48ca-89d2-9630e2df1ac4     Host - HA Response: {false  Disabled   0 false}
   2021/09/30 15:00:24 Host - Name: SimulatedAgent.f3c875a9-6f08-4df1-a079-c8995eaccfa0     Host - HA Response: {false  Disabled   0 false}
   2021/09/30 15:00:24 Host - Name: SimulatedAgent.2a1689d9-778d-49f4-ab85-87f2d8c88bcb     Host - HA Response: {false  Disabled   0 false}
   2021/09/30 15:00:24 Host - Name: s-143-QA        Host - HA Response: {false  Disabled   0 false}
   2021/09/30 15:00:24 Host - Name: s-143-QA        Host - HA Response: {false  Disabled   0 false}
   2021/09/30 15:00:24 Maintenance
   2021/09/30 15:00:24 Cancelinng host for maintenance on host: SimulatedAgent.200634f3-68d0-48ca-89d2-9630e2df1ac4
   2021/09/30 15:00:24 Host response : {
       "annotation": "",
       "capabilities": "hvm",
       "clusterid": "363676ef-b414-442c-97eb-231987beedf6",
       "clustername": "DemoClusterSIG",
       "clustertype": "CloudManaged",
       "cpuallocated": "0%",
       "cpuallocatedpercentage": "0%",
       "cpuallocatedvalue": 0,
       "cpuallocatedwithoverprovisioning": "0%",
       "cpuloadaverage": 0,
       "cpunumber": 4,
       "cpusockets": 0,
       "cpuspeed": 8000,
       "cpuused": "0%",
       "cpuwithoverprovisioning": "32000",
       "created": "2020-03-30T10:07:58+0000",
       "details": null,
       "disconnected": "2021-09-28T20:05:04+0000",
       "disksizeallocated": 0,
       "disksizetotal": 0,
       "events": "Ping; ShutdownRequested; PingTimeout; ManagementServerDown; AgentConnected; AgentDisconnected; Remove; StartAgentRebalance; HostDown",
       "gpugroup": null,
       "hahost": false,
       "hasenoughcapacity": false,
       "hostha": {                                                               <----- Host HA response
           "haenable": false,
           "haprovider": "",
           "hastate": "Disabled",
           "hostid": "",
           "jobid": "",
           "jobstatus": 0,
           "status": false
       },
       "hosttags": "null",
       "hypervisor": "Simulator",
       "hypervisorversion": "4.14.0.0-SNAPSHOT",
       "id": "4f944183-7cfe-41c7-a34c-b7230bb503d5",
       "ipaddress": "172.23.1.13",
       "islocalstorageactive": false,
       "jobid": "75b78ba4-2481-4bc7-9cb9-90118605e624",
       "jobstatus": 0,
       "lastannotated": "",
       "lastpinged": "1970-01-19T10:58:30+0000",
       "managementserverid": "18c349c6-ed36-4890-b670-4ef76e48485e",
       "memoryallocated": 0,
       "memoryallocatedbytes": 0,
       "memoryallocatedpercentage": "0%",
       "memorytotal": 8589934592,
       "memoryused": 0,
       "memorywithoverprovisioning": "8589934592",
       "name": "SimulatedAgent.200634f3-68d0-48ca-89d2-9630e2df1ac4",
       "networkkbsread": 32768,
       "networkkbswrite": 16384,
       "oscategoryid": "e4992bed-5fdf-11ea-9a56-1e006800018c",
       "oscategoryname": "CentOS",
       "outofbandmanagement": {
           "action": "",
           "address": "",
           "description": "",
           "driver": "",
           "enabled": false,
           "hostid": "",
           "jobid": "",
           "jobstatus": 0,
           "password": "",
           "port": "",
           "powerstate": "Disabled",
           "status": false,
           "username": ""
       },
       "podid": "83a739b7-bf5f-481e-8016-3a6045045e0b",
       "podname": "DemoSIGPod",
       "removed": "",
       "resourcestate": "Enabled",
       "state": "Up",
       "suitableformigration": false,
       "type": "Routing",
       "ueficapability": false,
       "username": "",
       "version": "4.14.0.0-SNAPSHOT",
       "zoneid": "b6afade4-1919-4f0b-a785-12ff05a4d383",
       "zonename": "DemoSIGZone"
   }
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] rhtyd commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-930362702


   Does this PR also address https://github.com/apache/cloudstack-go/issues/8? 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] rhtyd commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-930362223


   Thanks @Pearl1594 I'll review and test it tomorrow 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] Pearl1594 commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
Pearl1594 commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-930779660


   yes @rhtyd - It attempts to address #8 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] rhtyd merged pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
rhtyd merged pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] rhtyd commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-930782803


   Thanks @Pearl1594 I'll test and merge it today 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [cloudstack-go] rhtyd commented on pull request #9: Modify (auto)generate code to handle API parameter type changes - 4.15.2

Posted by GitBox <gi...@apache.org>.
rhtyd commented on pull request #9:
URL: https://github.com/apache/cloudstack-go/pull/9#issuecomment-930362223






-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: dev-unsubscribe@cloudstack.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org