From 5cd72f642b71e82e26ff2addf28355faed5a091f Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Tue, 1 Dec 2015 00:37:48 +0100 Subject: [PATCH 1/2] Improve async job handling and increase default timeout --- cloudstack/AccountService.go | 50 ++--- cloudstack/AddressService.go | 30 ++- cloudstack/AffinityGroupService.go | 30 ++- cloudstack/AlertService.go | 10 +- cloudstack/AsyncjobService.go | 6 +- cloudstack/AutoScaleService.go | 150 ++++++--------- cloudstack/BaremetalService.go | 30 ++- cloudstack/BigSwitchVNSService.go | 20 +- cloudstack/CertificateService.go | 10 +- cloudstack/ClusterService.go | 20 +- cloudstack/DomainService.go | 10 +- cloudstack/FirewallService.go | 120 +++++------- cloudstack/GuestOSService.go | 60 +++--- cloudstack/HostService.go | 60 +++--- cloudstack/ISOService.go | 50 ++--- cloudstack/InternalLBService.go | 40 ++-- cloudstack/LoadBalancerService.go | 240 ++++++++++-------------- cloudstack/NATService.go | 30 ++- cloudstack/NetworkACLService.go | 70 +++---- cloudstack/NetworkService.go | 120 +++++------- cloudstack/NicService.go | 20 +- cloudstack/NiciraNVPService.go | 20 +- cloudstack/OvsElementService.go | 10 +- cloudstack/PodService.go | 20 +- cloudstack/PortableIPService.go | 20 +- cloudstack/ProjectService.go | 70 +++---- cloudstack/ResourcemetadataService.go | 20 +- cloudstack/ResourcetagsService.go | 20 +- cloudstack/RouterService.go | 60 +++--- cloudstack/SSHService.go | 10 +- cloudstack/SecurityGroupService.go | 40 ++-- cloudstack/SnapshotService.go | 70 +++---- cloudstack/StoragePoolService.go | 20 +- cloudstack/SystemVMService.go | 60 +++--- cloudstack/TemplateService.go | 40 ++-- cloudstack/UCSService.go | 10 +- cloudstack/UsageService.go | 30 ++- cloudstack/UserService.go | 10 +- cloudstack/VLANService.go | 10 +- cloudstack/VPCService.go | 110 +++++------ cloudstack/VPNService.go | 150 ++++++--------- cloudstack/VirtualMachineService.go | 150 ++++++--------- cloudstack/VolumeService.go | 80 ++++---- cloudstack/ZoneService.go | 20 +- cloudstack/cloudstack.go | 23 ++- cloudstack43/AccountService.go | 50 ++--- cloudstack43/AddressService.go | 20 +- cloudstack43/AffinityGroupService.go | 30 ++- cloudstack43/AlertService.go | 10 +- cloudstack43/AsyncjobService.go | 6 +- cloudstack43/AutoScaleService.go | 150 ++++++--------- cloudstack43/BaremetalService.go | 30 ++- cloudstack43/BigSwitchVNSService.go | 20 +- cloudstack43/CertificateService.go | 10 +- cloudstack43/ClusterService.go | 20 +- cloudstack43/DomainService.go | 10 +- cloudstack43/ExternalDeviceService.go | 30 ++- cloudstack43/FirewallService.go | 130 +++++-------- cloudstack43/HostService.go | 60 +++--- cloudstack43/ISOService.go | 50 ++--- cloudstack43/InternalLBService.go | 40 ++-- cloudstack43/LoadBalancerService.go | 240 ++++++++++-------------- cloudstack43/NATService.go | 30 ++- cloudstack43/NetworkACLService.go | 60 +++--- cloudstack43/NetworkService.go | 120 +++++------- cloudstack43/NicService.go | 20 +- cloudstack43/NiciraNVPService.go | 20 +- cloudstack43/PodService.go | 20 +- cloudstack43/PortableIPService.go | 20 +- cloudstack43/ProjectService.go | 70 +++---- cloudstack43/ResourcemetadataService.go | 20 +- cloudstack43/ResourcetagsService.go | 20 +- cloudstack43/RouterService.go | 60 +++--- cloudstack43/SSHService.go | 10 +- cloudstack43/SecurityGroupService.go | 40 ++-- cloudstack43/SnapshotService.go | 60 +++--- cloudstack43/StoragePoolService.go | 20 +- cloudstack43/SystemVMService.go | 60 +++--- cloudstack43/TemplateService.go | 50 ++--- cloudstack43/UCSService.go | 20 +- cloudstack43/UsageService.go | 30 ++- cloudstack43/UserService.go | 10 +- cloudstack43/VLANService.go | 10 +- cloudstack43/VPCService.go | 110 +++++------ cloudstack43/VPNService.go | 120 +++++------- cloudstack43/VirtualMachineService.go | 150 ++++++--------- cloudstack43/VolumeService.go | 80 ++++---- cloudstack43/ZoneService.go | 20 +- cloudstack43/cloudstack.go | 23 ++- cloudstack44/AccountService.go | 50 ++--- cloudstack44/AddressService.go | 30 ++- cloudstack44/AffinityGroupService.go | 30 ++- cloudstack44/AlertService.go | 10 +- cloudstack44/AsyncjobService.go | 6 +- cloudstack44/AutoScaleService.go | 150 ++++++--------- cloudstack44/BaremetalService.go | 30 ++- cloudstack44/BigSwitchVNSService.go | 20 +- cloudstack44/CertificateService.go | 10 +- cloudstack44/ClusterService.go | 20 +- cloudstack44/DomainService.go | 10 +- cloudstack44/FirewallService.go | 120 +++++------- cloudstack44/GuestOSService.go | 60 +++--- cloudstack44/HostService.go | 60 +++--- cloudstack44/ISOService.go | 50 ++--- cloudstack44/InternalLBService.go | 40 ++-- cloudstack44/LoadBalancerService.go | 240 ++++++++++-------------- cloudstack44/NATService.go | 30 ++- cloudstack44/NetworkACLService.go | 70 +++---- cloudstack44/NetworkService.go | 120 +++++------- cloudstack44/NicService.go | 20 +- cloudstack44/NiciraNVPService.go | 20 +- cloudstack44/OvsElementService.go | 10 +- cloudstack44/PodService.go | 20 +- cloudstack44/PortableIPService.go | 20 +- cloudstack44/ProjectService.go | 70 +++---- cloudstack44/ResourcemetadataService.go | 20 +- cloudstack44/ResourcetagsService.go | 20 +- cloudstack44/RouterService.go | 60 +++--- cloudstack44/SSHService.go | 10 +- cloudstack44/SecurityGroupService.go | 40 ++-- cloudstack44/SnapshotService.go | 70 +++---- cloudstack44/StoragePoolService.go | 20 +- cloudstack44/SystemVMService.go | 60 +++--- cloudstack44/TemplateService.go | 40 ++-- cloudstack44/UCSService.go | 10 +- cloudstack44/UsageService.go | 30 ++- cloudstack44/UserService.go | 10 +- cloudstack44/VLANService.go | 10 +- cloudstack44/VPCService.go | 110 +++++------ cloudstack44/VPNService.go | 150 ++++++--------- cloudstack44/VirtualMachineService.go | 150 ++++++--------- cloudstack44/VolumeService.go | 80 ++++---- cloudstack44/ZoneService.go | 20 +- cloudstack44/cloudstack.go | 23 ++- generate/generate.go | 46 +++-- 135 files changed, 2713 insertions(+), 4010 deletions(-) diff --git a/cloudstack/AccountService.go b/cloudstack/AccountService.go index 3e6c7a2..3c55ac0 100644 --- a/cloudstack/AccountService.go +++ b/cloudstack/AccountService.go @@ -333,15 +333,13 @@ func (s *AccountService) DeleteAccount(p *DeleteAccountParams) (*DeleteAccountRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -616,15 +614,13 @@ func (s *AccountService) DisableAccount(p *DisableAccountParams) (*DisableAccoun // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1367,15 +1363,13 @@ func (s *AccountService) MarkDefaultZoneForAccount(p *MarkDefaultZoneForAccountP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1532,15 +1526,13 @@ func (s *AccountService) AddAccountToProject(p *AddAccountToProjectParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1613,15 +1605,13 @@ func (s *AccountService) DeleteAccountFromProject(p *DeleteAccountFromProjectPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/AddressService.go b/cloudstack/AddressService.go index 5181766..fb5c586 100644 --- a/cloudstack/AddressService.go +++ b/cloudstack/AddressService.go @@ -160,15 +160,13 @@ func (s *AddressService) AssociateIpAddress(p *AssociateIpAddressParams) (*Assoc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -273,15 +271,13 @@ func (s *AddressService) DisassociateIpAddress(p *DisassociateIpAddressParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -747,15 +743,13 @@ func (s *AddressService) UpdateIpAddress(p *UpdateIpAddressParams) (*UpdateIpAdd // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/AffinityGroupService.go b/cloudstack/AffinityGroupService.go index 12ee8d5..fd36305 100644 --- a/cloudstack/AffinityGroupService.go +++ b/cloudstack/AffinityGroupService.go @@ -115,15 +115,13 @@ func (s *AffinityGroupService) CreateAffinityGroup(p *CreateAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -227,15 +225,13 @@ func (s *AffinityGroupService) DeleteAffinityGroup(p *DeleteAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -566,15 +562,13 @@ func (s *AffinityGroupService) UpdateVMAffinityGroup(p *UpdateVMAffinityGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/AlertService.go b/cloudstack/AlertService.go index e23b3f5..2cfd4b2 100644 --- a/cloudstack/AlertService.go +++ b/cloudstack/AlertService.go @@ -471,15 +471,13 @@ func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/AsyncjobService.go b/cloudstack/AsyncjobService.go index a78402b..348830c 100644 --- a/cloudstack/AsyncjobService.go +++ b/cloudstack/AsyncjobService.go @@ -20,6 +20,7 @@ import ( "encoding/json" "net/url" "strconv" + "time" ) type QueryAsyncJobResultParams struct { @@ -62,9 +63,10 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu // We should be able to retry on failure as this call is idempotent for i := 0; i < 3; i++ { resp, err = s.cs.newRequest("queryAsyncJobResult", p.toURLValues()) - if err != nil { - continue + if err == nil { + break } + time.Sleep(1 * time.Second) } if err != nil { return nil, err diff --git a/cloudstack/AutoScaleService.go b/cloudstack/AutoScaleService.go index 76a8227..65a1d2e 100644 --- a/cloudstack/AutoScaleService.go +++ b/cloudstack/AutoScaleService.go @@ -94,15 +94,13 @@ func (s *AutoScaleService) CreateCounter(p *CreateCounterParams) (*CreateCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -218,15 +216,13 @@ func (s *AutoScaleService) CreateCondition(p *CreateConditionParams) (*CreateCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -338,15 +334,13 @@ func (s *AutoScaleService) CreateAutoScalePolicy(p *CreateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -506,15 +500,13 @@ func (s *AutoScaleService) CreateAutoScaleVmProfile(p *CreateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -679,15 +671,13 @@ func (s *AutoScaleService) CreateAutoScaleVmGroup(p *CreateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -766,15 +756,13 @@ func (s *AutoScaleService) DeleteCounter(p *DeleteCounterParams) (*DeleteCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -835,15 +823,13 @@ func (s *AutoScaleService) DeleteCondition(p *DeleteConditionParams) (*DeleteCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -904,15 +890,13 @@ func (s *AutoScaleService) DeleteAutoScalePolicy(p *DeleteAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -973,15 +957,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmProfile(p *DeleteAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1042,15 +1024,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmGroup(p *DeleteAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2208,15 +2188,13 @@ func (s *AutoScaleService) EnableAutoScaleVmGroup(p *EnableAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2295,15 +2273,13 @@ func (s *AutoScaleService) DisableAutoScaleVmGroup(p *DisableAutoScaleVmGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2418,15 +2394,13 @@ func (s *AutoScaleService) UpdateAutoScalePolicy(p *UpdateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2573,15 +2547,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmProfile(p *UpdateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2741,15 +2713,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmGroup(p *UpdateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/BaremetalService.go b/cloudstack/BaremetalService.go index f4bfadb..a37aa1c 100644 --- a/cloudstack/BaremetalService.go +++ b/cloudstack/BaremetalService.go @@ -139,15 +139,13 @@ func (s *BaremetalService) AddBaremetalPxeKickStartServer(p *AddBaremetalPxeKick // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -329,15 +327,13 @@ func (s *BaremetalService) AddBaremetalPxePingServer(p *AddBaremetalPxePingServe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -452,15 +448,13 @@ func (s *BaremetalService) AddBaremetalDhcp(p *AddBaremetalDhcpParams) (*AddBare // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/BigSwitchVNSService.go b/cloudstack/BigSwitchVNSService.go index cccbcf5..f6bc551 100644 --- a/cloudstack/BigSwitchVNSService.go +++ b/cloudstack/BigSwitchVNSService.go @@ -80,15 +80,13 @@ func (s *BigSwitchVNSService) AddBigSwitchVnsDevice(p *AddBigSwitchVnsDevicePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -157,15 +155,13 @@ func (s *BigSwitchVNSService) DeleteBigSwitchVnsDevice(p *DeleteBigSwitchVnsDevi // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/CertificateService.go b/cloudstack/CertificateService.go index 75ab92f..dc125a0 100644 --- a/cloudstack/CertificateService.go +++ b/cloudstack/CertificateService.go @@ -114,15 +114,13 @@ func (s *CertificateService) UploadCustomCertificate(p *UploadCustomCertificateP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/ClusterService.go b/cloudstack/ClusterService.go index 2045c6d..24d0214 100644 --- a/cloudstack/ClusterService.go +++ b/cloudstack/ClusterService.go @@ -786,15 +786,13 @@ func (s *ClusterService) DedicateCluster(p *DedicateClusterParams) (*DedicateClu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -864,15 +862,13 @@ func (s *ClusterService) ReleaseDedicatedCluster(p *ReleaseDedicatedClusterParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/DomainService.go b/cloudstack/DomainService.go index f8594b0..8839764 100644 --- a/cloudstack/DomainService.go +++ b/cloudstack/DomainService.go @@ -251,15 +251,13 @@ func (s *DomainService) DeleteDomain(p *DeleteDomainParams) (*DeleteDomainRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/FirewallService.go b/cloudstack/FirewallService.go index 96c6806..08cb564 100644 --- a/cloudstack/FirewallService.go +++ b/cloudstack/FirewallService.go @@ -467,15 +467,13 @@ func (s *FirewallService) CreatePortForwardingRule(p *CreatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -567,15 +565,13 @@ func (s *FirewallService) DeletePortForwardingRule(p *DeletePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -725,15 +721,13 @@ func (s *FirewallService) UpdatePortForwardingRule(p *UpdatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -920,15 +914,13 @@ func (s *FirewallService) CreateFirewallRule(p *CreateFirewallRuleParams) (*Crea // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1016,15 +1008,13 @@ func (s *FirewallService) DeleteFirewallRule(p *DeleteFirewallRuleParams) (*Dele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1369,15 +1359,13 @@ func (s *FirewallService) UpdateFirewallRule(p *UpdateFirewallRuleParams) (*Upda // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1560,15 +1548,13 @@ func (s *FirewallService) CreateEgressFirewallRule(p *CreateEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1656,15 +1642,13 @@ func (s *FirewallService) DeleteEgressFirewallRule(p *DeleteEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2015,15 +1999,13 @@ func (s *FirewallService) UpdateEgressFirewallRule(p *UpdateEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2159,15 +2141,13 @@ func (s *FirewallService) AddPaloAltoFirewall(p *AddPaloAltoFirewallParams) (*Ad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2247,15 +2227,13 @@ func (s *FirewallService) DeletePaloAltoFirewall(p *DeletePaloAltoFirewallParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2328,15 +2306,13 @@ func (s *FirewallService) ConfigurePaloAltoFirewall(p *ConfigurePaloAltoFirewall // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/GuestOSService.go b/cloudstack/GuestOSService.go index eebb6ae..1cbff4d 100644 --- a/cloudstack/GuestOSService.go +++ b/cloudstack/GuestOSService.go @@ -406,15 +406,13 @@ func (s *GuestOSService) AddGuestOs(p *AddGuestOsParams) (*AddGuestOsResponse, e // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -494,15 +492,13 @@ func (s *GuestOSService) UpdateGuestOs(p *UpdateGuestOsParams) (*UpdateGuestOsRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -570,15 +566,13 @@ func (s *GuestOSService) RemoveGuestOs(p *RemoveGuestOsParams) (*RemoveGuestOsRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -840,15 +834,13 @@ func (s *GuestOSService) AddGuestOsMapping(p *AddGuestOsMappingParams) (*AddGues // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -931,15 +923,13 @@ func (s *GuestOSService) UpdateGuestOsMapping(p *UpdateGuestOsMappingParams) (*U // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1010,15 +1000,13 @@ func (s *GuestOSService) RemoveGuestOsMapping(p *RemoveGuestOsMappingParams) (*R // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/HostService.go b/cloudstack/HostService.go index b6cb0c4..427f278 100644 --- a/cloudstack/HostService.go +++ b/cloudstack/HostService.go @@ -281,15 +281,13 @@ func (s *HostService) ReconnectHost(p *ReconnectHostParams) (*ReconnectHostRespo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -636,15 +634,13 @@ func (s *HostService) PrepareHostForMaintenance(p *PrepareHostForMaintenancePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -765,15 +761,13 @@ func (s *HostService) CancelHostMaintenance(p *CancelHostMaintenanceParams) (*Ca // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1515,15 +1509,13 @@ func (s *HostService) ReleaseHostReservation(p *ReleaseHostReservationParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1829,15 +1821,13 @@ func (s *HostService) DedicateHost(p *DedicateHostParams) (*DedicateHostResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1907,15 +1897,13 @@ func (s *HostService) ReleaseDedicatedHost(p *ReleaseDedicatedHostParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/ISOService.go b/cloudstack/ISOService.go index 5e34a51..62348a7 100644 --- a/cloudstack/ISOService.go +++ b/cloudstack/ISOService.go @@ -82,15 +82,13 @@ func (s *ISOService) AttachIso(p *AttachIsoParams) (*AttachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -321,15 +319,13 @@ func (s *ISOService) DetachIso(p *DetachIsoParams) (*DetachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1443,15 +1439,13 @@ func (s *ISOService) DeleteIso(p *DeleteIsoParams) (*DeleteIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1535,15 +1529,13 @@ func (s *ISOService) CopyIso(p *CopyIsoParams) (*CopyIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1897,15 +1889,13 @@ func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/InternalLBService.go b/cloudstack/InternalLBService.go index d23bd24..b4fceda 100644 --- a/cloudstack/InternalLBService.go +++ b/cloudstack/InternalLBService.go @@ -83,15 +83,13 @@ func (s *InternalLBService) ConfigureInternalLoadBalancerElement(p *ConfigureInt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -158,15 +156,13 @@ func (s *InternalLBService) CreateInternalLoadBalancerElement(p *CreateInternalL // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -386,15 +382,13 @@ func (s *InternalLBService) StopInternalLoadBalancerVM(p *StopInternalLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -523,15 +517,13 @@ func (s *InternalLBService) StartInternalLoadBalancerVM(p *StartInternalLoadBala // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/LoadBalancerService.go b/cloudstack/LoadBalancerService.go index 75df7dd..03d1ec4 100644 --- a/cloudstack/LoadBalancerService.go +++ b/cloudstack/LoadBalancerService.go @@ -221,15 +221,13 @@ func (s *LoadBalancerService) CreateLoadBalancerRule(p *CreateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -324,15 +322,13 @@ func (s *LoadBalancerService) DeleteLoadBalancerRule(p *DeleteLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -421,15 +417,13 @@ func (s *LoadBalancerService) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -518,15 +512,13 @@ func (s *LoadBalancerService) AssignToLoadBalancerRule(p *AssignToLoadBalancerRu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -650,15 +642,13 @@ func (s *LoadBalancerService) CreateLBStickinessPolicy(p *CreateLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -762,15 +752,13 @@ func (s *LoadBalancerService) UpdateLBStickinessPolicy(p *UpdateLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -851,15 +839,13 @@ func (s *LoadBalancerService) DeleteLBStickinessPolicy(p *DeleteLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1666,15 +1652,13 @@ func (s *LoadBalancerService) CreateLBHealthCheckPolicy(p *CreateLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1777,15 +1761,13 @@ func (s *LoadBalancerService) UpdateLBHealthCheckPolicy(p *UpdateLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1865,15 +1847,13 @@ func (s *LoadBalancerService) DeleteLBHealthCheckPolicy(p *DeleteLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2133,15 +2113,13 @@ func (s *LoadBalancerService) UpdateLoadBalancerRule(p *UpdateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2521,15 +2499,13 @@ func (s *LoadBalancerService) AssignCertToLoadBalancer(p *AssignCertToLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2590,15 +2566,13 @@ func (s *LoadBalancerService) RemoveCertFromLoadBalancer(p *RemoveCertFromLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2753,15 +2727,13 @@ func (s *LoadBalancerService) AddNetscalerLoadBalancer(p *AddNetscalerLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2840,15 +2812,13 @@ func (s *LoadBalancerService) DeleteNetscalerLoadBalancer(p *DeleteNetscalerLoad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2957,15 +2927,13 @@ func (s *LoadBalancerService) ConfigureNetscalerLoadBalancer(p *ConfigureNetscal // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3250,15 +3218,13 @@ func (s *LoadBalancerService) CreateGlobalLoadBalancerRule(p *CreateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3368,15 +3334,13 @@ func (s *LoadBalancerService) DeleteGlobalLoadBalancerRule(p *DeleteGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3470,15 +3434,13 @@ func (s *LoadBalancerService) UpdateGlobalLoadBalancerRule(p *UpdateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3932,15 +3894,13 @@ func (s *LoadBalancerService) AssignToGlobalLoadBalancerRule(p *AssignToGlobalLo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4014,15 +3974,13 @@ func (s *LoadBalancerService) RemoveFromGlobalLoadBalancerRule(p *RemoveFromGlob // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4191,15 +4149,13 @@ func (s *LoadBalancerService) CreateLoadBalancer(p *CreateLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4659,15 +4615,13 @@ func (s *LoadBalancerService) DeleteLoadBalancer(p *DeleteLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4751,15 +4705,13 @@ func (s *LoadBalancerService) UpdateLoadBalancer(p *UpdateLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/NATService.go b/cloudstack/NATService.go index 549c620..25ad9a1 100644 --- a/cloudstack/NATService.go +++ b/cloudstack/NATService.go @@ -216,15 +216,13 @@ func (s *NATService) CreateIpForwardingRule(p *CreateIpForwardingRuleParams) (*C // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -316,15 +314,13 @@ func (s *NATService) DeleteIpForwardingRule(p *DeleteIpForwardingRuleParams) (*D // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -622,15 +618,13 @@ func (s *NATService) DisableStaticNat(p *DisableStaticNatParams) (*DisableStatic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/NetworkACLService.go b/cloudstack/NetworkACLService.go index c4b1ff2..cc748f0 100644 --- a/cloudstack/NetworkACLService.go +++ b/cloudstack/NetworkACLService.go @@ -198,15 +198,13 @@ func (s *NetworkACLService) CreateNetworkACL(p *CreateNetworkACLParams) (*Create // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -423,15 +421,13 @@ func (s *NetworkACLService) UpdateNetworkACLItem(p *UpdateNetworkACLItemParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -520,15 +516,13 @@ func (s *NetworkACLService) DeleteNetworkACL(p *DeleteNetworkACLParams) (*Delete // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -919,15 +913,13 @@ func (s *NetworkACLService) CreateNetworkACLList(p *CreateNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -996,15 +988,13 @@ func (s *NetworkACLService) DeleteNetworkACLList(p *DeleteNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1087,15 +1077,13 @@ func (s *NetworkACLService) ReplaceNetworkACLList(p *ReplaceNetworkACLListParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1470,15 +1458,13 @@ func (s *NetworkACLService) UpdateNetworkACLList(p *UpdateNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/NetworkService.go b/cloudstack/NetworkService.go index 50b9b21..1e9bda4 100644 --- a/cloudstack/NetworkService.go +++ b/cloudstack/NetworkService.go @@ -628,15 +628,13 @@ func (s *NetworkService) DeleteNetwork(p *DeleteNetworkParams) (*DeleteNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1191,15 +1189,13 @@ func (s *NetworkService) RestartNetwork(p *RestartNetworkParams) (*RestartNetwor // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1394,15 +1390,13 @@ func (s *NetworkService) UpdateNetwork(p *UpdateNetworkParams) (*UpdateNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1621,15 +1615,13 @@ func (s *NetworkService) CreatePhysicalNetwork(p *CreatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1703,15 +1695,13 @@ func (s *NetworkService) DeletePhysicalNetwork(p *DeletePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2008,15 +1998,13 @@ func (s *NetworkService) UpdatePhysicalNetwork(p *UpdatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2239,15 +2227,13 @@ func (s *NetworkService) AddNetworkServiceProvider(p *AddNetworkServiceProviderP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2318,15 +2304,13 @@ func (s *NetworkService) DeleteNetworkServiceProvider(p *DeleteNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2557,15 +2541,13 @@ func (s *NetworkService) UpdateNetworkServiceProvider(p *UpdateNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2695,15 +2677,13 @@ func (s *NetworkService) CreateStorageNetworkIpRange(p *CreateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2776,15 +2756,13 @@ func (s *NetworkService) DeleteStorageNetworkIpRange(p *DeleteStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3036,15 +3014,13 @@ func (s *NetworkService) UpdateStorageNetworkIpRange(p *UpdateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/NicService.go b/cloudstack/NicService.go index 40c19a1..3ef49d6 100644 --- a/cloudstack/NicService.go +++ b/cloudstack/NicService.go @@ -79,15 +79,13 @@ func (s *NicService) AddIpToNic(p *AddIpToNicParams) (*AddIpToNicResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -156,15 +154,13 @@ func (s *NicService) RemoveIpFromNic(p *RemoveIpFromNicParams) (*RemoveIpFromNic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/NiciraNVPService.go b/cloudstack/NiciraNVPService.go index b361083..a4cb205 100644 --- a/cloudstack/NiciraNVPService.go +++ b/cloudstack/NiciraNVPService.go @@ -127,15 +127,13 @@ func (s *NiciraNVPService) AddNiciraNvpDevice(p *AddNiciraNvpDeviceParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -206,15 +204,13 @@ func (s *NiciraNVPService) DeleteNiciraNvpDevice(p *DeleteNiciraNvpDeviceParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/OvsElementService.go b/cloudstack/OvsElementService.go index a4f736d..3c81420 100644 --- a/cloudstack/OvsElementService.go +++ b/cloudstack/OvsElementService.go @@ -83,15 +83,13 @@ func (s *OvsElementService) ConfigureOvsElement(p *ConfigureOvsElementParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/PodService.go b/cloudstack/PodService.go index b910f01..f529190 100644 --- a/cloudstack/PodService.go +++ b/cloudstack/PodService.go @@ -645,15 +645,13 @@ func (s *PodService) DedicatePod(p *DedicatePodParams) (*DedicatePodResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -723,15 +721,13 @@ func (s *PodService) ReleaseDedicatedPod(p *ReleaseDedicatedPodParams) (*Release // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/PortableIPService.go b/cloudstack/PortableIPService.go index dc898e5..3dabf38 100644 --- a/cloudstack/PortableIPService.go +++ b/cloudstack/PortableIPService.go @@ -130,15 +130,13 @@ func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -221,15 +219,13 @@ func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/ProjectService.go b/cloudstack/ProjectService.go index d9848d5..b826868 100644 --- a/cloudstack/ProjectService.go +++ b/cloudstack/ProjectService.go @@ -104,15 +104,13 @@ func (s *ProjectService) CreateProject(p *CreateProjectParams) (*CreateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -230,15 +228,13 @@ func (s *ProjectService) DeleteProject(p *DeleteProjectParams) (*DeleteProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -321,15 +317,13 @@ func (s *ProjectService) UpdateProject(p *UpdateProjectParams) (*UpdateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -447,15 +441,13 @@ func (s *ProjectService) ActivateProject(p *ActivateProjectParams) (*ActivatePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -573,15 +565,13 @@ func (s *ProjectService) SuspendProject(p *SuspendProjectParams) (*SuspendProjec // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1259,15 +1249,13 @@ func (s *ProjectService) UpdateProjectInvitation(p *UpdateProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1328,15 +1316,13 @@ func (s *ProjectService) DeleteProjectInvitation(p *DeleteProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/ResourcemetadataService.go b/cloudstack/ResourcemetadataService.go index 12c36e1..e61b0ec 100644 --- a/cloudstack/ResourcemetadataService.go +++ b/cloudstack/ResourcemetadataService.go @@ -110,15 +110,13 @@ func (s *ResourcemetadataService) AddResourceDetail(p *AddResourceDetailParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -202,15 +200,13 @@ func (s *ResourcemetadataService) RemoveResourceDetail(p *RemoveResourceDetailPa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/ResourcetagsService.go b/cloudstack/ResourcetagsService.go index b6965ca..abfd862 100644 --- a/cloudstack/ResourcetagsService.go +++ b/cloudstack/ResourcetagsService.go @@ -111,15 +111,13 @@ func (s *ResourcetagsService) CreateTags(p *CreateTagsParams) (*CreateTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -209,15 +207,13 @@ func (s *ResourcetagsService) DeleteTags(p *DeleteTagsParams) (*DeleteTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/RouterService.go b/cloudstack/RouterService.go index 8d3dda1..6bd59e4 100644 --- a/cloudstack/RouterService.go +++ b/cloudstack/RouterService.go @@ -70,15 +70,13 @@ func (s *RouterService) StartRouter(p *StartRouterParams) (*StartRouterResponse, // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -207,15 +205,13 @@ func (s *RouterService) RebootRouter(p *RebootRouterParams) (*RebootRouterRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -356,15 +352,13 @@ func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -493,15 +487,13 @@ func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1332,15 +1324,13 @@ func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1423,15 +1413,13 @@ func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElement // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/SSHService.go b/cloudstack/SSHService.go index 3bb7f0e..eb97dfc 100644 --- a/cloudstack/SSHService.go +++ b/cloudstack/SSHService.go @@ -113,15 +113,13 @@ func (s *SSHService) ResetSSHKeyForVirtualMachine(p *ResetSSHKeyForVirtualMachin // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/SecurityGroupService.go b/cloudstack/SecurityGroupService.go index 8d5418e..282cd64 100644 --- a/cloudstack/SecurityGroupService.go +++ b/cloudstack/SecurityGroupService.go @@ -453,15 +453,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupIngress(p *AuthorizeSecurit // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -546,15 +544,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupIngress(p *RevokeSecurityGroup // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -745,15 +741,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupEgress(p *AuthorizeSecurity // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -838,15 +832,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupEgress(p *RevokeSecurityGroupE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/SnapshotService.go b/cloudstack/SnapshotService.go index 23af3af..0b23ad1 100644 --- a/cloudstack/SnapshotService.go +++ b/cloudstack/SnapshotService.go @@ -115,15 +115,13 @@ func (s *SnapshotService) CreateSnapshot(p *CreateSnapshotParams) (*CreateSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -555,15 +553,13 @@ func (s *SnapshotService) DeleteSnapshot(p *DeleteSnapshotParams) (*DeleteSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -763,15 +759,13 @@ func (s *SnapshotService) UpdateSnapshotPolicy(p *UpdateSnapshotPolicyParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1049,15 +1043,13 @@ func (s *SnapshotService) RevertSnapshot(p *RevertSnapshotParams) (*RevertSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1446,15 +1438,13 @@ func (s *SnapshotService) CreateVMSnapshot(p *CreateVMSnapshotParams) (*CreateVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1535,15 +1525,13 @@ func (s *SnapshotService) DeleteVMSnapshot(p *DeleteVMSnapshotParams) (*DeleteVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1604,15 +1592,13 @@ func (s *SnapshotService) RevertToVMSnapshot(p *RevertToVMSnapshotParams) (*Reve // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/StoragePoolService.go b/cloudstack/StoragePoolService.go index 7c82aff..e5a0f6a 100644 --- a/cloudstack/StoragePoolService.go +++ b/cloudstack/StoragePoolService.go @@ -159,15 +159,13 @@ func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -254,15 +252,13 @@ func (s *StoragePoolService) CancelStorageMaintenance(p *CancelStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/SystemVMService.go b/cloudstack/SystemVMService.go index a0cebbf..3536965 100644 --- a/cloudstack/SystemVMService.go +++ b/cloudstack/SystemVMService.go @@ -70,15 +70,13 @@ func (s *SystemVMService) StartSystemVm(p *StartSystemVmParams) (*StartSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -169,15 +167,13 @@ func (s *SystemVMService) RebootSystemVm(p *RebootSystemVmParams) (*RebootSystem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -280,15 +276,13 @@ func (s *SystemVMService) StopSystemVm(p *StopSystemVmParams) (*StopSystemVmResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -379,15 +373,13 @@ func (s *SystemVMService) DestroySystemVm(p *DestroySystemVmParams) (*DestroySys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -753,15 +745,13 @@ func (s *SystemVMService) MigrateSystemVm(p *MigrateSystemVmParams) (*MigrateSys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -984,15 +974,13 @@ func (s *SystemVMService) ScaleSystemVm(p *ScaleSystemVmParams) (*ScaleSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/TemplateService.go b/cloudstack/TemplateService.go index 56757c1..860e592 100644 --- a/cloudstack/TemplateService.go +++ b/cloudstack/TemplateService.go @@ -237,15 +237,13 @@ func (s *TemplateService) CreateTemplate(p *CreateTemplateParams) (*CreateTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -947,15 +945,13 @@ func (s *TemplateService) CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1077,15 +1073,13 @@ func (s *TemplateService) DeleteTemplate(p *DeleteTemplateParams) (*DeleteTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1753,15 +1747,13 @@ func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/UCSService.go b/cloudstack/UCSService.go index 21af540..5bf79c5 100644 --- a/cloudstack/UCSService.go +++ b/cloudstack/UCSService.go @@ -552,15 +552,13 @@ func (s *UCSService) AssociateUcsProfileToBlade(p *AssociateUcsProfileToBladePar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/UsageService.go b/cloudstack/UsageService.go index 02556ad..ea468e1 100644 --- a/cloudstack/UsageService.go +++ b/cloudstack/UsageService.go @@ -147,15 +147,13 @@ func (s *UsageService) AddTrafficType(p *AddTrafficTypeParams) (*AddTrafficTypeR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -226,15 +224,13 @@ func (s *UsageService) DeleteTrafficType(p *DeleteTrafficTypeParams) (*DeleteTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -466,15 +462,13 @@ func (s *UsageService) UpdateTrafficType(p *UpdateTrafficTypeParams) (*UpdateTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/UserService.go b/cloudstack/UserService.go index ffab577..e11e25f 100644 --- a/cloudstack/UserService.go +++ b/cloudstack/UserService.go @@ -712,15 +712,13 @@ func (s *UserService) DisableUser(p *DisableUserParams) (*DisableUserResponse, e // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/VLANService.go b/cloudstack/VLANService.go index 18f231f..38ebb01 100644 --- a/cloudstack/VLANService.go +++ b/cloudstack/VLANService.go @@ -725,15 +725,13 @@ func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/VPCService.go b/cloudstack/VPCService.go index b4f080e..2046559 100644 --- a/cloudstack/VPCService.go +++ b/cloudstack/VPCService.go @@ -186,15 +186,13 @@ func (s *VPCService) CreateVPC(p *CreateVPCParams) (*CreateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -867,15 +865,13 @@ func (s *VPCService) DeleteVPC(p *DeleteVPCParams) (*DeleteVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -981,15 +977,13 @@ func (s *VPCService) UpdateVPC(p *UpdateVPCParams) (*UpdateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1178,15 +1172,13 @@ func (s *VPCService) RestartVPC(p *RestartVPCParams) (*RestartVPCResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1443,15 +1435,13 @@ func (s *VPCService) CreateVPCOffering(p *CreateVPCOfferingParams) (*CreateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1573,15 +1563,13 @@ func (s *VPCService) UpdateVPCOffering(p *UpdateVPCOfferingParams) (*UpdateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1670,15 +1658,13 @@ func (s *VPCService) DeleteVPCOffering(p *DeleteVPCOfferingParams) (*DeleteVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2073,15 +2059,13 @@ func (s *VPCService) CreatePrivateGateway(p *CreatePrivateGatewayParams) (*Creat // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2410,15 +2394,13 @@ func (s *VPCService) DeletePrivateGateway(p *DeletePrivateGatewayParams) (*Delet // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2491,15 +2473,13 @@ func (s *VPCService) CreateStaticRoute(p *CreateStaticRouteParams) (*CreateStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2585,15 +2565,13 @@ func (s *VPCService) DeleteStaticRoute(p *DeleteStaticRouteParams) (*DeleteStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/VPNService.go b/cloudstack/VPNService.go index 9f8e5ad..37550c4 100644 --- a/cloudstack/VPNService.go +++ b/cloudstack/VPNService.go @@ -127,15 +127,13 @@ func (s *VPNService) CreateRemoteAccessVpn(p *CreateRemoteAccessVpnParams) (*Cre // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -211,15 +209,13 @@ func (s *VPNService) DeleteRemoteAccessVpn(p *DeleteRemoteAccessVpnParams) (*Del // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -536,15 +532,13 @@ func (s *VPNService) UpdateRemoteAccessVpn(p *UpdateRemoteAccessVpnParams) (*Upd // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -665,15 +659,13 @@ func (s *VPNService) AddVpnUser(p *AddVpnUserParams) (*AddVpnUserResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -778,15 +770,13 @@ func (s *VPNService) RemoveVpnUser(p *RemoveVpnUserParams) (*RemoveVpnUserRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1170,15 +1160,13 @@ func (s *VPNService) CreateVpnCustomerGateway(p *CreateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1271,15 +1259,13 @@ func (s *VPNService) CreateVpnGateway(p *CreateVpnGatewayParams) (*CreateVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1389,15 +1375,13 @@ func (s *VPNService) CreateVpnConnection(p *CreateVpnConnectionParams) (*CreateV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1483,15 +1467,13 @@ func (s *VPNService) DeleteVpnCustomerGateway(p *DeleteVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1552,15 +1534,13 @@ func (s *VPNService) DeleteVpnGateway(p *DeleteVpnGatewayParams) (*DeleteVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1621,15 +1601,13 @@ func (s *VPNService) DeleteVpnConnection(p *DeleteVpnConnectionParams) (*DeleteV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1819,15 +1797,13 @@ func (s *VPNService) UpdateVpnCustomerGateway(p *UpdateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1930,15 +1906,13 @@ func (s *VPNService) ResetVpnConnection(p *ResetVpnConnectionParams) (*ResetVpnC // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2757,15 +2731,13 @@ func (s *VPNService) UpdateVpnConnection(p *UpdateVpnConnectionParams) (*UpdateV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2874,15 +2846,13 @@ func (s *VPNService) UpdateVpnGateway(p *UpdateVpnGatewayParams) (*UpdateVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/VirtualMachineService.go b/cloudstack/VirtualMachineService.go index d459b3b..2265e0b 100644 --- a/cloudstack/VirtualMachineService.go +++ b/cloudstack/VirtualMachineService.go @@ -410,15 +410,13 @@ func (s *VirtualMachineService) DeployVirtualMachine(p *DeployVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -661,15 +659,13 @@ func (s *VirtualMachineService) DestroyVirtualMachine(p *DestroyVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -900,15 +896,13 @@ func (s *VirtualMachineService) RebootVirtualMachine(p *RebootVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1161,15 +1155,13 @@ func (s *VirtualMachineService) StartVirtualMachine(p *StartVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1412,15 +1404,13 @@ func (s *VirtualMachineService) StopVirtualMachine(p *StopVirtualMachineParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1651,15 +1641,13 @@ func (s *VirtualMachineService) ResetPasswordForVirtualMachine(p *ResetPasswordF // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2920,15 +2908,13 @@ func (s *VirtualMachineService) RestoreVirtualMachine(p *RestoreVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3431,15 +3417,13 @@ func (s *VirtualMachineService) ScaleVirtualMachine(p *ScaleVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3786,15 +3770,13 @@ func (s *VirtualMachineService) MigrateVirtualMachine(p *MigrateVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4053,15 +4035,13 @@ func (s *VirtualMachineService) MigrateVirtualMachineWithVolume(p *MigrateVirtua // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4508,15 +4488,13 @@ func (s *VirtualMachineService) ExpungeVirtualMachine(p *ExpungeVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4565,15 +4543,13 @@ func (s *VirtualMachineService) CleanVMReservations(p *CleanVMReservationsParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4657,15 +4633,13 @@ func (s *VirtualMachineService) AddNicToVirtualMachine(p *AddNicToVirtualMachine // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4908,15 +4882,13 @@ func (s *VirtualMachineService) RemoveNicFromVirtualMachine(p *RemoveNicFromVirt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -5159,15 +5131,13 @@ func (s *VirtualMachineService) UpdateDefaultNicForVirtualMachine(p *UpdateDefau // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/VolumeService.go b/cloudstack/VolumeService.go index 5f62151..eb4a7c4 100644 --- a/cloudstack/VolumeService.go +++ b/cloudstack/VolumeService.go @@ -94,15 +94,13 @@ func (s *VolumeService) AttachVolume(p *AttachVolumeParams) (*AttachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -329,15 +327,13 @@ func (s *VolumeService) UploadVolume(p *UploadVolumeParams) (*UploadVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -484,15 +480,13 @@ func (s *VolumeService) DetachVolume(p *DetachVolumeParams) (*DetachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -753,15 +747,13 @@ func (s *VolumeService) CreateVolume(p *CreateVolumeParams) (*CreateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1390,15 +1382,13 @@ func (s *VolumeService) ExtractVolume(p *ExtractVolumeParams) (*ExtractVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1500,15 +1490,13 @@ func (s *VolumeService) MigrateVolume(p *MigrateVolumeParams) (*MigrateVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1668,15 +1656,13 @@ func (s *VolumeService) ResizeVolume(p *ResizeVolumeParams) (*ResizeVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1867,15 +1853,13 @@ func (s *VolumeService) UpdateVolume(p *UpdateVolumeParams) (*UpdateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack/ZoneService.go b/cloudstack/ZoneService.go index 37f1fde..56894db 100644 --- a/cloudstack/ZoneService.go +++ b/cloudstack/ZoneService.go @@ -933,15 +933,13 @@ func (s *ZoneService) DedicateZone(p *DedicateZoneParams) (*DedicateZoneResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1011,15 +1009,13 @@ func (s *ZoneService) ReleaseDedicatedZone(p *ReleaseDedicatedZoneParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go index cd26904..2744755 100644 --- a/cloudstack/cloudstack.go +++ b/cloudstack/cloudstack.go @@ -23,6 +23,7 @@ import ( "crypto/tls" "encoding/base64" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -50,7 +51,7 @@ type CloudStackClient struct { apiKey string // Api key secret string // Secret key async bool // Wait for async calls to finish - timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds + timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds APIDiscovery *APIDiscoveryService Account *AccountService @@ -131,7 +132,7 @@ func newClient(apiurl string, apikey string, secret string, async bool, verifyss apiKey: apikey, secret: secret, async: async, - timeout: 60, + timeout: 300, } cs.APIDiscovery = NewAPIDiscoveryService(cs) cs.Account = NewAccountService(cs) @@ -216,39 +217,41 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) return cs } -// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60 +// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds // seconds, to check if the async job is finished. func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) { cs.timeout = timeoutInSeconds } +var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish") + // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured -// timeout, the async job return a warning saying the timer has expired. -func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (b json.RawMessage, warn error, err error) { +// timeout, the async job returns a AsyncTimeoutErr. +func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { currentTime := time.Now().Unix() for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) if err != nil { - return nil, nil, err + return nil, err } // Status 1 means the job is finished successfully if r.Jobstatus == 1 { - return r.Jobresult, nil, nil + return r.Jobresult, nil } // When the status is 2, the job has failed if r.Jobstatus == 2 { if r.Jobresulttype == "text" { - return nil, nil, fmt.Errorf(string(r.Jobresult)) + return nil, fmt.Errorf(string(r.Jobresult)) } else { - return nil, nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) + return nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) } } if time.Now().Unix()-currentTime > timeout { - return nil, fmt.Errorf("Timeout while waiting for async job to finish"), nil + return nil, AsyncTimeoutErr } time.Sleep(3 * time.Second) } diff --git a/cloudstack43/AccountService.go b/cloudstack43/AccountService.go index fb24e57..4a3106a 100644 --- a/cloudstack43/AccountService.go +++ b/cloudstack43/AccountService.go @@ -332,15 +332,13 @@ func (s *AccountService) DeleteAccount(p *DeleteAccountParams) (*DeleteAccountRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -614,15 +612,13 @@ func (s *AccountService) DisableAccount(p *DisableAccountParams) (*DisableAccoun // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1361,15 +1357,13 @@ func (s *AccountService) MarkDefaultZoneForAccount(p *MarkDefaultZoneForAccountP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1525,15 +1519,13 @@ func (s *AccountService) AddAccountToProject(p *AddAccountToProjectParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1606,15 +1598,13 @@ func (s *AccountService) DeleteAccountFromProject(p *DeleteAccountFromProjectPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/AddressService.go b/cloudstack43/AddressService.go index 5d6240e..88871eb 100644 --- a/cloudstack43/AddressService.go +++ b/cloudstack43/AddressService.go @@ -148,15 +148,13 @@ func (s *AddressService) AssociateIpAddress(p *AssociateIpAddressParams) (*Assoc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -260,15 +258,13 @@ func (s *AddressService) DisassociateIpAddress(p *DisassociateIpAddressParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/AffinityGroupService.go b/cloudstack43/AffinityGroupService.go index 65c80e6..1006d7b 100644 --- a/cloudstack43/AffinityGroupService.go +++ b/cloudstack43/AffinityGroupService.go @@ -115,15 +115,13 @@ func (s *AffinityGroupService) CreateAffinityGroup(p *CreateAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -227,15 +225,13 @@ func (s *AffinityGroupService) DeleteAffinityGroup(p *DeleteAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -566,15 +562,13 @@ func (s *AffinityGroupService) UpdateVMAffinityGroup(p *UpdateVMAffinityGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/AlertService.go b/cloudstack43/AlertService.go index e71b413..33161a5 100644 --- a/cloudstack43/AlertService.go +++ b/cloudstack43/AlertService.go @@ -471,15 +471,13 @@ func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/AsyncjobService.go b/cloudstack43/AsyncjobService.go index 05e9514..c078ff1 100644 --- a/cloudstack43/AsyncjobService.go +++ b/cloudstack43/AsyncjobService.go @@ -20,6 +20,7 @@ import ( "encoding/json" "net/url" "strconv" + "time" ) type QueryAsyncJobResultParams struct { @@ -62,9 +63,10 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu // We should be able to retry on failure as this call is idempotent for i := 0; i < 3; i++ { resp, err = s.cs.newRequest("queryAsyncJobResult", p.toURLValues()) - if err != nil { - continue + if err == nil { + break } + time.Sleep(1 * time.Second) } if err != nil { return nil, err diff --git a/cloudstack43/AutoScaleService.go b/cloudstack43/AutoScaleService.go index b8bded3..f20d668 100644 --- a/cloudstack43/AutoScaleService.go +++ b/cloudstack43/AutoScaleService.go @@ -94,15 +94,13 @@ func (s *AutoScaleService) CreateCounter(p *CreateCounterParams) (*CreateCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -218,15 +216,13 @@ func (s *AutoScaleService) CreateCondition(p *CreateConditionParams) (*CreateCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -338,15 +334,13 @@ func (s *AutoScaleService) CreateAutoScalePolicy(p *CreateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -494,15 +488,13 @@ func (s *AutoScaleService) CreateAutoScaleVmProfile(p *CreateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -654,15 +646,13 @@ func (s *AutoScaleService) CreateAutoScaleVmGroup(p *CreateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -740,15 +730,13 @@ func (s *AutoScaleService) DeleteCounter(p *DeleteCounterParams) (*DeleteCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -809,15 +797,13 @@ func (s *AutoScaleService) DeleteCondition(p *DeleteConditionParams) (*DeleteCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -878,15 +864,13 @@ func (s *AutoScaleService) DeleteAutoScalePolicy(p *DeleteAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -947,15 +931,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmProfile(p *DeleteAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1016,15 +998,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmGroup(p *DeleteAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2134,15 +2114,13 @@ func (s *AutoScaleService) EnableAutoScaleVmGroup(p *EnableAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2220,15 +2198,13 @@ func (s *AutoScaleService) DisableAutoScaleVmGroup(p *DisableAutoScaleVmGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2342,15 +2318,13 @@ func (s *AutoScaleService) UpdateAutoScalePolicy(p *UpdateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2474,15 +2448,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmProfile(p *UpdateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2618,15 +2590,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmGroup(p *UpdateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/BaremetalService.go b/cloudstack43/BaremetalService.go index b3f52b4..091a8f4 100644 --- a/cloudstack43/BaremetalService.go +++ b/cloudstack43/BaremetalService.go @@ -139,15 +139,13 @@ func (s *BaremetalService) AddBaremetalPxeKickStartServer(p *AddBaremetalPxeKick // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -329,15 +327,13 @@ func (s *BaremetalService) AddBaremetalPxePingServer(p *AddBaremetalPxePingServe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -452,15 +448,13 @@ func (s *BaremetalService) AddBaremetalDhcp(p *AddBaremetalDhcpParams) (*AddBare // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/BigSwitchVNSService.go b/cloudstack43/BigSwitchVNSService.go index 7202bfd..51535ed 100644 --- a/cloudstack43/BigSwitchVNSService.go +++ b/cloudstack43/BigSwitchVNSService.go @@ -80,15 +80,13 @@ func (s *BigSwitchVNSService) AddBigSwitchVnsDevice(p *AddBigSwitchVnsDevicePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -157,15 +155,13 @@ func (s *BigSwitchVNSService) DeleteBigSwitchVnsDevice(p *DeleteBigSwitchVnsDevi // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/CertificateService.go b/cloudstack43/CertificateService.go index 0010cbc..9c87bd6 100644 --- a/cloudstack43/CertificateService.go +++ b/cloudstack43/CertificateService.go @@ -114,15 +114,13 @@ func (s *CertificateService) UploadCustomCertificate(p *UploadCustomCertificateP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/ClusterService.go b/cloudstack43/ClusterService.go index 4a6804b..fd6345b 100644 --- a/cloudstack43/ClusterService.go +++ b/cloudstack43/ClusterService.go @@ -786,15 +786,13 @@ func (s *ClusterService) DedicateCluster(p *DedicateClusterParams) (*DedicateClu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -864,15 +862,13 @@ func (s *ClusterService) ReleaseDedicatedCluster(p *ReleaseDedicatedClusterParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/DomainService.go b/cloudstack43/DomainService.go index c8aca4b..9c2f6dd 100644 --- a/cloudstack43/DomainService.go +++ b/cloudstack43/DomainService.go @@ -251,15 +251,13 @@ func (s *DomainService) DeleteDomain(p *DeleteDomainParams) (*DeleteDomainRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/ExternalDeviceService.go b/cloudstack43/ExternalDeviceService.go index 566018c..7a48c0c 100644 --- a/cloudstack43/ExternalDeviceService.go +++ b/cloudstack43/ExternalDeviceService.go @@ -68,15 +68,13 @@ func (s *ExternalDeviceService) DeleteCiscoNexusVSM(p *DeleteCiscoNexusVSMParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -137,15 +135,13 @@ func (s *ExternalDeviceService) EnableCiscoNexusVSM(p *EnableCiscoNexusVSMParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -220,15 +216,13 @@ func (s *ExternalDeviceService) DisableCiscoNexusVSM(p *DisableCiscoNexusVSMPara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/FirewallService.go b/cloudstack43/FirewallService.go index 71124ec..5a399a9 100644 --- a/cloudstack43/FirewallService.go +++ b/cloudstack43/FirewallService.go @@ -442,15 +442,13 @@ func (s *FirewallService) CreatePortForwardingRule(p *CreatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -541,15 +539,13 @@ func (s *FirewallService) DeletePortForwardingRule(p *DeletePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -668,15 +664,13 @@ func (s *FirewallService) UpdatePortForwardingRule(p *UpdatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -850,15 +844,13 @@ func (s *FirewallService) CreateFirewallRule(p *CreateFirewallRuleParams) (*Crea // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -945,15 +937,13 @@ func (s *FirewallService) DeleteFirewallRule(p *DeleteFirewallRuleParams) (*Dele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1345,15 +1335,13 @@ func (s *FirewallService) CreateEgressFirewallRule(p *CreateEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1440,15 +1428,13 @@ func (s *FirewallService) DeleteEgressFirewallRule(p *DeleteEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1811,15 +1797,13 @@ func (s *FirewallService) AddSrxFirewall(p *AddSrxFirewallParams) (*AddSrxFirewa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1899,15 +1883,13 @@ func (s *FirewallService) DeleteSrxFirewall(p *DeleteSrxFirewallParams) (*Delete // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1980,15 +1962,13 @@ func (s *FirewallService) ConfigureSrxFirewall(p *ConfigureSrxFirewallParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2231,15 +2211,13 @@ func (s *FirewallService) AddPaloAltoFirewall(p *AddPaloAltoFirewallParams) (*Ad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2319,15 +2297,13 @@ func (s *FirewallService) DeletePaloAltoFirewall(p *DeletePaloAltoFirewallParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2400,15 +2376,13 @@ func (s *FirewallService) ConfigurePaloAltoFirewall(p *ConfigurePaloAltoFirewall // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/HostService.go b/cloudstack43/HostService.go index cbcb0b2..cc840da 100644 --- a/cloudstack43/HostService.go +++ b/cloudstack43/HostService.go @@ -268,15 +268,13 @@ func (s *HostService) ReconnectHost(p *ReconnectHostParams) (*ReconnectHostRespo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -597,15 +595,13 @@ func (s *HostService) PrepareHostForMaintenance(p *PrepareHostForMaintenancePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -713,15 +709,13 @@ func (s *HostService) CancelHostMaintenance(p *CancelHostMaintenanceParams) (*Ca // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1437,15 +1431,13 @@ func (s *HostService) ReleaseHostReservation(p *ReleaseHostReservationParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1738,15 +1730,13 @@ func (s *HostService) DedicateHost(p *DedicateHostParams) (*DedicateHostResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1816,15 +1806,13 @@ func (s *HostService) ReleaseDedicatedHost(p *ReleaseDedicatedHostParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/ISOService.go b/cloudstack43/ISOService.go index 0f4d7d0..ed6bf82 100644 --- a/cloudstack43/ISOService.go +++ b/cloudstack43/ISOService.go @@ -82,15 +82,13 @@ func (s *ISOService) AttachIso(p *AttachIsoParams) (*AttachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -291,15 +289,13 @@ func (s *ISOService) DetachIso(p *DetachIsoParams) (*DetachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1367,15 +1363,13 @@ func (s *ISOService) DeleteIso(p *DeleteIsoParams) (*DeleteIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1459,15 +1453,13 @@ func (s *ISOService) CopyIso(p *CopyIsoParams) (*CopyIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1821,15 +1813,13 @@ func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/InternalLBService.go b/cloudstack43/InternalLBService.go index 665b8cb..59d5732 100644 --- a/cloudstack43/InternalLBService.go +++ b/cloudstack43/InternalLBService.go @@ -83,15 +83,13 @@ func (s *InternalLBService) ConfigureInternalLoadBalancerElement(p *ConfigureInt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -158,15 +156,13 @@ func (s *InternalLBService) CreateInternalLoadBalancerElement(p *CreateInternalL // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -386,15 +382,13 @@ func (s *InternalLBService) StopInternalLoadBalancerVM(p *StopInternalLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -521,15 +515,13 @@ func (s *InternalLBService) StartInternalLoadBalancerVM(p *StartInternalLoadBala // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/LoadBalancerService.go b/cloudstack43/LoadBalancerService.go index f2d9a60..777100b 100644 --- a/cloudstack43/LoadBalancerService.go +++ b/cloudstack43/LoadBalancerService.go @@ -209,15 +209,13 @@ func (s *LoadBalancerService) CreateLoadBalancerRule(p *CreateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -311,15 +309,13 @@ func (s *LoadBalancerService) DeleteLoadBalancerRule(p *DeleteLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -393,15 +389,13 @@ func (s *LoadBalancerService) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -475,15 +469,13 @@ func (s *LoadBalancerService) AssignToLoadBalancerRule(p *AssignToLoadBalancerRu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -595,15 +587,13 @@ func (s *LoadBalancerService) CreateLBStickinessPolicy(p *CreateLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -683,15 +673,13 @@ func (s *LoadBalancerService) DeleteLBStickinessPolicy(p *DeleteLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1373,15 +1361,13 @@ func (s *LoadBalancerService) CreateLBHealthCheckPolicy(p *CreateLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1460,15 +1446,13 @@ func (s *LoadBalancerService) DeleteLBHealthCheckPolicy(p *DeleteLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1800,15 +1784,13 @@ func (s *LoadBalancerService) UpdateLoadBalancerRule(p *UpdateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2137,15 +2119,13 @@ func (s *LoadBalancerService) AssignCertToLoadBalancer(p *AssignCertToLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2206,15 +2186,13 @@ func (s *LoadBalancerService) RemoveCertFromLoadBalancer(p *RemoveCertFromLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2323,15 +2301,13 @@ func (s *LoadBalancerService) AddF5LoadBalancer(p *AddF5LoadBalancerParams) (*Ad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2417,15 +2393,13 @@ func (s *LoadBalancerService) ConfigureF5LoadBalancer(p *ConfigureF5LoadBalancer // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2499,15 +2473,13 @@ func (s *LoadBalancerService) DeleteF5LoadBalancer(p *DeleteF5LoadBalancerParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2771,15 +2743,13 @@ func (s *LoadBalancerService) AddNetscalerLoadBalancer(p *AddNetscalerLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2858,15 +2828,13 @@ func (s *LoadBalancerService) DeleteNetscalerLoadBalancer(p *DeleteNetscalerLoad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2975,15 +2943,13 @@ func (s *LoadBalancerService) ConfigureNetscalerLoadBalancer(p *ConfigureNetscal // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3268,15 +3234,13 @@ func (s *LoadBalancerService) CreateGlobalLoadBalancerRule(p *CreateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3385,15 +3349,13 @@ func (s *LoadBalancerService) DeleteGlobalLoadBalancerRule(p *DeleteGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3487,15 +3449,13 @@ func (s *LoadBalancerService) UpdateGlobalLoadBalancerRule(p *UpdateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3947,15 +3907,13 @@ func (s *LoadBalancerService) AssignToGlobalLoadBalancerRule(p *AssignToGlobalLo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4029,15 +3987,13 @@ func (s *LoadBalancerService) RemoveFromGlobalLoadBalancerRule(p *RemoveFromGlob // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4194,15 +4150,13 @@ func (s *LoadBalancerService) CreateLoadBalancer(p *CreateLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4648,15 +4602,13 @@ func (s *LoadBalancerService) DeleteLoadBalancer(p *DeleteLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/NATService.go b/cloudstack43/NATService.go index 27a46f5..7cb070a 100644 --- a/cloudstack43/NATService.go +++ b/cloudstack43/NATService.go @@ -216,15 +216,13 @@ func (s *NATService) CreateIpForwardingRule(p *CreateIpForwardingRuleParams) (*C // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -315,15 +313,13 @@ func (s *NATService) DeleteIpForwardingRule(p *DeleteIpForwardingRuleParams) (*D // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -620,15 +616,13 @@ func (s *NATService) DisableStaticNat(p *DisableStaticNatParams) (*DisableStatic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/NetworkACLService.go b/cloudstack43/NetworkACLService.go index c784d46..0120c7b 100644 --- a/cloudstack43/NetworkACLService.go +++ b/cloudstack43/NetworkACLService.go @@ -186,15 +186,13 @@ func (s *NetworkACLService) CreateNetworkACL(p *CreateNetworkACLParams) (*Create // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -387,15 +385,13 @@ func (s *NetworkACLService) UpdateNetworkACLItem(p *UpdateNetworkACLItemParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -483,15 +479,13 @@ func (s *NetworkACLService) DeleteNetworkACL(p *DeleteNetworkACLParams) (*Delete // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -857,15 +851,13 @@ func (s *NetworkACLService) CreateNetworkACLList(p *CreateNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -933,15 +925,13 @@ func (s *NetworkACLService) DeleteNetworkACLList(p *DeleteNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1024,15 +1014,13 @@ func (s *NetworkACLService) ReplaceNetworkACLList(p *ReplaceNetworkACLListParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/NetworkService.go b/cloudstack43/NetworkService.go index 2858642..27bdf7f 100644 --- a/cloudstack43/NetworkService.go +++ b/cloudstack43/NetworkService.go @@ -623,15 +623,13 @@ func (s *NetworkService) DeleteNetwork(p *DeleteNetworkParams) (*DeleteNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1172,15 +1170,13 @@ func (s *NetworkService) RestartNetwork(p *RestartNetworkParams) (*RestartNetwor // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1363,15 +1359,13 @@ func (s *NetworkService) UpdateNetwork(p *UpdateNetworkParams) (*UpdateNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1588,15 +1582,13 @@ func (s *NetworkService) CreatePhysicalNetwork(p *CreatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1670,15 +1662,13 @@ func (s *NetworkService) DeletePhysicalNetwork(p *DeletePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1975,15 +1965,13 @@ func (s *NetworkService) UpdatePhysicalNetwork(p *UpdatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2206,15 +2194,13 @@ func (s *NetworkService) AddNetworkServiceProvider(p *AddNetworkServiceProviderP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2285,15 +2271,13 @@ func (s *NetworkService) DeleteNetworkServiceProvider(p *DeleteNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2524,15 +2508,13 @@ func (s *NetworkService) UpdateNetworkServiceProvider(p *UpdateNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2662,15 +2644,13 @@ func (s *NetworkService) CreateStorageNetworkIpRange(p *CreateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2743,15 +2723,13 @@ func (s *NetworkService) DeleteStorageNetworkIpRange(p *DeleteStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3003,15 +2981,13 @@ func (s *NetworkService) UpdateStorageNetworkIpRange(p *UpdateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/NicService.go b/cloudstack43/NicService.go index 508ce10..14e6da8 100644 --- a/cloudstack43/NicService.go +++ b/cloudstack43/NicService.go @@ -79,15 +79,13 @@ func (s *NicService) AddIpToNic(p *AddIpToNicParams) (*AddIpToNicResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -156,15 +154,13 @@ func (s *NicService) RemoveIpFromNic(p *RemoveIpFromNicParams) (*RemoveIpFromNic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/NiciraNVPService.go b/cloudstack43/NiciraNVPService.go index 5122b02..9849215 100644 --- a/cloudstack43/NiciraNVPService.go +++ b/cloudstack43/NiciraNVPService.go @@ -127,15 +127,13 @@ func (s *NiciraNVPService) AddNiciraNvpDevice(p *AddNiciraNvpDeviceParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -206,15 +204,13 @@ func (s *NiciraNVPService) DeleteNiciraNvpDevice(p *DeleteNiciraNvpDeviceParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/PodService.go b/cloudstack43/PodService.go index ec5482e..57ef7ed 100644 --- a/cloudstack43/PodService.go +++ b/cloudstack43/PodService.go @@ -645,15 +645,13 @@ func (s *PodService) DedicatePod(p *DedicatePodParams) (*DedicatePodResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -723,15 +721,13 @@ func (s *PodService) ReleaseDedicatedPod(p *ReleaseDedicatedPodParams) (*Release // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/PortableIPService.go b/cloudstack43/PortableIPService.go index 5123c0a..74363f8 100644 --- a/cloudstack43/PortableIPService.go +++ b/cloudstack43/PortableIPService.go @@ -130,15 +130,13 @@ func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -221,15 +219,13 @@ func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/ProjectService.go b/cloudstack43/ProjectService.go index 9b67a1d..c7bd3ef 100644 --- a/cloudstack43/ProjectService.go +++ b/cloudstack43/ProjectService.go @@ -104,15 +104,13 @@ func (s *ProjectService) CreateProject(p *CreateProjectParams) (*CreateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -230,15 +228,13 @@ func (s *ProjectService) DeleteProject(p *DeleteProjectParams) (*DeleteProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -321,15 +317,13 @@ func (s *ProjectService) UpdateProject(p *UpdateProjectParams) (*UpdateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -447,15 +441,13 @@ func (s *ProjectService) ActivateProject(p *ActivateProjectParams) (*ActivatePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -573,15 +565,13 @@ func (s *ProjectService) SuspendProject(p *SuspendProjectParams) (*SuspendProjec // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1259,15 +1249,13 @@ func (s *ProjectService) UpdateProjectInvitation(p *UpdateProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1328,15 +1316,13 @@ func (s *ProjectService) DeleteProjectInvitation(p *DeleteProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/ResourcemetadataService.go b/cloudstack43/ResourcemetadataService.go index 68110e4..ac1b7ab 100644 --- a/cloudstack43/ResourcemetadataService.go +++ b/cloudstack43/ResourcemetadataService.go @@ -98,15 +98,13 @@ func (s *ResourcemetadataService) AddResourceDetail(p *AddResourceDetailParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -190,15 +188,13 @@ func (s *ResourcemetadataService) RemoveResourceDetail(p *RemoveResourceDetailPa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/ResourcetagsService.go b/cloudstack43/ResourcetagsService.go index 3c05e04..0d61028 100644 --- a/cloudstack43/ResourcetagsService.go +++ b/cloudstack43/ResourcetagsService.go @@ -111,15 +111,13 @@ func (s *ResourcetagsService) CreateTags(p *CreateTagsParams) (*CreateTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -209,15 +207,13 @@ func (s *ResourcetagsService) DeleteTags(p *DeleteTagsParams) (*DeleteTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/RouterService.go b/cloudstack43/RouterService.go index 863f929..aaf3e8a 100644 --- a/cloudstack43/RouterService.go +++ b/cloudstack43/RouterService.go @@ -70,15 +70,13 @@ func (s *RouterService) StartRouter(p *StartRouterParams) (*StartRouterResponse, // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -205,15 +203,13 @@ func (s *RouterService) RebootRouter(p *RebootRouterParams) (*RebootRouterRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -352,15 +348,13 @@ func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -487,15 +481,13 @@ func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1320,15 +1312,13 @@ func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1411,15 +1401,13 @@ func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElement // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/SSHService.go b/cloudstack43/SSHService.go index 84aa32d..855b8b9 100644 --- a/cloudstack43/SSHService.go +++ b/cloudstack43/SSHService.go @@ -113,15 +113,13 @@ func (s *SSHService) ResetSSHKeyForVirtualMachine(p *ResetSSHKeyForVirtualMachin // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/SecurityGroupService.go b/cloudstack43/SecurityGroupService.go index 07a1a1b..b1f98d1 100644 --- a/cloudstack43/SecurityGroupService.go +++ b/cloudstack43/SecurityGroupService.go @@ -429,15 +429,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupIngress(p *AuthorizeSecurit // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -510,15 +508,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupIngress(p *RevokeSecurityGroup // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -709,15 +705,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupEgress(p *AuthorizeSecurity // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -790,15 +784,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupEgress(p *RevokeSecurityGroupE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/SnapshotService.go b/cloudstack43/SnapshotService.go index 7bacdaa..ee7fff7 100644 --- a/cloudstack43/SnapshotService.go +++ b/cloudstack43/SnapshotService.go @@ -115,15 +115,13 @@ func (s *SnapshotService) CreateSnapshot(p *CreateSnapshotParams) (*CreateSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -555,15 +553,13 @@ func (s *SnapshotService) DeleteSnapshot(p *DeleteSnapshotParams) (*DeleteSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -885,15 +881,13 @@ func (s *SnapshotService) RevertSnapshot(p *RevertSnapshotParams) (*RevertSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1282,15 +1276,13 @@ func (s *SnapshotService) CreateVMSnapshot(p *CreateVMSnapshotParams) (*CreateVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1371,15 +1363,13 @@ func (s *SnapshotService) DeleteVMSnapshot(p *DeleteVMSnapshotParams) (*DeleteVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1440,15 +1430,13 @@ func (s *SnapshotService) RevertToVMSnapshot(p *RevertToVMSnapshotParams) (*Reve // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/StoragePoolService.go b/cloudstack43/StoragePoolService.go index d7367d8..5adef55 100644 --- a/cloudstack43/StoragePoolService.go +++ b/cloudstack43/StoragePoolService.go @@ -159,15 +159,13 @@ func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -253,15 +251,13 @@ func (s *StoragePoolService) CancelStorageMaintenance(p *CancelStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/SystemVMService.go b/cloudstack43/SystemVMService.go index 74068c2..8656eb2 100644 --- a/cloudstack43/SystemVMService.go +++ b/cloudstack43/SystemVMService.go @@ -70,15 +70,13 @@ func (s *SystemVMService) StartSystemVm(p *StartSystemVmParams) (*StartSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -169,15 +167,13 @@ func (s *SystemVMService) RebootSystemVm(p *RebootSystemVmParams) (*RebootSystem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -280,15 +276,13 @@ func (s *SystemVMService) StopSystemVm(p *StopSystemVmParams) (*StopSystemVmResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -379,15 +373,13 @@ func (s *SystemVMService) DestroySystemVm(p *DestroySystemVmParams) (*DestroySys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -753,15 +745,13 @@ func (s *SystemVMService) MigrateSystemVm(p *MigrateSystemVmParams) (*MigrateSys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -984,15 +974,13 @@ func (s *SystemVMService) ScaleSystemVm(p *ScaleSystemVmParams) (*ScaleSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/TemplateService.go b/cloudstack43/TemplateService.go index 8e716ae..6f62ec8 100644 --- a/cloudstack43/TemplateService.go +++ b/cloudstack43/TemplateService.go @@ -237,15 +237,13 @@ func (s *TemplateService) CreateTemplate(p *CreateTemplateParams) (*CreateTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -931,15 +929,13 @@ func (s *TemplateService) CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1061,15 +1057,13 @@ func (s *TemplateService) DeleteTemplate(p *DeleteTemplateParams) (*DeleteTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1737,15 +1731,13 @@ func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2161,15 +2153,13 @@ func (s *TemplateService) InstantiateUcsTemplateAndAssocaciateToBlade(p *Instant // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/UCSService.go b/cloudstack43/UCSService.go index 2641ade..9eacf88 100644 --- a/cloudstack43/UCSService.go +++ b/cloudstack43/UCSService.go @@ -552,15 +552,13 @@ func (s *UCSService) AssociateUcsProfileToBlade(p *AssociateUcsProfileToBladePar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -692,15 +690,13 @@ func (s *UCSService) DisassociateUcsProfileFromBlade(p *DisassociateUcsProfileFr // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/UsageService.go b/cloudstack43/UsageService.go index a72712e..8a39e51 100644 --- a/cloudstack43/UsageService.go +++ b/cloudstack43/UsageService.go @@ -147,15 +147,13 @@ func (s *UsageService) AddTrafficType(p *AddTrafficTypeParams) (*AddTrafficTypeR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -226,15 +224,13 @@ func (s *UsageService) DeleteTrafficType(p *DeleteTrafficTypeParams) (*DeleteTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -466,15 +462,13 @@ func (s *UsageService) UpdateTrafficType(p *UpdateTrafficTypeParams) (*UpdateTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/UserService.go b/cloudstack43/UserService.go index 8ed7e64..5c520a9 100644 --- a/cloudstack43/UserService.go +++ b/cloudstack43/UserService.go @@ -712,15 +712,13 @@ func (s *UserService) DisableUser(p *DisableUserParams) (*DisableUserResponse, e // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/VLANService.go b/cloudstack43/VLANService.go index 2876a71..33e4b35 100644 --- a/cloudstack43/VLANService.go +++ b/cloudstack43/VLANService.go @@ -725,15 +725,13 @@ func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/VPCService.go b/cloudstack43/VPCService.go index ee93e8c..4de858c 100644 --- a/cloudstack43/VPCService.go +++ b/cloudstack43/VPCService.go @@ -174,15 +174,13 @@ func (s *VPCService) CreateVPC(p *CreateVPCParams) (*CreateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -833,15 +831,13 @@ func (s *VPCService) DeleteVPC(p *DeleteVPCParams) (*DeleteVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -925,15 +921,13 @@ func (s *VPCService) UpdateVPC(p *UpdateVPCParams) (*UpdateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1117,15 +1111,13 @@ func (s *VPCService) RestartVPC(p *RestartVPCParams) (*RestartVPCResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1361,15 +1353,13 @@ func (s *VPCService) CreateVPCOffering(p *CreateVPCOfferingParams) (*CreateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1489,15 +1479,13 @@ func (s *VPCService) UpdateVPCOffering(p *UpdateVPCOfferingParams) (*UpdateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1584,15 +1572,13 @@ func (s *VPCService) DeleteVPCOffering(p *DeleteVPCOfferingParams) (*DeleteVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1985,15 +1971,13 @@ func (s *VPCService) CreatePrivateGateway(p *CreatePrivateGatewayParams) (*Creat // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2322,15 +2306,13 @@ func (s *VPCService) DeletePrivateGateway(p *DeletePrivateGatewayParams) (*Delet // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2403,15 +2385,13 @@ func (s *VPCService) CreateStaticRoute(p *CreateStaticRouteParams) (*CreateStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2497,15 +2477,13 @@ func (s *VPCService) DeleteStaticRoute(p *DeleteStaticRouteParams) (*DeleteStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/VPNService.go b/cloudstack43/VPNService.go index 8648dea..fd1dee2 100644 --- a/cloudstack43/VPNService.go +++ b/cloudstack43/VPNService.go @@ -115,15 +115,13 @@ func (s *VPNService) CreateRemoteAccessVpn(p *CreateRemoteAccessVpnParams) (*Cre // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -198,15 +196,13 @@ func (s *VPNService) DeleteRemoteAccessVpn(p *DeleteRemoteAccessVpnParams) (*Del // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -532,15 +528,13 @@ func (s *VPNService) AddVpnUser(p *AddVpnUserParams) (*AddVpnUserResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -645,15 +639,13 @@ func (s *VPNService) RemoveVpnUser(p *RemoveVpnUserParams) (*RemoveVpnUserRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1037,15 +1029,13 @@ func (s *VPNService) CreateVpnCustomerGateway(p *CreateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1126,15 +1116,13 @@ func (s *VPNService) CreateVpnGateway(p *CreateVpnGatewayParams) (*CreateVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1231,15 +1219,13 @@ func (s *VPNService) CreateVpnConnection(p *CreateVpnConnectionParams) (*CreateV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1324,15 +1310,13 @@ func (s *VPNService) DeleteVpnCustomerGateway(p *DeleteVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1393,15 +1377,13 @@ func (s *VPNService) DeleteVpnGateway(p *DeleteVpnGatewayParams) (*DeleteVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1462,15 +1444,13 @@ func (s *VPNService) DeleteVpnConnection(p *DeleteVpnConnectionParams) (*DeleteV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1660,15 +1640,13 @@ func (s *VPNService) UpdateVpnCustomerGateway(p *UpdateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1771,15 +1749,13 @@ func (s *VPNService) ResetVpnConnection(p *ResetVpnConnectionParams) (*ResetVpnC // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/VirtualMachineService.go b/cloudstack43/VirtualMachineService.go index 5f1c75f..11ecf82 100644 --- a/cloudstack43/VirtualMachineService.go +++ b/cloudstack43/VirtualMachineService.go @@ -376,15 +376,13 @@ func (s *VirtualMachineService) DeployVirtualMachine(p *DeployVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -597,15 +595,13 @@ func (s *VirtualMachineService) DestroyVirtualMachine(p *DestroyVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -806,15 +802,13 @@ func (s *VirtualMachineService) RebootVirtualMachine(p *RebootVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1026,15 +1020,13 @@ func (s *VirtualMachineService) StartVirtualMachine(p *StartVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1247,15 +1239,13 @@ func (s *VirtualMachineService) StopVirtualMachine(p *StopVirtualMachineParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1456,15 +1446,13 @@ func (s *VirtualMachineService) ResetPasswordForVirtualMachine(p *ResetPasswordF // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2553,15 +2541,13 @@ func (s *VirtualMachineService) RestoreVirtualMachine(p *RestoreVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3004,15 +2990,13 @@ func (s *VirtualMachineService) ScaleVirtualMachine(p *ScaleVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3329,15 +3313,13 @@ func (s *VirtualMachineService) MigrateVirtualMachine(p *MigrateVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3566,15 +3548,13 @@ func (s *VirtualMachineService) MigrateVirtualMachineWithVolume(p *MigrateVirtua // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3961,15 +3941,13 @@ func (s *VirtualMachineService) ExpungeVirtualMachine(p *ExpungeVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4018,15 +3996,13 @@ func (s *VirtualMachineService) CleanVMReservations(p *CleanVMReservationsParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4110,15 +4086,13 @@ func (s *VirtualMachineService) AddNicToVirtualMachine(p *AddNicToVirtualMachine // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4331,15 +4305,13 @@ func (s *VirtualMachineService) RemoveNicFromVirtualMachine(p *RemoveNicFromVirt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4552,15 +4524,13 @@ func (s *VirtualMachineService) UpdateDefaultNicForVirtualMachine(p *UpdateDefau // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/VolumeService.go b/cloudstack43/VolumeService.go index 0d27c64..98fef73 100644 --- a/cloudstack43/VolumeService.go +++ b/cloudstack43/VolumeService.go @@ -94,15 +94,13 @@ func (s *VolumeService) AttachVolume(p *AttachVolumeParams) (*AttachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -312,15 +310,13 @@ func (s *VolumeService) UploadVolume(p *UploadVolumeParams) (*UploadVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -461,15 +457,13 @@ func (s *VolumeService) DetachVolume(p *DetachVolumeParams) (*DetachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -713,15 +707,13 @@ func (s *VolumeService) CreateVolume(p *CreateVolumeParams) (*CreateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1315,15 +1307,13 @@ func (s *VolumeService) ExtractVolume(p *ExtractVolumeParams) (*ExtractVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1425,15 +1415,13 @@ func (s *VolumeService) MigrateVolume(p *MigrateVolumeParams) (*MigrateVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1586,15 +1574,13 @@ func (s *VolumeService) ResizeVolume(p *ResizeVolumeParams) (*ResizeVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1757,15 +1743,13 @@ func (s *VolumeService) UpdateVolume(p *UpdateVolumeParams) (*UpdateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack43/ZoneService.go b/cloudstack43/ZoneService.go index 69257a2..929e5cc 100644 --- a/cloudstack43/ZoneService.go +++ b/cloudstack43/ZoneService.go @@ -1207,15 +1207,13 @@ func (s *ZoneService) DedicateZone(p *DedicateZoneParams) (*DedicateZoneResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1285,15 +1283,13 @@ func (s *ZoneService) ReleaseDedicatedZone(p *ReleaseDedicatedZoneParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack43/cloudstack.go b/cloudstack43/cloudstack.go index 52ad1fc..bcd4076 100644 --- a/cloudstack43/cloudstack.go +++ b/cloudstack43/cloudstack.go @@ -23,6 +23,7 @@ import ( "crypto/tls" "encoding/base64" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -50,7 +51,7 @@ type CloudStackClient struct { apiKey string // Api key secret string // Secret key async bool // Wait for async calls to finish - timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds + timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds APIDiscovery *APIDiscoveryService Account *AccountService @@ -132,7 +133,7 @@ func newClient(apiurl string, apikey string, secret string, async bool, verifyss apiKey: apikey, secret: secret, async: async, - timeout: 60, + timeout: 300, } cs.APIDiscovery = NewAPIDiscoveryService(cs) cs.Account = NewAccountService(cs) @@ -218,39 +219,41 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) return cs } -// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60 +// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds // seconds, to check if the async job is finished. func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) { cs.timeout = timeoutInSeconds } +var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish") + // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured -// timeout, the async job return a warning saying the timer has expired. -func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (b json.RawMessage, warn error, err error) { +// timeout, the async job returns a AsyncTimeoutErr. +func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { currentTime := time.Now().Unix() for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) if err != nil { - return nil, nil, err + return nil, err } // Status 1 means the job is finished successfully if r.Jobstatus == 1 { - return r.Jobresult, nil, nil + return r.Jobresult, nil } // When the status is 2, the job has failed if r.Jobstatus == 2 { if r.Jobresulttype == "text" { - return nil, nil, fmt.Errorf(string(r.Jobresult)) + return nil, fmt.Errorf(string(r.Jobresult)) } else { - return nil, nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) + return nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) } } if time.Now().Unix()-currentTime > timeout { - return nil, fmt.Errorf("Timeout while waiting for async job to finish"), nil + return nil, AsyncTimeoutErr } time.Sleep(3 * time.Second) } diff --git a/cloudstack44/AccountService.go b/cloudstack44/AccountService.go index 04f1238..fe1eea3 100644 --- a/cloudstack44/AccountService.go +++ b/cloudstack44/AccountService.go @@ -333,15 +333,13 @@ func (s *AccountService) DeleteAccount(p *DeleteAccountParams) (*DeleteAccountRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -616,15 +614,13 @@ func (s *AccountService) DisableAccount(p *DisableAccountParams) (*DisableAccoun // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1367,15 +1363,13 @@ func (s *AccountService) MarkDefaultZoneForAccount(p *MarkDefaultZoneForAccountP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1532,15 +1526,13 @@ func (s *AccountService) AddAccountToProject(p *AddAccountToProjectParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1613,15 +1605,13 @@ func (s *AccountService) DeleteAccountFromProject(p *DeleteAccountFromProjectPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/AddressService.go b/cloudstack44/AddressService.go index acb0f50..2c381ab 100644 --- a/cloudstack44/AddressService.go +++ b/cloudstack44/AddressService.go @@ -160,15 +160,13 @@ func (s *AddressService) AssociateIpAddress(p *AssociateIpAddressParams) (*Assoc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -273,15 +271,13 @@ func (s *AddressService) DisassociateIpAddress(p *DisassociateIpAddressParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -747,15 +743,13 @@ func (s *AddressService) UpdateIpAddress(p *UpdateIpAddressParams) (*UpdateIpAdd // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/AffinityGroupService.go b/cloudstack44/AffinityGroupService.go index 771848e..65954fc 100644 --- a/cloudstack44/AffinityGroupService.go +++ b/cloudstack44/AffinityGroupService.go @@ -115,15 +115,13 @@ func (s *AffinityGroupService) CreateAffinityGroup(p *CreateAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -227,15 +225,13 @@ func (s *AffinityGroupService) DeleteAffinityGroup(p *DeleteAffinityGroupParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -566,15 +562,13 @@ func (s *AffinityGroupService) UpdateVMAffinityGroup(p *UpdateVMAffinityGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/AlertService.go b/cloudstack44/AlertService.go index 18029d7..3d2b409 100644 --- a/cloudstack44/AlertService.go +++ b/cloudstack44/AlertService.go @@ -471,15 +471,13 @@ func (s *AlertService) GenerateAlert(p *GenerateAlertParams) (*GenerateAlertResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/AsyncjobService.go b/cloudstack44/AsyncjobService.go index 12faf01..d3d292c 100644 --- a/cloudstack44/AsyncjobService.go +++ b/cloudstack44/AsyncjobService.go @@ -20,6 +20,7 @@ import ( "encoding/json" "net/url" "strconv" + "time" ) type QueryAsyncJobResultParams struct { @@ -62,9 +63,10 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu // We should be able to retry on failure as this call is idempotent for i := 0; i < 3; i++ { resp, err = s.cs.newRequest("queryAsyncJobResult", p.toURLValues()) - if err != nil { - continue + if err == nil { + break } + time.Sleep(1 * time.Second) } if err != nil { return nil, err diff --git a/cloudstack44/AutoScaleService.go b/cloudstack44/AutoScaleService.go index 0a6289c..f3e5188 100644 --- a/cloudstack44/AutoScaleService.go +++ b/cloudstack44/AutoScaleService.go @@ -94,15 +94,13 @@ func (s *AutoScaleService) CreateCounter(p *CreateCounterParams) (*CreateCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -218,15 +216,13 @@ func (s *AutoScaleService) CreateCondition(p *CreateConditionParams) (*CreateCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -338,15 +334,13 @@ func (s *AutoScaleService) CreateAutoScalePolicy(p *CreateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -506,15 +500,13 @@ func (s *AutoScaleService) CreateAutoScaleVmProfile(p *CreateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -679,15 +671,13 @@ func (s *AutoScaleService) CreateAutoScaleVmGroup(p *CreateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -766,15 +756,13 @@ func (s *AutoScaleService) DeleteCounter(p *DeleteCounterParams) (*DeleteCounter // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -835,15 +823,13 @@ func (s *AutoScaleService) DeleteCondition(p *DeleteConditionParams) (*DeleteCon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -904,15 +890,13 @@ func (s *AutoScaleService) DeleteAutoScalePolicy(p *DeleteAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -973,15 +957,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmProfile(p *DeleteAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1042,15 +1024,13 @@ func (s *AutoScaleService) DeleteAutoScaleVmGroup(p *DeleteAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2208,15 +2188,13 @@ func (s *AutoScaleService) EnableAutoScaleVmGroup(p *EnableAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2295,15 +2273,13 @@ func (s *AutoScaleService) DisableAutoScaleVmGroup(p *DisableAutoScaleVmGroupPar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2418,15 +2394,13 @@ func (s *AutoScaleService) UpdateAutoScalePolicy(p *UpdateAutoScalePolicyParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2573,15 +2547,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmProfile(p *UpdateAutoScaleVmProfileP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2741,15 +2713,13 @@ func (s *AutoScaleService) UpdateAutoScaleVmGroup(p *UpdateAutoScaleVmGroupParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/BaremetalService.go b/cloudstack44/BaremetalService.go index c8dc13c..9ff00bf 100644 --- a/cloudstack44/BaremetalService.go +++ b/cloudstack44/BaremetalService.go @@ -139,15 +139,13 @@ func (s *BaremetalService) AddBaremetalPxeKickStartServer(p *AddBaremetalPxeKick // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -329,15 +327,13 @@ func (s *BaremetalService) AddBaremetalPxePingServer(p *AddBaremetalPxePingServe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -452,15 +448,13 @@ func (s *BaremetalService) AddBaremetalDhcp(p *AddBaremetalDhcpParams) (*AddBare // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/BigSwitchVNSService.go b/cloudstack44/BigSwitchVNSService.go index aa0d7f5..2c6f8c9 100644 --- a/cloudstack44/BigSwitchVNSService.go +++ b/cloudstack44/BigSwitchVNSService.go @@ -80,15 +80,13 @@ func (s *BigSwitchVNSService) AddBigSwitchVnsDevice(p *AddBigSwitchVnsDevicePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -157,15 +155,13 @@ func (s *BigSwitchVNSService) DeleteBigSwitchVnsDevice(p *DeleteBigSwitchVnsDevi // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/CertificateService.go b/cloudstack44/CertificateService.go index 938de08..dddca4f 100644 --- a/cloudstack44/CertificateService.go +++ b/cloudstack44/CertificateService.go @@ -114,15 +114,13 @@ func (s *CertificateService) UploadCustomCertificate(p *UploadCustomCertificateP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/ClusterService.go b/cloudstack44/ClusterService.go index 4406126..601f7a4 100644 --- a/cloudstack44/ClusterService.go +++ b/cloudstack44/ClusterService.go @@ -786,15 +786,13 @@ func (s *ClusterService) DedicateCluster(p *DedicateClusterParams) (*DedicateClu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -864,15 +862,13 @@ func (s *ClusterService) ReleaseDedicatedCluster(p *ReleaseDedicatedClusterParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/DomainService.go b/cloudstack44/DomainService.go index bed2382..6227e4e 100644 --- a/cloudstack44/DomainService.go +++ b/cloudstack44/DomainService.go @@ -251,15 +251,13 @@ func (s *DomainService) DeleteDomain(p *DeleteDomainParams) (*DeleteDomainRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/FirewallService.go b/cloudstack44/FirewallService.go index 9e81617..c9cb559 100644 --- a/cloudstack44/FirewallService.go +++ b/cloudstack44/FirewallService.go @@ -467,15 +467,13 @@ func (s *FirewallService) CreatePortForwardingRule(p *CreatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -567,15 +565,13 @@ func (s *FirewallService) DeletePortForwardingRule(p *DeletePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -725,15 +721,13 @@ func (s *FirewallService) UpdatePortForwardingRule(p *UpdatePortForwardingRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -920,15 +914,13 @@ func (s *FirewallService) CreateFirewallRule(p *CreateFirewallRuleParams) (*Crea // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1016,15 +1008,13 @@ func (s *FirewallService) DeleteFirewallRule(p *DeleteFirewallRuleParams) (*Dele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1369,15 +1359,13 @@ func (s *FirewallService) UpdateFirewallRule(p *UpdateFirewallRuleParams) (*Upda // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1560,15 +1548,13 @@ func (s *FirewallService) CreateEgressFirewallRule(p *CreateEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1656,15 +1642,13 @@ func (s *FirewallService) DeleteEgressFirewallRule(p *DeleteEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2015,15 +1999,13 @@ func (s *FirewallService) UpdateEgressFirewallRule(p *UpdateEgressFirewallRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2159,15 +2141,13 @@ func (s *FirewallService) AddPaloAltoFirewall(p *AddPaloAltoFirewallParams) (*Ad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2247,15 +2227,13 @@ func (s *FirewallService) DeletePaloAltoFirewall(p *DeletePaloAltoFirewallParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2328,15 +2306,13 @@ func (s *FirewallService) ConfigurePaloAltoFirewall(p *ConfigurePaloAltoFirewall // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/GuestOSService.go b/cloudstack44/GuestOSService.go index 9b60e12..87f9f68 100644 --- a/cloudstack44/GuestOSService.go +++ b/cloudstack44/GuestOSService.go @@ -406,15 +406,13 @@ func (s *GuestOSService) AddGuestOs(p *AddGuestOsParams) (*AddGuestOsResponse, e // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -494,15 +492,13 @@ func (s *GuestOSService) UpdateGuestOs(p *UpdateGuestOsParams) (*UpdateGuestOsRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -570,15 +566,13 @@ func (s *GuestOSService) RemoveGuestOs(p *RemoveGuestOsParams) (*RemoveGuestOsRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -840,15 +834,13 @@ func (s *GuestOSService) AddGuestOsMapping(p *AddGuestOsMappingParams) (*AddGues // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -931,15 +923,13 @@ func (s *GuestOSService) UpdateGuestOsMapping(p *UpdateGuestOsMappingParams) (*U // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1010,15 +1000,13 @@ func (s *GuestOSService) RemoveGuestOsMapping(p *RemoveGuestOsMappingParams) (*R // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/HostService.go b/cloudstack44/HostService.go index ba90332..7fd72a2 100644 --- a/cloudstack44/HostService.go +++ b/cloudstack44/HostService.go @@ -281,15 +281,13 @@ func (s *HostService) ReconnectHost(p *ReconnectHostParams) (*ReconnectHostRespo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -636,15 +634,13 @@ func (s *HostService) PrepareHostForMaintenance(p *PrepareHostForMaintenancePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -765,15 +761,13 @@ func (s *HostService) CancelHostMaintenance(p *CancelHostMaintenanceParams) (*Ca // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1515,15 +1509,13 @@ func (s *HostService) ReleaseHostReservation(p *ReleaseHostReservationParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1829,15 +1821,13 @@ func (s *HostService) DedicateHost(p *DedicateHostParams) (*DedicateHostResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1907,15 +1897,13 @@ func (s *HostService) ReleaseDedicatedHost(p *ReleaseDedicatedHostParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/ISOService.go b/cloudstack44/ISOService.go index 1497b97..b865f64 100644 --- a/cloudstack44/ISOService.go +++ b/cloudstack44/ISOService.go @@ -82,15 +82,13 @@ func (s *ISOService) AttachIso(p *AttachIsoParams) (*AttachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -321,15 +319,13 @@ func (s *ISOService) DetachIso(p *DetachIsoParams) (*DetachIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1443,15 +1439,13 @@ func (s *ISOService) DeleteIso(p *DeleteIsoParams) (*DeleteIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1535,15 +1529,13 @@ func (s *ISOService) CopyIso(p *CopyIsoParams) (*CopyIsoResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1897,15 +1889,13 @@ func (s *ISOService) ExtractIso(p *ExtractIsoParams) (*ExtractIsoResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/InternalLBService.go b/cloudstack44/InternalLBService.go index 5270afa..2be88d4 100644 --- a/cloudstack44/InternalLBService.go +++ b/cloudstack44/InternalLBService.go @@ -83,15 +83,13 @@ func (s *InternalLBService) ConfigureInternalLoadBalancerElement(p *ConfigureInt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -158,15 +156,13 @@ func (s *InternalLBService) CreateInternalLoadBalancerElement(p *CreateInternalL // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -386,15 +382,13 @@ func (s *InternalLBService) StopInternalLoadBalancerVM(p *StopInternalLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -523,15 +517,13 @@ func (s *InternalLBService) StartInternalLoadBalancerVM(p *StartInternalLoadBala // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/LoadBalancerService.go b/cloudstack44/LoadBalancerService.go index f26e02c..8974f24 100644 --- a/cloudstack44/LoadBalancerService.go +++ b/cloudstack44/LoadBalancerService.go @@ -221,15 +221,13 @@ func (s *LoadBalancerService) CreateLoadBalancerRule(p *CreateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -324,15 +322,13 @@ func (s *LoadBalancerService) DeleteLoadBalancerRule(p *DeleteLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -421,15 +417,13 @@ func (s *LoadBalancerService) RemoveFromLoadBalancerRule(p *RemoveFromLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -518,15 +512,13 @@ func (s *LoadBalancerService) AssignToLoadBalancerRule(p *AssignToLoadBalancerRu // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -650,15 +642,13 @@ func (s *LoadBalancerService) CreateLBStickinessPolicy(p *CreateLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -762,15 +752,13 @@ func (s *LoadBalancerService) UpdateLBStickinessPolicy(p *UpdateLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -851,15 +839,13 @@ func (s *LoadBalancerService) DeleteLBStickinessPolicy(p *DeleteLBStickinessPoli // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1666,15 +1652,13 @@ func (s *LoadBalancerService) CreateLBHealthCheckPolicy(p *CreateLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1777,15 +1761,13 @@ func (s *LoadBalancerService) UpdateLBHealthCheckPolicy(p *UpdateLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1865,15 +1847,13 @@ func (s *LoadBalancerService) DeleteLBHealthCheckPolicy(p *DeleteLBHealthCheckPo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2133,15 +2113,13 @@ func (s *LoadBalancerService) UpdateLoadBalancerRule(p *UpdateLoadBalancerRulePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2521,15 +2499,13 @@ func (s *LoadBalancerService) AssignCertToLoadBalancer(p *AssignCertToLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2590,15 +2566,13 @@ func (s *LoadBalancerService) RemoveCertFromLoadBalancer(p *RemoveCertFromLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2753,15 +2727,13 @@ func (s *LoadBalancerService) AddNetscalerLoadBalancer(p *AddNetscalerLoadBalanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2840,15 +2812,13 @@ func (s *LoadBalancerService) DeleteNetscalerLoadBalancer(p *DeleteNetscalerLoad // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2957,15 +2927,13 @@ func (s *LoadBalancerService) ConfigureNetscalerLoadBalancer(p *ConfigureNetscal // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3250,15 +3218,13 @@ func (s *LoadBalancerService) CreateGlobalLoadBalancerRule(p *CreateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3368,15 +3334,13 @@ func (s *LoadBalancerService) DeleteGlobalLoadBalancerRule(p *DeleteGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3470,15 +3434,13 @@ func (s *LoadBalancerService) UpdateGlobalLoadBalancerRule(p *UpdateGlobalLoadBa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3932,15 +3894,13 @@ func (s *LoadBalancerService) AssignToGlobalLoadBalancerRule(p *AssignToGlobalLo // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4014,15 +3974,13 @@ func (s *LoadBalancerService) RemoveFromGlobalLoadBalancerRule(p *RemoveFromGlob // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4191,15 +4149,13 @@ func (s *LoadBalancerService) CreateLoadBalancer(p *CreateLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4659,15 +4615,13 @@ func (s *LoadBalancerService) DeleteLoadBalancer(p *DeleteLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4751,15 +4705,13 @@ func (s *LoadBalancerService) UpdateLoadBalancer(p *UpdateLoadBalancerParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/NATService.go b/cloudstack44/NATService.go index 429f04c..2c977fe 100644 --- a/cloudstack44/NATService.go +++ b/cloudstack44/NATService.go @@ -216,15 +216,13 @@ func (s *NATService) CreateIpForwardingRule(p *CreateIpForwardingRuleParams) (*C // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -316,15 +314,13 @@ func (s *NATService) DeleteIpForwardingRule(p *DeleteIpForwardingRuleParams) (*D // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -622,15 +618,13 @@ func (s *NATService) DisableStaticNat(p *DisableStaticNatParams) (*DisableStatic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/NetworkACLService.go b/cloudstack44/NetworkACLService.go index fded6a0..b862612 100644 --- a/cloudstack44/NetworkACLService.go +++ b/cloudstack44/NetworkACLService.go @@ -198,15 +198,13 @@ func (s *NetworkACLService) CreateNetworkACL(p *CreateNetworkACLParams) (*Create // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -423,15 +421,13 @@ func (s *NetworkACLService) UpdateNetworkACLItem(p *UpdateNetworkACLItemParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -520,15 +516,13 @@ func (s *NetworkACLService) DeleteNetworkACL(p *DeleteNetworkACLParams) (*Delete // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -919,15 +913,13 @@ func (s *NetworkACLService) CreateNetworkACLList(p *CreateNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -996,15 +988,13 @@ func (s *NetworkACLService) DeleteNetworkACLList(p *DeleteNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1087,15 +1077,13 @@ func (s *NetworkACLService) ReplaceNetworkACLList(p *ReplaceNetworkACLListParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1470,15 +1458,13 @@ func (s *NetworkACLService) UpdateNetworkACLList(p *UpdateNetworkACLListParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/NetworkService.go b/cloudstack44/NetworkService.go index 8b0525c..cfa3d32 100644 --- a/cloudstack44/NetworkService.go +++ b/cloudstack44/NetworkService.go @@ -628,15 +628,13 @@ func (s *NetworkService) DeleteNetwork(p *DeleteNetworkParams) (*DeleteNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1191,15 +1189,13 @@ func (s *NetworkService) RestartNetwork(p *RestartNetworkParams) (*RestartNetwor // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1394,15 +1390,13 @@ func (s *NetworkService) UpdateNetwork(p *UpdateNetworkParams) (*UpdateNetworkRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1621,15 +1615,13 @@ func (s *NetworkService) CreatePhysicalNetwork(p *CreatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1703,15 +1695,13 @@ func (s *NetworkService) DeletePhysicalNetwork(p *DeletePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2008,15 +1998,13 @@ func (s *NetworkService) UpdatePhysicalNetwork(p *UpdatePhysicalNetworkParams) ( // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2239,15 +2227,13 @@ func (s *NetworkService) AddNetworkServiceProvider(p *AddNetworkServiceProviderP // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2318,15 +2304,13 @@ func (s *NetworkService) DeleteNetworkServiceProvider(p *DeleteNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2557,15 +2541,13 @@ func (s *NetworkService) UpdateNetworkServiceProvider(p *UpdateNetworkServicePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2695,15 +2677,13 @@ func (s *NetworkService) CreateStorageNetworkIpRange(p *CreateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2776,15 +2756,13 @@ func (s *NetworkService) DeleteStorageNetworkIpRange(p *DeleteStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3036,15 +3014,13 @@ func (s *NetworkService) UpdateStorageNetworkIpRange(p *UpdateStorageNetworkIpRa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/NicService.go b/cloudstack44/NicService.go index f45e79b..ef223f6 100644 --- a/cloudstack44/NicService.go +++ b/cloudstack44/NicService.go @@ -79,15 +79,13 @@ func (s *NicService) AddIpToNic(p *AddIpToNicParams) (*AddIpToNicResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -156,15 +154,13 @@ func (s *NicService) RemoveIpFromNic(p *RemoveIpFromNicParams) (*RemoveIpFromNic // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/NiciraNVPService.go b/cloudstack44/NiciraNVPService.go index caaa4a2..7b64541 100644 --- a/cloudstack44/NiciraNVPService.go +++ b/cloudstack44/NiciraNVPService.go @@ -127,15 +127,13 @@ func (s *NiciraNVPService) AddNiciraNvpDevice(p *AddNiciraNvpDeviceParams) (*Add // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -206,15 +204,13 @@ func (s *NiciraNVPService) DeleteNiciraNvpDevice(p *DeleteNiciraNvpDeviceParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/OvsElementService.go b/cloudstack44/OvsElementService.go index ad6b07b..a23ec19 100644 --- a/cloudstack44/OvsElementService.go +++ b/cloudstack44/OvsElementService.go @@ -83,15 +83,13 @@ func (s *OvsElementService) ConfigureOvsElement(p *ConfigureOvsElementParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/PodService.go b/cloudstack44/PodService.go index d704876..6c249bb 100644 --- a/cloudstack44/PodService.go +++ b/cloudstack44/PodService.go @@ -645,15 +645,13 @@ func (s *PodService) DedicatePod(p *DedicatePodParams) (*DedicatePodResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -723,15 +721,13 @@ func (s *PodService) ReleaseDedicatedPod(p *ReleaseDedicatedPodParams) (*Release // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/PortableIPService.go b/cloudstack44/PortableIPService.go index 6eea331..7246ffd 100644 --- a/cloudstack44/PortableIPService.go +++ b/cloudstack44/PortableIPService.go @@ -130,15 +130,13 @@ func (s *PortableIPService) CreatePortableIpRange(p *CreatePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -221,15 +219,13 @@ func (s *PortableIPService) DeletePortableIpRange(p *DeletePortableIpRangeParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/ProjectService.go b/cloudstack44/ProjectService.go index e397572..f23fcbb 100644 --- a/cloudstack44/ProjectService.go +++ b/cloudstack44/ProjectService.go @@ -104,15 +104,13 @@ func (s *ProjectService) CreateProject(p *CreateProjectParams) (*CreateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -230,15 +228,13 @@ func (s *ProjectService) DeleteProject(p *DeleteProjectParams) (*DeleteProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -321,15 +317,13 @@ func (s *ProjectService) UpdateProject(p *UpdateProjectParams) (*UpdateProjectRe // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -447,15 +441,13 @@ func (s *ProjectService) ActivateProject(p *ActivateProjectParams) (*ActivatePro // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -573,15 +565,13 @@ func (s *ProjectService) SuspendProject(p *SuspendProjectParams) (*SuspendProjec // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1259,15 +1249,13 @@ func (s *ProjectService) UpdateProjectInvitation(p *UpdateProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1328,15 +1316,13 @@ func (s *ProjectService) DeleteProjectInvitation(p *DeleteProjectInvitationParam // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/ResourcemetadataService.go b/cloudstack44/ResourcemetadataService.go index c7bac1c..f4d9dcf 100644 --- a/cloudstack44/ResourcemetadataService.go +++ b/cloudstack44/ResourcemetadataService.go @@ -110,15 +110,13 @@ func (s *ResourcemetadataService) AddResourceDetail(p *AddResourceDetailParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -202,15 +200,13 @@ func (s *ResourcemetadataService) RemoveResourceDetail(p *RemoveResourceDetailPa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/ResourcetagsService.go b/cloudstack44/ResourcetagsService.go index cf428f1..4da94f9 100644 --- a/cloudstack44/ResourcetagsService.go +++ b/cloudstack44/ResourcetagsService.go @@ -111,15 +111,13 @@ func (s *ResourcetagsService) CreateTags(p *CreateTagsParams) (*CreateTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -209,15 +207,13 @@ func (s *ResourcetagsService) DeleteTags(p *DeleteTagsParams) (*DeleteTagsRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/RouterService.go b/cloudstack44/RouterService.go index 47f4add..b2b4825 100644 --- a/cloudstack44/RouterService.go +++ b/cloudstack44/RouterService.go @@ -70,15 +70,13 @@ func (s *RouterService) StartRouter(p *StartRouterParams) (*StartRouterResponse, // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -207,15 +205,13 @@ func (s *RouterService) RebootRouter(p *RebootRouterParams) (*RebootRouterRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -356,15 +352,13 @@ func (s *RouterService) StopRouter(p *StopRouterParams) (*StopRouterResponse, er // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -493,15 +487,13 @@ func (s *RouterService) DestroyRouter(p *DestroyRouterParams) (*DestroyRouterRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1332,15 +1324,13 @@ func (s *RouterService) ConfigureVirtualRouterElement(p *ConfigureVirtualRouterE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1423,15 +1413,13 @@ func (s *RouterService) CreateVirtualRouterElement(p *CreateVirtualRouterElement // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/SSHService.go b/cloudstack44/SSHService.go index db5e980..4b5039b 100644 --- a/cloudstack44/SSHService.go +++ b/cloudstack44/SSHService.go @@ -113,15 +113,13 @@ func (s *SSHService) ResetSSHKeyForVirtualMachine(p *ResetSSHKeyForVirtualMachin // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/SecurityGroupService.go b/cloudstack44/SecurityGroupService.go index 75357c2..bd222c9 100644 --- a/cloudstack44/SecurityGroupService.go +++ b/cloudstack44/SecurityGroupService.go @@ -453,15 +453,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupIngress(p *AuthorizeSecurit // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -546,15 +544,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupIngress(p *RevokeSecurityGroup // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -745,15 +741,13 @@ func (s *SecurityGroupService) AuthorizeSecurityGroupEgress(p *AuthorizeSecurity // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -838,15 +832,13 @@ func (s *SecurityGroupService) RevokeSecurityGroupEgress(p *RevokeSecurityGroupE // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/SnapshotService.go b/cloudstack44/SnapshotService.go index 79f5970..67f9fa3 100644 --- a/cloudstack44/SnapshotService.go +++ b/cloudstack44/SnapshotService.go @@ -115,15 +115,13 @@ func (s *SnapshotService) CreateSnapshot(p *CreateSnapshotParams) (*CreateSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -555,15 +553,13 @@ func (s *SnapshotService) DeleteSnapshot(p *DeleteSnapshotParams) (*DeleteSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -763,15 +759,13 @@ func (s *SnapshotService) UpdateSnapshotPolicy(p *UpdateSnapshotPolicyParams) (* // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1049,15 +1043,13 @@ func (s *SnapshotService) RevertSnapshot(p *RevertSnapshotParams) (*RevertSnapsh // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1446,15 +1438,13 @@ func (s *SnapshotService) CreateVMSnapshot(p *CreateVMSnapshotParams) (*CreateVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1535,15 +1525,13 @@ func (s *SnapshotService) DeleteVMSnapshot(p *DeleteVMSnapshotParams) (*DeleteVM // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1604,15 +1592,13 @@ func (s *SnapshotService) RevertToVMSnapshot(p *RevertToVMSnapshotParams) (*Reve // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/StoragePoolService.go b/cloudstack44/StoragePoolService.go index fe2e9cf..8a9ffa4 100644 --- a/cloudstack44/StoragePoolService.go +++ b/cloudstack44/StoragePoolService.go @@ -159,15 +159,13 @@ func (s *StoragePoolService) EnableStorageMaintenance(p *EnableStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -254,15 +252,13 @@ func (s *StoragePoolService) CancelStorageMaintenance(p *CancelStorageMaintenanc // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/SystemVMService.go b/cloudstack44/SystemVMService.go index f8d5eaf..8257574 100644 --- a/cloudstack44/SystemVMService.go +++ b/cloudstack44/SystemVMService.go @@ -70,15 +70,13 @@ func (s *SystemVMService) StartSystemVm(p *StartSystemVmParams) (*StartSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -169,15 +167,13 @@ func (s *SystemVMService) RebootSystemVm(p *RebootSystemVmParams) (*RebootSystem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -280,15 +276,13 @@ func (s *SystemVMService) StopSystemVm(p *StopSystemVmParams) (*StopSystemVmResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -379,15 +373,13 @@ func (s *SystemVMService) DestroySystemVm(p *DestroySystemVmParams) (*DestroySys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -753,15 +745,13 @@ func (s *SystemVMService) MigrateSystemVm(p *MigrateSystemVmParams) (*MigrateSys // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -984,15 +974,13 @@ func (s *SystemVMService) ScaleSystemVm(p *ScaleSystemVmParams) (*ScaleSystemVmR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/TemplateService.go b/cloudstack44/TemplateService.go index de79d3f..32dc5ea 100644 --- a/cloudstack44/TemplateService.go +++ b/cloudstack44/TemplateService.go @@ -237,15 +237,13 @@ func (s *TemplateService) CreateTemplate(p *CreateTemplateParams) (*CreateTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -947,15 +945,13 @@ func (s *TemplateService) CopyTemplate(p *CopyTemplateParams) (*CopyTemplateResp // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1077,15 +1073,13 @@ func (s *TemplateService) DeleteTemplate(p *DeleteTemplateParams) (*DeleteTempla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1753,15 +1747,13 @@ func (s *TemplateService) ExtractTemplate(p *ExtractTemplateParams) (*ExtractTem // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/UCSService.go b/cloudstack44/UCSService.go index b1afbe0..f3cf35c 100644 --- a/cloudstack44/UCSService.go +++ b/cloudstack44/UCSService.go @@ -552,15 +552,13 @@ func (s *UCSService) AssociateUcsProfileToBlade(p *AssociateUcsProfileToBladePar // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/UsageService.go b/cloudstack44/UsageService.go index 33d5c38..e69c0ac 100644 --- a/cloudstack44/UsageService.go +++ b/cloudstack44/UsageService.go @@ -147,15 +147,13 @@ func (s *UsageService) AddTrafficType(p *AddTrafficTypeParams) (*AddTrafficTypeR // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -226,15 +224,13 @@ func (s *UsageService) DeleteTrafficType(p *DeleteTrafficTypeParams) (*DeleteTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -466,15 +462,13 @@ func (s *UsageService) UpdateTrafficType(p *UpdateTrafficTypeParams) (*UpdateTra // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/UserService.go b/cloudstack44/UserService.go index 78d861a..53e1206 100644 --- a/cloudstack44/UserService.go +++ b/cloudstack44/UserService.go @@ -712,15 +712,13 @@ func (s *UserService) DisableUser(p *DisableUserParams) (*DisableUserResponse, e // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/VLANService.go b/cloudstack44/VLANService.go index 7a6a2d5..e001fda 100644 --- a/cloudstack44/VLANService.go +++ b/cloudstack44/VLANService.go @@ -725,15 +725,13 @@ func (s *VLANService) ReleaseDedicatedGuestVlanRange(p *ReleaseDedicatedGuestVla // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/VPCService.go b/cloudstack44/VPCService.go index a5eff9b..5db5d2f 100644 --- a/cloudstack44/VPCService.go +++ b/cloudstack44/VPCService.go @@ -186,15 +186,13 @@ func (s *VPCService) CreateVPC(p *CreateVPCParams) (*CreateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -867,15 +865,13 @@ func (s *VPCService) DeleteVPC(p *DeleteVPCParams) (*DeleteVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -981,15 +977,13 @@ func (s *VPCService) UpdateVPC(p *UpdateVPCParams) (*UpdateVPCResponse, error) { // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1178,15 +1172,13 @@ func (s *VPCService) RestartVPC(p *RestartVPCParams) (*RestartVPCResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1443,15 +1435,13 @@ func (s *VPCService) CreateVPCOffering(p *CreateVPCOfferingParams) (*CreateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1573,15 +1563,13 @@ func (s *VPCService) UpdateVPCOffering(p *UpdateVPCOfferingParams) (*UpdateVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1670,15 +1658,13 @@ func (s *VPCService) DeleteVPCOffering(p *DeleteVPCOfferingParams) (*DeleteVPCOf // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2073,15 +2059,13 @@ func (s *VPCService) CreatePrivateGateway(p *CreatePrivateGatewayParams) (*Creat // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2410,15 +2394,13 @@ func (s *VPCService) DeletePrivateGateway(p *DeletePrivateGatewayParams) (*Delet // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -2491,15 +2473,13 @@ func (s *VPCService) CreateStaticRoute(p *CreateStaticRouteParams) (*CreateStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2585,15 +2565,13 @@ func (s *VPCService) DeleteStaticRoute(p *DeleteStaticRouteParams) (*DeleteStati // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/VPNService.go b/cloudstack44/VPNService.go index 1089959..79e1f6b 100644 --- a/cloudstack44/VPNService.go +++ b/cloudstack44/VPNService.go @@ -127,15 +127,13 @@ func (s *VPNService) CreateRemoteAccessVpn(p *CreateRemoteAccessVpnParams) (*Cre // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -211,15 +209,13 @@ func (s *VPNService) DeleteRemoteAccessVpn(p *DeleteRemoteAccessVpnParams) (*Del // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -536,15 +532,13 @@ func (s *VPNService) UpdateRemoteAccessVpn(p *UpdateRemoteAccessVpnParams) (*Upd // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -665,15 +659,13 @@ func (s *VPNService) AddVpnUser(p *AddVpnUserParams) (*AddVpnUserResponse, error // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -778,15 +770,13 @@ func (s *VPNService) RemoveVpnUser(p *RemoveVpnUserParams) (*RemoveVpnUserRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1170,15 +1160,13 @@ func (s *VPNService) CreateVpnCustomerGateway(p *CreateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1271,15 +1259,13 @@ func (s *VPNService) CreateVpnGateway(p *CreateVpnGatewayParams) (*CreateVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1389,15 +1375,13 @@ func (s *VPNService) CreateVpnConnection(p *CreateVpnConnectionParams) (*CreateV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1483,15 +1467,13 @@ func (s *VPNService) DeleteVpnCustomerGateway(p *DeleteVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1552,15 +1534,13 @@ func (s *VPNService) DeleteVpnGateway(p *DeleteVpnGatewayParams) (*DeleteVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1621,15 +1601,13 @@ func (s *VPNService) DeleteVpnConnection(p *DeleteVpnConnectionParams) (*DeleteV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -1819,15 +1797,13 @@ func (s *VPNService) UpdateVpnCustomerGateway(p *UpdateVpnCustomerGatewayParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1930,15 +1906,13 @@ func (s *VPNService) ResetVpnConnection(p *ResetVpnConnectionParams) (*ResetVpnC // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2757,15 +2731,13 @@ func (s *VPNService) UpdateVpnConnection(p *UpdateVpnConnectionParams) (*UpdateV // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2874,15 +2846,13 @@ func (s *VPNService) UpdateVpnGateway(p *UpdateVpnGatewayParams) (*UpdateVpnGate // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/VirtualMachineService.go b/cloudstack44/VirtualMachineService.go index daa5c03..b6de53a 100644 --- a/cloudstack44/VirtualMachineService.go +++ b/cloudstack44/VirtualMachineService.go @@ -410,15 +410,13 @@ func (s *VirtualMachineService) DeployVirtualMachine(p *DeployVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -661,15 +659,13 @@ func (s *VirtualMachineService) DestroyVirtualMachine(p *DestroyVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -900,15 +896,13 @@ func (s *VirtualMachineService) RebootVirtualMachine(p *RebootVirtualMachinePara // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1161,15 +1155,13 @@ func (s *VirtualMachineService) StartVirtualMachine(p *StartVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1412,15 +1404,13 @@ func (s *VirtualMachineService) StopVirtualMachine(p *StopVirtualMachineParams) // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1651,15 +1641,13 @@ func (s *VirtualMachineService) ResetPasswordForVirtualMachine(p *ResetPasswordF // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -2920,15 +2908,13 @@ func (s *VirtualMachineService) RestoreVirtualMachine(p *RestoreVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -3431,15 +3417,13 @@ func (s *VirtualMachineService) ScaleVirtualMachine(p *ScaleVirtualMachineParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -3786,15 +3770,13 @@ func (s *VirtualMachineService) MigrateVirtualMachine(p *MigrateVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4053,15 +4035,13 @@ func (s *VirtualMachineService) MigrateVirtualMachineWithVolume(p *MigrateVirtua // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4508,15 +4488,13 @@ func (s *VirtualMachineService) ExpungeVirtualMachine(p *ExpungeVirtualMachinePa // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4565,15 +4543,13 @@ func (s *VirtualMachineService) CleanVMReservations(p *CleanVMReservationsParams // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err @@ -4657,15 +4633,13 @@ func (s *VirtualMachineService) AddNicToVirtualMachine(p *AddNicToVirtualMachine // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -4908,15 +4882,13 @@ func (s *VirtualMachineService) RemoveNicFromVirtualMachine(p *RemoveNicFromVirt // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -5159,15 +5131,13 @@ func (s *VirtualMachineService) UpdateDefaultNicForVirtualMachine(p *UpdateDefau // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/VolumeService.go b/cloudstack44/VolumeService.go index 052dbae..86d4200 100644 --- a/cloudstack44/VolumeService.go +++ b/cloudstack44/VolumeService.go @@ -94,15 +94,13 @@ func (s *VolumeService) AttachVolume(p *AttachVolumeParams) (*AttachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -329,15 +327,13 @@ func (s *VolumeService) UploadVolume(p *UploadVolumeParams) (*UploadVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -484,15 +480,13 @@ func (s *VolumeService) DetachVolume(p *DetachVolumeParams) (*DetachVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -753,15 +747,13 @@ func (s *VolumeService) CreateVolume(p *CreateVolumeParams) (*CreateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1390,15 +1382,13 @@ func (s *VolumeService) ExtractVolume(p *ExtractVolumeParams) (*ExtractVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1500,15 +1490,13 @@ func (s *VolumeService) MigrateVolume(p *MigrateVolumeParams) (*MigrateVolumeRes // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1668,15 +1656,13 @@ func (s *VolumeService) ResizeVolume(p *ResizeVolumeParams) (*ResizeVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1867,15 +1853,13 @@ func (s *VolumeService) UpdateVolume(p *UpdateVolumeParams) (*UpdateVolumeRespon // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { diff --git a/cloudstack44/ZoneService.go b/cloudstack44/ZoneService.go index c5e6fd9..8fe3bad 100644 --- a/cloudstack44/ZoneService.go +++ b/cloudstack44/ZoneService.go @@ -933,15 +933,13 @@ func (s *ZoneService) DedicateZone(p *DedicateZoneParams) (*DedicateZoneResponse // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } b, err = getRawValue(b) if err != nil { @@ -1011,15 +1009,13 @@ func (s *ZoneService) ReleaseDedicatedZone(p *ReleaseDedicatedZoneParams) (*Rele // If we have a async client, we need to wait for the async result if s.cs.async { - b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) + b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout) if err != nil { + if err == AsyncTimeoutErr { + return &r, err + } return nil, err } - // If 'warn' has a value it means the job is running longer than the configured - // timeout, the resonse will contain the jobid of the running async job - if warn != nil { - return &r, warn - } if err := json.Unmarshal(b, &r); err != nil { return nil, err diff --git a/cloudstack44/cloudstack.go b/cloudstack44/cloudstack.go index e732f24..8fa7abf 100644 --- a/cloudstack44/cloudstack.go +++ b/cloudstack44/cloudstack.go @@ -23,6 +23,7 @@ import ( "crypto/tls" "encoding/base64" "encoding/json" + "errors" "fmt" "io/ioutil" "net/http" @@ -50,7 +51,7 @@ type CloudStackClient struct { apiKey string // Api key secret string // Secret key async bool // Wait for async calls to finish - timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds + timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds APIDiscovery *APIDiscoveryService Account *AccountService @@ -131,7 +132,7 @@ func newClient(apiurl string, apikey string, secret string, async bool, verifyss apiKey: apikey, secret: secret, async: async, - timeout: 60, + timeout: 300, } cs.APIDiscovery = NewAPIDiscoveryService(cs) cs.Account = NewAccountService(cs) @@ -216,39 +217,41 @@ func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) return cs } -// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60 +// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds // seconds, to check if the async job is finished. func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) { cs.timeout = timeoutInSeconds } +var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish") + // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured -// timeout, the async job return a warning saying the timer has expired. -func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (b json.RawMessage, warn error, err error) { +// timeout, the async job returns a AsyncTimeoutErr. +func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { currentTime := time.Now().Unix() for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) if err != nil { - return nil, nil, err + return nil, err } // Status 1 means the job is finished successfully if r.Jobstatus == 1 { - return r.Jobresult, nil, nil + return r.Jobresult, nil } // When the status is 2, the job has failed if r.Jobstatus == 2 { if r.Jobresulttype == "text" { - return nil, nil, fmt.Errorf(string(r.Jobresult)) + return nil, fmt.Errorf(string(r.Jobresult)) } else { - return nil, nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) + return nil, fmt.Errorf("Undefined error: %s", string(r.Jobresult)) } } if time.Now().Unix()-currentTime > timeout { - return nil, fmt.Errorf("Timeout while waiting for async job to finish"), nil + return nil, AsyncTimeoutErr } time.Sleep(3 * time.Second) } diff --git a/generate/generate.go b/generate/generate.go index 5a5b592..e489b07 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -99,6 +99,7 @@ func (s services) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +// APIParams represents a list of API params type APIParams []*APIParam // Add functions for the Sort interface @@ -114,6 +115,7 @@ func (s APIParams) Swap(i, j int) { s[i], s[j] = s[j], s[i] } +// API represents an API endpoint we can call type API struct { Name string `json:"name"` Description string `json:"description"` @@ -122,6 +124,7 @@ type API struct { Response APIResponses `json:"response"` } +// APIParam represents a single API parameter type APIParam struct { Name string `json:"name"` Description string `json:"description"` @@ -129,6 +132,7 @@ type APIParam struct { Required bool `json:"required"` } +// APIResponse represents a API response type APIResponse struct { Name string `json:"name"` Description string `json:"description"` @@ -136,6 +140,7 @@ type APIResponse struct { Response APIResponses `json:"response,omitempty"` } +// APIResponses represents a list of API responses type APIResponses []*APIResponse // Add functions for the Sort interface @@ -259,7 +264,7 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn(" apiKey string // Api key") pn(" secret string // Secret key") pn(" async bool // Wait for async calls to finish") - pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 60 seconds") + pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds") pn("") for _, s := range as.services { pn(" %s *%s", strings.TrimSuffix(s.name, "Service"), s.name) @@ -280,7 +285,7 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn(" apiKey: apikey,") pn(" secret: secret,") pn(" async: async,") - pn(" timeout: 60,") + pn(" timeout: 300,") pn(" }") for _, s := range as.services { pn(" cs.%s = New%s(cs)", strings.TrimSuffix(s.name, "Service"), s.name) @@ -305,39 +310,41 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn(" return cs") pn("}") pn("") - pn("// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 60") + pn("// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds") pn("// seconds, to check if the async job is finished.") pn("func (cs *CloudStackClient) AsyncTimeout(timeoutInSeconds int64) {") pn(" cs.timeout = timeoutInSeconds") pn("}") pn("") + pn("var AsyncTimeoutErr = errors.New(\"Timeout while waiting for async job to finish\")") + pn("") pn("// A helper function that you can use to get the result of a running async job. If the job is not finished within the configured") - pn("// timeout, the async job return a warning saying the timer has expired.") - pn("func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (b json.RawMessage, warn error, err error) {") + pn("// timeout, the async job returns a AsyncTimeoutErr.") + pn("func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) {") pn(" currentTime := time.Now().Unix()") pn(" for {") pn(" p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid)") pn(" r, err := cs.Asyncjob.QueryAsyncJobResult(p)") pn(" if err != nil {") - pn(" return nil, nil, err") + pn(" return nil, err") pn(" }") pn("") pn(" // Status 1 means the job is finished successfully") pn(" if r.Jobstatus == 1 {") - pn(" return r.Jobresult, nil, nil") + pn(" return r.Jobresult, nil") pn(" }") pn("") pn(" // When the status is 2, the job has failed") pn(" if r.Jobstatus == 2 {") pn(" if r.Jobresulttype == \"text\" {") - pn(" return nil, nil, fmt.Errorf(string(r.Jobresult))") + pn(" return nil, fmt.Errorf(string(r.Jobresult))") pn(" } else {") - pn(" return nil, nil, fmt.Errorf(\"Undefined error: %%s\", string(r.Jobresult))") + pn(" return nil, fmt.Errorf(\"Undefined error: %%s\", string(r.Jobresult))") pn(" }") pn(" }") pn("") pn(" if time.Now().Unix()-currentTime > timeout {") - pn(" return nil, fmt.Errorf(\"Timeout while waiting for async job to finish\"), nil") + pn(" return nil, AsyncTimeoutErr") pn(" }") pn(" time.Sleep(3 * time.Second)") pn(" }") @@ -938,9 +945,10 @@ func (s *service) generateNewAPICallFunc(a *API) { pn(" // We should be able to retry on failure as this call is idempotent") pn(" for i := 0; i < 3; i++ {") pn(" resp, err = s.cs.newRequest(\"%s\", p.toURLValues())", a.Name) - pn(" if (err != nil) {") - pn(" continue") + pn(" if err == nil {") + pn(" break") pn(" }") + pn(" time.Sleep(1 * time.Second)") pn(" }") } else { pn(" resp, err := s.cs.newRequest(\"%s\", p.toURLValues())", a.Name) @@ -963,15 +971,13 @@ func (s *service) generateNewAPICallFunc(a *API) { pn("") pn(" // If we have a async client, we need to wait for the async result") pn(" if s.cs.async {") - pn(" b, warn, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)") + pn(" b, err := s.cs.GetAsyncJobResult(r.JobID, s.cs.timeout)") pn(" if err != nil {") + pn(" if err == AsyncTimeoutErr {") + pn(" return &r, err") + pn(" }") pn(" return nil, err") pn(" }") - pn(" // If 'warn' has a value it means the job is running longer than the configured") - pn(" // timeout, the resonse will contain the jobid of the running async job") - pn(" if warn != nil {") - pn(" return &r, warn") - pn(" }") pn("") if !isSuccessOnlyResponse(a.Response) { pn(" b, err = getRawValue(b)") @@ -1093,7 +1099,7 @@ func (s *service) recusiveGenerateResponseType(resp APIResponses, async bool) (o func getAllServices() (*allServices, []error, error) { // Get a map with all API info - ai, err := getApiInfo() + ai, err := getAPIInfo() if err != nil { return nil, nil, err } @@ -1120,7 +1126,7 @@ func getAllServices() (*allServices, []error, error) { return as, errors, nil } -func getApiInfo() (map[string]*API, error) { +func getAPIInfo() (map[string]*API, error) { var apiInfo []byte switch *version { From 60afae5afce5a8052aaaa6ac3890ca87ab249361 Mon Sep 17 00:00:00 2001 From: Sander van Harmelen Date: Thu, 3 Dec 2015 12:17:44 +0100 Subject: [PATCH 2/2] Add a simple kind of exponential backoff feature for async clients --- cloudstack/AsyncjobService.go | 2 +- cloudstack/cloudstack.go | 11 +- cloudstack43/AsyncjobService.go | 2 +- cloudstack43/cloudstack.go | 11 +- cloudstack44/AsyncjobService.go | 2 +- cloudstack44/cloudstack.go | 11 +- generate/generate.go | 213 +++++++++++++++++--------------- 7 files changed, 144 insertions(+), 108 deletions(-) diff --git a/cloudstack/AsyncjobService.go b/cloudstack/AsyncjobService.go index 348830c..2266be9 100644 --- a/cloudstack/AsyncjobService.go +++ b/cloudstack/AsyncjobService.go @@ -66,7 +66,7 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu if err == nil { break } - time.Sleep(1 * time.Second) + time.Sleep(500 * time.Millisecond) } if err != nil { return nil, err diff --git a/cloudstack/cloudstack.go b/cloudstack/cloudstack.go index 2744755..20eb3a7 100644 --- a/cloudstack/cloudstack.go +++ b/cloudstack/cloudstack.go @@ -228,7 +228,9 @@ var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish" // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured // timeout, the async job returns a AsyncTimeoutErr. func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { + var timer time.Duration currentTime := time.Now().Unix() + for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) @@ -253,7 +255,14 @@ func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json if time.Now().Unix()-currentTime > timeout { return nil, AsyncTimeoutErr } - time.Sleep(3 * time.Second) + + // Add an (extremely simple) exponential backoff like feature to prevent + // flooding the CloudStack API + if timer < 15 { + timer++ + } + + time.Sleep(timer * time.Second) } } diff --git a/cloudstack43/AsyncjobService.go b/cloudstack43/AsyncjobService.go index c078ff1..82e73b3 100644 --- a/cloudstack43/AsyncjobService.go +++ b/cloudstack43/AsyncjobService.go @@ -66,7 +66,7 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu if err == nil { break } - time.Sleep(1 * time.Second) + time.Sleep(500 * time.Millisecond) } if err != nil { return nil, err diff --git a/cloudstack43/cloudstack.go b/cloudstack43/cloudstack.go index bcd4076..466b70d 100644 --- a/cloudstack43/cloudstack.go +++ b/cloudstack43/cloudstack.go @@ -230,7 +230,9 @@ var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish" // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured // timeout, the async job returns a AsyncTimeoutErr. func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { + var timer time.Duration currentTime := time.Now().Unix() + for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) @@ -255,7 +257,14 @@ func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json if time.Now().Unix()-currentTime > timeout { return nil, AsyncTimeoutErr } - time.Sleep(3 * time.Second) + + // Add an (extremely simple) exponential backoff like feature to prevent + // flooding the CloudStack API + if timer < 15 { + timer++ + } + + time.Sleep(timer * time.Second) } } diff --git a/cloudstack44/AsyncjobService.go b/cloudstack44/AsyncjobService.go index d3d292c..f125f25 100644 --- a/cloudstack44/AsyncjobService.go +++ b/cloudstack44/AsyncjobService.go @@ -66,7 +66,7 @@ func (s *AsyncjobService) QueryAsyncJobResult(p *QueryAsyncJobResultParams) (*Qu if err == nil { break } - time.Sleep(1 * time.Second) + time.Sleep(500 * time.Millisecond) } if err != nil { return nil, err diff --git a/cloudstack44/cloudstack.go b/cloudstack44/cloudstack.go index 8fa7abf..23ce560 100644 --- a/cloudstack44/cloudstack.go +++ b/cloudstack44/cloudstack.go @@ -228,7 +228,9 @@ var AsyncTimeoutErr = errors.New("Timeout while waiting for async job to finish" // A helper function that you can use to get the result of a running async job. If the job is not finished within the configured // timeout, the async job returns a AsyncTimeoutErr. func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) { + var timer time.Duration currentTime := time.Now().Unix() + for { p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid) r, err := cs.Asyncjob.QueryAsyncJobResult(p) @@ -253,7 +255,14 @@ func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json if time.Now().Unix()-currentTime > timeout { return nil, AsyncTimeoutErr } - time.Sleep(3 * time.Second) + + // Add an (extremely simple) exponential backoff like feature to prevent + // flooding the CloudStack API + if timer < 15 { + timer++ + } + + time.Sleep(timer * time.Second) } } diff --git a/generate/generate.go b/generate/generate.go index e489b07..4762803 100644 --- a/generate/generate.go +++ b/generate/generate.go @@ -247,24 +247,24 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn(")") pn("") pn("type CSError struct {") - pn(" ErrorCode int `json:\"errorcode\"`") - pn(" CSErrorCode int `json:\"cserrorcode\"`") - pn(" ErrorText string `json:\"errortext\"`") + pn(" ErrorCode int `json:\"errorcode\"`") + pn(" CSErrorCode int `json:\"cserrorcode\"`") + pn(" ErrorText string `json:\"errortext\"`") pn("}") pn("") pn("func (e *CSError) Error() error {") - pn(" return fmt.Errorf(\"CloudStack API error %%d (CSExceptionErrorCode: %%d): %%s\", e.ErrorCode, e.CSErrorCode, e.ErrorText)") + pn(" return fmt.Errorf(\"CloudStack API error %%d (CSExceptionErrorCode: %%d): %%s\", e.ErrorCode, e.CSErrorCode, e.ErrorText)") pn("}") pn("") pn("type CloudStackClient struct {") - pn(" HTTPGETOnly bool // If `true` only use HTTP GET calls") + pn(" HTTPGETOnly bool // If `true` only use HTTP GET calls") pn("") - pn(" client *http.Client // The http client for communicating") - pn(" baseURL string // The base URL of the API") - pn(" apiKey string // Api key") - pn(" secret string // Secret key") - pn(" async bool // Wait for async calls to finish") - pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds") + pn(" client *http.Client // The http client for communicating") + pn(" baseURL string // The base URL of the API") + pn(" apiKey string // Api key") + pn(" secret string // Secret key") + pn(" async bool // Wait for async calls to finish") + pn(" timeout int64 // Max waiting timeout in seconds for async jobs to finish; defaults to 300 seconds") pn("") for _, s := range as.services { pn(" %s *%s", strings.TrimSuffix(s.name, "Service"), s.name) @@ -273,32 +273,32 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn("") pn("// Creates a new client for communicating with CloudStack") pn("func newClient(apiurl string, apikey string, secret string, async bool, verifyssl bool) *CloudStackClient {") - pn(" cs := &CloudStackClient{") - pn(" client: &http.Client{") - pn(" Transport: &http.Transport{") - pn(" Proxy: http.ProxyFromEnvironment,") - pn(" TLSClientConfig: &tls.Config{InsecureSkipVerify: !verifyssl}, // If verifyssl is true, skipping the verify should be false and vice versa") - pn(" },") - pn(" Timeout: time.Duration(60 * time.Second),") - pn(" },") - pn(" baseURL: apiurl,") - pn(" apiKey: apikey,") - pn(" secret: secret,") - pn(" async: async,") - pn(" timeout: 300,") - pn(" }") + pn(" cs := &CloudStackClient{") + pn(" client: &http.Client{") + pn(" Transport: &http.Transport{") + pn(" Proxy: http.ProxyFromEnvironment,") + pn(" TLSClientConfig: &tls.Config{InsecureSkipVerify: !verifyssl}, // If verifyssl is true, skipping the verify should be false and vice versa") + pn(" },") + pn(" Timeout: time.Duration(60 * time.Second),") + pn(" },") + pn(" baseURL: apiurl,") + pn(" apiKey: apikey,") + pn(" secret: secret,") + pn(" async: async,") + pn(" timeout: 300,") + pn(" }") for _, s := range as.services { pn(" cs.%s = New%s(cs)", strings.TrimSuffix(s.name, "Service"), s.name) } - pn(" return cs") + pn(" return cs") pn("}") pn("") pn("// Default non-async client. So for async calls you need to implement and check the async job result yourself. When using") pn("// HTTPS with a self-signed certificate to connect to your CloudStack API, you would probably want to set 'verifyssl' to") pn("// false so the call ignores the SSL errors/warnings.") pn("func NewClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient {") - pn(" cs := newClient(apiurl, apikey, secret, false, verifyssl)") - pn(" return cs") + pn(" cs := newClient(apiurl, apikey, secret, false, verifyssl)") + pn(" return cs") pn("}") pn("") pn("// For sync API calls this client behaves exactly the same as a standard client call, but for async API calls") @@ -306,8 +306,8 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn("// job finishes successfully it will return actual object received from the API and nil, but when the timout is") pn("// reached it will return the initial object containing the async job ID for the running job and a warning.") pn("func NewAsyncClient(apiurl string, apikey string, secret string, verifyssl bool) *CloudStackClient {") - pn(" cs := newClient(apiurl, apikey, secret, true, verifyssl)") - pn(" return cs") + pn(" cs := newClient(apiurl, apikey, secret, true, verifyssl)") + pn(" return cs") pn("}") pn("") pn("// When using the async client an api call will wait for the async call to finish before returning. The default is to poll for 300 seconds") @@ -321,55 +321,64 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn("// A helper function that you can use to get the result of a running async job. If the job is not finished within the configured") pn("// timeout, the async job returns a AsyncTimeoutErr.") pn("func (cs *CloudStackClient) GetAsyncJobResult(jobid string, timeout int64) (json.RawMessage, error) {") - pn(" currentTime := time.Now().Unix()") - pn(" for {") - pn(" p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid)") - pn(" r, err := cs.Asyncjob.QueryAsyncJobResult(p)") - pn(" if err != nil {") - pn(" return nil, err") - pn(" }") + pn(" var timer time.Duration") + pn(" currentTime := time.Now().Unix()") pn("") - pn(" // Status 1 means the job is finished successfully") - pn(" if r.Jobstatus == 1 {") - pn(" return r.Jobresult, nil") - pn(" }") + pn(" for {") + pn(" p := cs.Asyncjob.NewQueryAsyncJobResultParams(jobid)") + pn(" r, err := cs.Asyncjob.QueryAsyncJobResult(p)") + pn(" if err != nil {") + pn(" return nil, err") + pn(" }") pn("") - pn(" // When the status is 2, the job has failed") - pn(" if r.Jobstatus == 2 {") - pn(" if r.Jobresulttype == \"text\" {") - pn(" return nil, fmt.Errorf(string(r.Jobresult))") - pn(" } else {") - pn(" return nil, fmt.Errorf(\"Undefined error: %%s\", string(r.Jobresult))") - pn(" }") - pn(" }") + pn(" // Status 1 means the job is finished successfully") + pn(" if r.Jobstatus == 1 {") + pn(" return r.Jobresult, nil") + pn(" }") pn("") - pn(" if time.Now().Unix()-currentTime > timeout {") - pn(" return nil, AsyncTimeoutErr") - pn(" }") - pn(" time.Sleep(3 * time.Second)") - pn(" }") + pn(" // When the status is 2, the job has failed") + pn(" if r.Jobstatus == 2 {") + pn(" if r.Jobresulttype == \"text\" {") + pn(" return nil, fmt.Errorf(string(r.Jobresult))") + pn(" } else {") + pn(" return nil, fmt.Errorf(\"Undefined error: %%s\", string(r.Jobresult))") + pn(" }") + pn(" }") + pn("") + pn(" if time.Now().Unix()-currentTime > timeout {") + pn(" return nil, AsyncTimeoutErr") + pn(" }") + pn("") + pn(" // Add an (extremely simple) exponential backoff like feature to prevent") + pn(" // flooding the CloudStack API") + pn(" if timer < 15 {") + pn(" timer++") + pn(" }") + pn("") + pn(" time.Sleep(timer * time.Second)") + pn(" }") pn("}") pn("") pn("// Execute the request against a CS API. Will return the raw JSON data returned by the API and nil if") pn("// no error occured. If the API returns an error the result will be nil and the HTTP error code and CS") pn("// error details. If a processing (code) error occurs the result will be nil and the generated error") pn("func (cs *CloudStackClient) newRequest(api string, params url.Values) (json.RawMessage, error) {") - pn(" params.Set(\"apiKey\", cs.apiKey)") - pn(" params.Set(\"command\", api)") - pn(" params.Set(\"response\", \"json\")") + pn(" params.Set(\"apiKey\", cs.apiKey)") + pn(" params.Set(\"command\", api)") + pn(" params.Set(\"response\", \"json\")") pn("") - pn(" // Generate signature for API call") - pn(" // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues") - pn(" // * Convert the entire argument string to lowercase") - pn(" // * Replace all instances of '+' to '%%20'") - pn(" // * Calculate HMAC SHA1 of argument string with CloudStack secret") - pn(" // * URL encode the string and convert to base64") - pn(" s := encodeValues(params)") - pn(" s2 := strings.ToLower(s)") - pn(" s3 := strings.Replace(s2, \"+\", \"%%20\", -1)") - pn(" mac := hmac.New(sha1.New, []byte(cs.secret))") - pn(" mac.Write([]byte(s3))") - pn(" signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))") + pn(" // Generate signature for API call") + pn(" // * Serialize parameters, URL encoding only values and sort them by key, done by encodeValues") + pn(" // * Convert the entire argument string to lowercase") + pn(" // * Replace all instances of '+' to '%%20'") + pn(" // * Calculate HMAC SHA1 of argument string with CloudStack secret") + pn(" // * URL encode the string and convert to base64") + pn(" s := encodeValues(params)") + pn(" s2 := strings.ToLower(s)") + pn(" s3 := strings.Replace(s2, \"+\", \"%%20\", -1)") + pn(" mac := hmac.New(sha1.New, []byte(cs.secret))") + pn(" mac.Write([]byte(s3))") + pn(" signature := base64.StdEncoding.EncodeToString(mac.Sum(nil))") pn("") pn(" var err error") pn(" var resp *http.Response") @@ -383,36 +392,36 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn(" // Make a POST call") pn(" resp, err = cs.client.PostForm(cs.baseURL, params)") pn(" } else {") - pn(" // Create the final URL before we issue the request") - pn(" url := cs.baseURL + \"?\" + s + \"&signature=\" + url.QueryEscape(signature)") + pn(" // Create the final URL before we issue the request") + pn(" url := cs.baseURL + \"?\" + s + \"&signature=\" + url.QueryEscape(signature)") pn("") pn(" // Make a GET call") - pn(" resp, err = cs.client.Get(url)") + pn(" resp, err = cs.client.Get(url)") pn(" }") - pn(" if err != nil {") - pn(" return nil, err") - pn(" }") - pn(" defer resp.Body.Close()") + pn(" if err != nil {") + pn(" return nil, err") + pn(" }") + pn(" defer resp.Body.Close()") pn("") - pn(" b, err := ioutil.ReadAll(resp.Body)") - pn(" if err != nil {") - pn(" return nil, err") - pn(" }") + pn(" b, err := ioutil.ReadAll(resp.Body)") + pn(" if err != nil {") + pn(" return nil, err") + pn(" }") pn("") - pn(" // Need to get the raw value to make the result play nice") - pn(" b, err = getRawValue(b)") - pn(" if err != nil {") - pn(" return nil, err") - pn(" }") + pn(" // Need to get the raw value to make the result play nice") + pn(" b, err = getRawValue(b)") + pn(" if err != nil {") + pn(" return nil, err") + pn(" }") pn("") - pn(" if resp.StatusCode != 200 {") - pn(" var e CSError") - pn(" if err := json.Unmarshal(b, &e); err != nil {") - pn(" return nil, err") - pn(" }") - pn(" return nil, e.Error()") - pn(" }") - pn(" return b, nil") + pn(" if resp.StatusCode != 200 {") + pn(" var e CSError") + pn(" if err := json.Unmarshal(b, &e); err != nil {") + pn(" return nil, err") + pn(" }") + pn(" return nil, e.Error()") + pn(" }") + pn(" return b, nil") pn("}") pn("") pn("// Custom version of net/url Encode that only URL escapes values") @@ -443,14 +452,14 @@ func (as *allServices) GeneralCode() ([]byte, error) { pn("") pn("// Generic function to get the first raw value from a response as json.RawMessage") pn("func getRawValue(b json.RawMessage) (json.RawMessage, error) {") - pn(" var m map[string]json.RawMessage") - pn(" if err := json.Unmarshal(b, &m); err != nil {") - pn(" return nil, err") - pn(" }") - pn(" for _, v := range m {") - pn(" return v, nil") - pn(" }") - pn(" return nil, fmt.Errorf(\"Unable to extract the raw value from:\\n\\n%%s\\n\\n\", string(b))") + pn(" var m map[string]json.RawMessage") + pn(" if err := json.Unmarshal(b, &m); err != nil {") + pn(" return nil, err") + pn(" }") + pn(" for _, v := range m {") + pn(" return v, nil") + pn(" }") + pn(" return nil, fmt.Errorf(\"Unable to extract the raw value from:\\n\\n%%s\\n\\n\", string(b))") pn("}") pn("") for _, s := range as.services { @@ -948,7 +957,7 @@ func (s *service) generateNewAPICallFunc(a *API) { pn(" if err == nil {") pn(" break") pn(" }") - pn(" time.Sleep(1 * time.Second)") + pn(" time.Sleep(500 * time.Millisecond)") pn(" }") } else { pn(" resp, err := s.cs.newRequest(\"%s\", p.toURLValues())", a.Name)