[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-03-13 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174258066
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
 
 Review comment:
   ok, short method with low cyclic complexity; makes sense


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-03-13 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174258152
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
 
 Review comment:
   :+1:


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-03-13 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174253018
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
+if (StringUtils.isBlank(result)) {
 final String errMsg = "Could not mount secondary storage " + 
remoteDir + " on host " + localDir;
-
 s_logger.warn(errMsg);
-
 throw new CloudRuntimeException(errMsg);
 }
-
-return true;
 }
 
-protected boolean makeDirectory(final Connection conn, final String path) {
-final String result = hypervisorResource.callHostPlugin(conn, 
"cloud-plugin-storage", "makeDirectory", "path", path);
+protected boolean makeDirectory(Connection conn, String path) {
 
 Review comment:
   why removing the final?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-03-13 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r174252867
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessor.java
 ##
 @@ -65,90 +69,181 @@ public Xenserver625StorageProcessor(final 
CitrixResourceBase resource) {
 super(resource);
 }
 
-protected boolean mountNfs(final Connection conn, final String remoteDir, 
String localDir) {
+private void mountNfs(Connection conn, String remoteDir, String localDir) {
 if (localDir == null) {
 localDir = "/var/cloud_mount/" + 
UUID.nameUUIDFromBytes(remoteDir.getBytes());
 }
-
-final String results = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir",
-remoteDir);
-
-if (results == null || results.isEmpty()) {
+String result = hypervisorResource.callHostPluginAsync(conn, 
"cloud-plugin-storage", "mountNfsSecondaryStorage", 100 * 1000, "localDir", 
localDir, "remoteDir", remoteDir);
 
 Review comment:
   final not allowed?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-01-30 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164773896
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/Xenserver625StorageProcessorTest.java
 ##
 @@ -0,0 +1,459 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package com.cloud.hypervisor.xenserver.resource;
+
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.times;
+
+import java.util.HashSet;
+import java.util.Set;
+import java.util.UUID;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.xmlrpc.XmlRpcException;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.InOrder;
+import org.mockito.InjectMocks;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.powermock.api.mockito.PowerMockito;
+import org.powermock.core.classloader.annotations.PrepareForTest;
+import org.powermock.modules.junit4.PowerMockRunner;
+
+import com.cloud.utils.exception.CloudRuntimeException;
+import com.xensource.xenapi.Connection;
+import com.xensource.xenapi.Host;
+import com.xensource.xenapi.PBD;
+import com.xensource.xenapi.PBD.Record;
+import com.xensource.xenapi.SR;
+import com.xensource.xenapi.Types.InternalError;
+import com.xensource.xenapi.Types.XenAPIException;
+
+@RunWith(PowerMockRunner.class)
+public class Xenserver625StorageProcessorTest {
+
+@InjectMocks
+private Xenserver625StorageProcessor xenserver625StorageProcessor;
+
+@Mock
+private CitrixResourceBase citrixResourceBase;
+
+@Mock
+private Connection connectionMock;
+
+private String pathMock = "pathMock";
+
+@Before
+public void before() {
+xenserver625StorageProcessor = Mockito.spy(new 
Xenserver625StorageProcessor(citrixResourceBase));
+citrixResourceBase._host = Mockito.mock(XsHost.class);
+
Mockito.when(citrixResourceBase.getHost()).thenReturn(citrixResourceBase._host);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningEmpty() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, StringUtils.EMPTY);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningNull() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, null);
+
+assertFalse(makeDirectoryReturn);
+}
+
+@Test
+public void makeDirectoryTestCallHostPlugingReturningSomething() {
+boolean makeDirectoryReturn = 
configureAndExecuteMakeDirectoryMethodForTest(pathMock, "Soemthing");
 
 Review comment:
   Soemthing on purpose or Something intended?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-01-30 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164773076
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/test/java/com/cloud/hypervisor/xenserver/resource/XenServer625ResourceTest.java
 ##
 @@ -30,7 +31,7 @@
 
 @Before
 public void beforeTest() {
-super.citrixResourceBase = new Xenserver625Resource();
+super.citrixResourceBase = Mockito.spy(new Xenserver625Resource());
 
 Review comment:
   i don't see this spy being used, why create it?


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services


[GitHub] DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] Duplicated file SRs being created in XenServer pools

2018-01-30 Thread GitBox
DaanHoogland commented on a change in pull request #2414: [CLOUDSTACK-10241] 
Duplicated file SRs being created in XenServer pools
URL: https://github.com/apache/cloudstack/pull/2414#discussion_r164725447
 
 

 ##
 File path: 
plugins/hypervisors/xenserver/src/main/java/com/cloud/hypervisor/xenserver/resource/CitrixResourceBase.java
 ##
 @@ -17,7 +17,52 @@
 package com.cloud.hypervisor.xenserver.resource;
 
 Review comment:
   did anything actually change in this class? the file has +761 ?214 but i 
cannot find a 'real' change. if it is only formatting maybe put it in a 
separate commit.


This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


With regards,
Apache Git Services