Skip to content

Commit

Permalink
Merge pull request #7 from Xelon-AG/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
tonkoshkurik committed Nov 30, 2022
2 parents 10e6cda + af8fb76 commit 9a80f81
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/Requests/ApiRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ private function request(string $method, string $uri, array $options = [])
} catch (ClientException $e) {
// if 401, create new session and reply attempt
} catch (\Exception $e) {
Log::error('Rest api exception : '.$e->getMessage());
Log::error('Rest api exception: '.$e->getMessage());
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/Requests/SoapRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public function request(string $method, array $requestBody, bool $convertToSoap
property_exists($this->soapClient, '__last_request')
? "\nSOAP response start***: ".$this->soapClient->__last_response.'***SOAP response end'
: ''
).
"\nTrace: ".json_encode($exception->getTrace());
);
// "\nTrace: ".json_encode($exception->getTrace());

Log::error($message);
throw new \Exception($message);
Expand Down
6 changes: 6 additions & 0 deletions src/Traits/Soap/SoapVmApis.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,12 @@ public function getObjectInfo(string $objectId, string $objectType, string $path
}
}

if (! isset($result->returnval->propSet)) {
Log::error('Get object info error: '.json_encode($result));

return new \stdClass();
}

return $pathSet
? ($result->returnval->propSet->val ?? null)
: $this->transformPropSet($result->returnval->propSet);
Expand Down
1 change: 1 addition & 0 deletions src/Transform/SoapTransform.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ public function transformToArrayValues(stdClass $object, int $startIndex = 0, ?i
['returnval', 'sampleInfo'],
['returnval', 'value', 'value'],
['returnval', 'config', 'consumerId'],
['layoutEx', 'disk', 'chain', 'fileKey'],
['layoutEx', 'file'],
['layoutEx', 'snapshot'],
['layoutEx', 'snapshot', 'disk'],
Expand Down
9 changes: 7 additions & 2 deletions src/VmWareClientInit.php
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,12 @@ private function initSoapSession(): void

if (! $sessionInfo) {
$this->createSoapSession();
} elseif ($this->isSessionExpired($sessionInfo['expired_at'])) {
} elseif (
$this->isSessionExpired($sessionInfo['expired_at'])
|| Carbon::parse($sessionInfo['expired_at'])->diffInSeconds(Carbon::now()) < 30
) {
$this->createSoapClientWithExistingSession($sessionInfo['vmware_soap_session']);
$this->deleteSoapSession();
$this->createSoapSession();
} else {
$this->createSoapClientWithExistingSession($sessionInfo['vmware_soap_session']);
Expand Down Expand Up @@ -222,7 +227,7 @@ private function deleteSoapSession()
$soaplogout['_this'] = $sessionManager;
$this->soapClient->Logout($soaplogout);
} catch (\Exception $exception) {
Log::error('Can\'t delete soap session');
Log::error('Can\'t delete soap session: '.$exception->getMessage());
}
}
}

0 comments on commit 9a80f81

Please sign in to comment.