[GitHub] cloudstack pull request #1862: CLOUDSTACK-9704 Remove dependency on VmwareCo...

2016-12-30 Thread sateesh-chodapuneedi
Github user sateesh-chodapuneedi commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1862#discussion_r94214404
  
--- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 ---
@@ -5620,4 +5623,39 @@ private String getAbsoluteVmdkFile(VirtualDisk disk) 
{
 }
 return vmdkAbsFile;
 }
+
+protected File getSystemVmKeyFile() {
+if (s_systemVmKeyFile == null) {
+syncFetchSystemVmKeyFile();
+}
+return s_systemVmKeyFile;
+}
+
+private static void syncFetchSystemVmKeyFile() {
+synchronized (s_syncLockObjectFetchKeyFile) {
+if (s_systemVmKeyFile == null) {
+s_systemVmKeyFile = fetchSystemVmKeyFile();
+}
+}
+}
+
+private static File fetchSystemVmKeyFile() {
+String filePath = s_relativePathSystemVmKeyFileInstallDir;
+s_logger.debug("Looking for file [" + filePath + "] in the 
classpath.");
+URL url = Script.class.getClassLoader().getResource(filePath);
+File keyFile = null;
+if (url != null) {
+keyFile = new File(url.getPath());
+}
+if (keyFile == null || !keyFile.exists()) {
+filePath = s_defaultPathSystemVmKeyFile;
+keyFile = new File(filePath);
+s_logger.debug("Looking for file [" + filePath + "] in the 
classpath.");
+}
+assert (keyFile != null);
--- End diff --

Thanks @sureshanaparti for review.
I have addressed that now. Pushed the code changes, please check.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1862: CLOUDSTACK-9704 Remove dependency on VmwareCo...

2016-12-29 Thread sureshanaparti
Github user sureshanaparti commented on a diff in the pull request:

https://github.com/apache/cloudstack/pull/1862#discussion_r94206268
  
--- Diff: 
plugins/hypervisors/vmware/src/com/cloud/hypervisor/vmware/resource/VmwareResource.java
 ---
@@ -5620,4 +5623,39 @@ private String getAbsoluteVmdkFile(VirtualDisk disk) 
{
 }
 return vmdkAbsFile;
 }
+
+protected File getSystemVmKeyFile() {
+if (s_systemVmKeyFile == null) {
+syncFetchSystemVmKeyFile();
+}
+return s_systemVmKeyFile;
+}
+
+private static void syncFetchSystemVmKeyFile() {
+synchronized (s_syncLockObjectFetchKeyFile) {
+if (s_systemVmKeyFile == null) {
+s_systemVmKeyFile = fetchSystemVmKeyFile();
+}
+}
+}
+
+private static File fetchSystemVmKeyFile() {
+String filePath = s_relativePathSystemVmKeyFileInstallDir;
+s_logger.debug("Looking for file [" + filePath + "] in the 
classpath.");
+URL url = Script.class.getClassLoader().getResource(filePath);
+File keyFile = null;
+if (url != null) {
+keyFile = new File(url.getPath());
+}
+if (keyFile == null || !keyFile.exists()) {
+filePath = s_defaultPathSystemVmKeyFile;
+keyFile = new File(filePath);
+s_logger.debug("Looking for file [" + filePath + "] in the 
classpath.");
+}
+assert (keyFile != null);
--- End diff --

This assert statement is always true. Not needed here.

Rest code changes LGTM.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---


[GitHub] cloudstack pull request #1862: CLOUDSTACK-9704 Remove dependency on VmwareCo...

2016-12-23 Thread sateesh-chodapuneedi
GitHub user sateesh-chodapuneedi opened a pull request:

https://github.com/apache/cloudstack/pull/1862

CLOUDSTACK-9704 Remove dependency on VmwareContext object to fetch systemVM 
keyfile

Jira
===
CLOUDSTACK-9704 Remove dependency on VmwareContext object to fetch system 
VM key file

Description

While remote executing commands/scripts through SSH in VR, ACS uses system 
vm keyfile.
ACS is fetching this key file using VMwareContext object which encapsulates 
vCenter connection handle.
This is inefficient because of dependency on getServiceContext() which 
means a vCenter connection
handle which is not required just to fetch a file in name space in 
management server.

Fix
===
Implement a method to fetch system vm key file by using Script class 
instead of VmwareManagerImpl. Ensure this implementation is not present in 
VmwareManagerImpl itself because fetching the manager object from VmwareContext 
object unnecessarily adds dependency on session object just to search for 
keyfile in class path.

Signed-off-by: Sateesh Chodapuneedi 

You can merge this pull request into a Git repository by running:

$ git pull https://github.com/sateesh-chodapuneedi/cloudstack 
pr-cloudstack-9704

Alternatively you can review and apply these changes as the patch at:

https://github.com/apache/cloudstack/pull/1862.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

This closes #1862


commit 02bd90c424966c81c57bed9b8fc9f530e0b97b7d
Author: Sateesh Chodapuneedi 
Date:   2016-12-23T02:17:43Z

CLOUDSTACK-9704 Remove dependency on VmwareContext object to fetch system 
VM key file

While remote executing commands/scripts through SSH in VR, ACS uses system 
vm keyfile.
ACS is fetching this key file using VMwareContext object which encapsulates 
vCenter connection handle.
This is inefficient because of dependency on getServiceContext() which 
means a vCenter connection
handle which is not required just to fetch a file in name space in 
management server.

Signed-off-by: Sateesh Chodapuneedi 




---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---