Mike Kolesnik has uploaded a new change for review.

Change subject: engine: Command for testing provider connectivity
......................................................................

engine: Command for testing provider connectivity

Allows to test that the provider definition allows connecting the
provider and accessing it's API.

Change-Id: I19e04f45f72c76f99c283ba39dfa31e3a7624cbf
Signed-off-by: Mike Kolesnik <mkole...@redhat.com>
---
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxy.java
A 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/TestProviderConnectivityCommand.java
M 
backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/quantum/QuantumProviderProxy.java
M 
backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
4 files changed, 63 insertions(+), 1 deletion(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/66/12366/1

diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxy.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxy.java
index 89520ca..33dbef9 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxy.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/ProviderProxy.java
@@ -39,4 +39,10 @@
      *            The vNIC to deallocate.
      */
     void deallocate(VmNetworkInterface nic);
+
+    /**
+     * Test the connection to the provider.<br>
+     * If the connection is unsuccessful, an exception will be thrown.
+     */
+    void testConnection();
 }
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/TestProviderConnectivityCommand.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/TestProviderConnectivityCommand.java
new file mode 100644
index 0000000..328f074
--- /dev/null
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/TestProviderConnectivityCommand.java
@@ -0,0 +1,46 @@
+package org.ovirt.engine.core.bll.provider;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.ovirt.engine.core.bll.CommandBase;
+import org.ovirt.engine.core.bll.utils.PermissionSubject;
+import org.ovirt.engine.core.common.VdcObjectType;
+import org.ovirt.engine.core.common.action.ProviderParameters;
+import org.ovirt.engine.core.common.businessentities.ActionGroup;
+import org.ovirt.engine.core.compat.Guid;
+
+/**
+ * Allows to test that the provider definition allows connecting to the 
provider and accessing it's API.<br>
+ * In case of connection failure, an exception will be thrown.
+ *
+ * @param <P>
+ *            Parameter type.
+ */
+@SuppressWarnings("serial")
+public class TestProviderConnectivityCommand<P extends ProviderParameters> 
extends CommandBase<P> {
+
+    public TestProviderConnectivityCommand(Guid commandId) {
+        super(commandId);
+    }
+
+    public TestProviderConnectivityCommand(P parameters) {
+        super(parameters);
+    }
+
+    @Override
+    protected void executeCommand() {
+        ProviderProxy proxy = 
ProviderProxyFactory.getInstance().create(getParameters().getProvider());
+
+        proxy.testConnection();
+        setSucceeded(true);
+    }
+
+    @Override
+    public List<PermissionSubject> getPermissionCheckSubjects() {
+        return Collections.singletonList(new PermissionSubject(Guid.SYSTEM,
+                VdcObjectType.System,
+                ActionGroup.CREATE_STORAGE_POOL));
+    }
+
+}
diff --git 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/quantum/QuantumProviderProxy.java
 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/quantum/QuantumProviderProxy.java
index 2cd3aa1..4f34ca8 100644
--- 
a/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/quantum/QuantumProviderProxy.java
+++ 
b/backend/manager/modules/bll/src/main/java/org/ovirt/engine/core/bll/provider/quantum/QuantumProviderProxy.java
@@ -153,4 +153,13 @@
         QuantumPort[] ports = objectMapper.readValue(method.getResponseBody(), 
QuantumPortsList.class).getPorts();
         return ports;
     }
+
+    /**
+     * Quantum implementation must call {@link QuantumProviderClient#getAll()} 
since the root API returns an exception
+     * when accessing it.
+     */
+    @Override
+    public void testConnection() {
+        getAll();
+    }
 }
diff --git 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
index 69f0ad0..f2d9ea4 100644
--- 
a/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
+++ 
b/backend/manager/modules/common/src/main/java/org/ovirt/engine/core/common/action/VdcActionType.java
@@ -270,7 +270,8 @@
     AddProvider(1600, false, QuotaDependency.NONE),
     UpdateProvider(1601, false, QuotaDependency.NONE),
     RemoveProvider(1602, false, QuotaDependency.NONE),
-    AddNetworkOnProvider(1603, ActionGroup.CREATE_STORAGE_POOL_NETWORK, false, 
QuotaDependency.NONE);
+    AddNetworkOnProvider(1603, ActionGroup.CREATE_STORAGE_POOL_NETWORK, false, 
QuotaDependency.NONE),
+    TestProviderConnectivity(1604, false, QuotaDependency.NONE);
 
     private int intValue;
     private ActionGroup actionGroup;


--
To view, visit http://gerrit.ovirt.org/12366
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I19e04f45f72c76f99c283ba39dfa31e3a7624cbf
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: master
Gerrit-Owner: Mike Kolesnik <mkole...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to