From 7f035e26ee85f7b9481de5d8ba25ac0fb3361656 Mon Sep 17 00:00:00 2001 From: wladikz Date: Mon, 22 May 2017 14:00:42 +0300 Subject: [PATCH 1/4] Multi-Session with different users support --- .../Vmwarephp/Extensions/SessionManager.php | 45 ++++++++++++++----- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/library/Vmwarephp/Extensions/SessionManager.php b/library/Vmwarephp/Extensions/SessionManager.php index 97e273e..c856ace 100644 --- a/library/Vmwarephp/Extensions/SessionManager.php +++ b/library/Vmwarephp/Extensions/SessionManager.php @@ -5,17 +5,25 @@ class SessionManager extends \Vmwarephp\ManagedObject { private $cloneTicketFile; private $session; - - function acquireSession($userName, $password) { - if ($this->session) { - return $this->session; - } - try { - $this->session = $this->acquireSessionUsingCloneTicket(); - } catch (\Exception $e) { - $this->session = $this->acquireANewSession($userName, $password); - } - return $this->session; + private $userName; + + function acquireSession($userName, $password) { + if (empty($this->userName)) { + $this->userName=$userName; + } + if ($this->userName === $userName) { + if ($this->session) { + return $this->session; + } + try { + $this->session = $this->acquireSessionUsingCloneTicket(); + } catch (\Exception $e) { + $this->session = $this->acquireANewSession($userName, $password); + } + } else { + $this->session = $this->acquireANewSession($userName, $password); + } + return $this->session; } private function acquireSessionUsingCloneTicket() { @@ -47,8 +55,21 @@ private function readCloneTicket() { private function getCloneTicketFile() { if (!$this->cloneTicketFile) { - $this->cloneTicketFile = __DIR__ . '/../.clone_ticket.cache'; + $this->cloneTicketFile = __DIR__ . '/../.' . $this->getUserNameForFileName() .'_clone_ticket.cache'; } return $this->cloneTicketFile; } + private function getUserNameForFileName() { + if (empty($this->userName)) { + throw new Exception('UserName is Empty'); + } + if (strpos($this->userName, "\\") !== FALSE) { + $tmpUser= explode("\\", $this->userName)[1]; + } elseif (strpos($this->userName, "@") !== FALSE) { + $tmpUser= explode("@", $this->userName)[0]; + } else { + $tmpUser= $this->userName; + } + return $tmpUser; + } } From b45ac645cbc5e5de38761bdc44b1f00e3c4fe674 Mon Sep 17 00:00:00 2001 From: wladikz Date: Mon, 22 May 2017 14:06:47 +0300 Subject: [PATCH 2/4] fixed composer to my repo --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 34dc5a5..164ab0c 100644 --- a/composer.json +++ b/composer.json @@ -1,9 +1,9 @@ { - "name":"wirehive/vmwarephp", + "name":"wladikz/vmwarephp", "type":"library", "description":"Vmware vSphere bindings for PHP", "keywords":["vmware", "php", "vsphere", "bindings", "vsphere sdk", "vmware php"], - "homepage":"https://github.com/Wirehive/vmwarephp", + "homepage":"https://github.com/wladikz/vmwarephp", "license":"BSD-3-Clause", "authors":[ { From 97e4c93c1f7158fcec5a543b298976b5e1a81677 Mon Sep 17 00:00:00 2001 From: wladikz Date: Mon, 22 May 2017 15:52:41 +0300 Subject: [PATCH 3/4] customizationSpecManager extension --- .../Vmwarephp/Extensions/customizationSpecManager.php | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 library/Vmwarephp/Extensions/customizationSpecManager.php diff --git a/library/Vmwarephp/Extensions/customizationSpecManager.php b/library/Vmwarephp/Extensions/customizationSpecManager.php new file mode 100644 index 0000000..bad46ad --- /dev/null +++ b/library/Vmwarephp/Extensions/customizationSpecManager.php @@ -0,0 +1,10 @@ +info; + return $tmp; + } +} \ No newline at end of file From 223abc65983bd1585049da1564471933374ea5bf Mon Sep 17 00:00:00 2001 From: wladikz Date: Tue, 23 May 2017 08:34:19 +0300 Subject: [PATCH 4/4] not required anymore --- .gitignore | 3 ++- .../Vmwarephp/Extensions/customizationSpecManager.php | 10 ---------- 2 files changed, 2 insertions(+), 11 deletions(-) delete mode 100644 library/Vmwarephp/Extensions/customizationSpecManager.php diff --git a/.gitignore b/.gitignore index f92a8e4..f6f563b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/* library/Vmwarephp/.wsdl_class_map.cache library/Vmwarephp/.clone_ticket.cache -/nbproject/private/ \ No newline at end of file +/nbproject/private/ +*.cache diff --git a/library/Vmwarephp/Extensions/customizationSpecManager.php b/library/Vmwarephp/Extensions/customizationSpecManager.php deleted file mode 100644 index bad46ad..0000000 --- a/library/Vmwarephp/Extensions/customizationSpecManager.php +++ /dev/null @@ -1,10 +0,0 @@ -info; - return $tmp; - } -} \ No newline at end of file