[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-9704?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15787064#comment-15787064
 ] 

ASF GitHub Bot commented on CLOUDSTACK-9704:
--------------------------------------------

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.


> Remove dependency on VmwareContext object to fetch system VM key file
> ---------------------------------------------------------------------
>
>                 Key: CLOUDSTACK-9704
>                 URL: https://issues.apache.org/jira/browse/CLOUDSTACK-9704
>             Project: CloudStack
>          Issue Type: Bug
>      Security Level: Public(Anyone can view this level - this is the 
> default.) 
>            Reporter: Sateesh Chodapuneedi
>            Assignee: Sateesh Chodapuneedi
>
> While remote executing commands/scripts in VR, ACS uses system vm keyfile. 
> ACS is fetching this key file using following code
> {code:java}
> VmwareManager mgr = 
> getServiceContext().getStockObject(VmwareManager.CONTEXT_STOCK_NAME);
> File systemVmKeyFile = mgr.getSystemVMKeyFile();
> {code}
> This is inefficient because dependency on getServiceContext() in above code 
> means a vCenter connection handle which is not required just to fetch a file 
> in name space in management server.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to