You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by bh...@apache.org on 2015/03/12 07:05:03 UTC

[11/12] git commit: updated refs/heads/master to c27c694

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Network.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Network.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Network.java
new file mode 100644
index 0000000..0759c5a
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Network.java
@@ -0,0 +1,331 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+public class Network extends OvmObject {
+    private static final Logger LOGGER = Logger.getLogger(Network.class);
+    private static final String START = "start";
+    private static final String BRIDGE = "Bridge";
+    private static final String ADDRESS = "Address";
+    private static final String PHYSICAL = "Physical";
+    private Map<String, Interface> interfaceList = null;
+    private Object postDiscovery = null;
+    private List<String> netInterfaces = new ArrayList<String>();
+
+    public Network(Connection c) {
+        setClient(c);
+    }
+
+    public Map<String, Interface> getInterfaceList()
+            throws Ovm3ResourceException {
+        discoverNetwork();
+        return interfaceList;
+    }
+
+    public static class Interface {
+        private final Map<String, String> iFace = new HashMap<String, String>() {
+            {
+                put("Type", null);
+                put(PHYSICAL, null);
+                put("Name", null);
+                put(ADDRESS, null);
+                put("Broadcast", null);
+                put("MAC", null);
+                put("Vlan", null);
+            }
+        };
+
+        public Interface() {
+        }
+
+        public void setIfType(String t) {
+            iFace.put("Type", t);
+        }
+
+        public String getIfType() {
+            return iFace.get("Type");
+        }
+
+        public void setInterface(Map<String, String> itf) {
+            iFace.putAll(itf);
+        }
+
+        public String getName() {
+            return iFace.get("Name");
+        }
+
+        public String getPhysical() {
+            return iFace.get(PHYSICAL);
+        }
+
+        public String getAddress() {
+            return iFace.get(ADDRESS);
+        }
+
+        public String getBroadcast() {
+            return iFace.get("Broadcast");
+        }
+
+        public String getMac() {
+            return iFace.get("MAC");
+        }
+
+        public String setName(String name) {
+            return iFace.put("Name", name);
+        }
+
+        public String setPhysical(String ph) {
+            return iFace.put(PHYSICAL, ph);
+        }
+
+        public String setMac(String mac) {
+            return iFace.put("MAC", mac);
+        }
+    }
+
+    private Network.Interface getNetIface(String key, String val)
+            throws Ovm3ResourceException {
+        Map<String, Network.Interface> ifaces = getInterfaceList();
+        for (final Entry<String, Interface> iface : ifaces.entrySet()) {
+            String match = "default";
+            if (ADDRESS.equals(key)) {
+                match = iface.getValue().getAddress();
+            }
+            if ("Name".equals(key)) {
+                match = iface.getKey();
+            }
+            if (match != null && match.equals(val)) {
+                return iface.getValue();
+            }
+        }
+        LOGGER.debug("Unable to find " + key + " Interface by value: " + val);
+        setSuccess(false);
+        return null;
+    }
+
+    public Network.Interface getInterfaceByIp(String ip)
+            throws Ovm3ResourceException {
+        return getNetIface(ADDRESS, ip);
+    }
+
+    public Network.Interface getInterfaceByName(String name)
+            throws Ovm3ResourceException {
+        return getNetIface("Name", name);
+    }
+
+    /* check if it is a BRIDGE */
+    public String getPhysicalByBridgeName(String name)
+            throws Ovm3ResourceException {
+        return getInterfaceByName(name).getPhysical();
+    }
+
+    public Network.Interface getBridgeByName(String name)
+            throws Ovm3ResourceException {
+        if (getNetIface("Name", name) != null
+                && getNetIface("Name", name).getIfType().contentEquals(BRIDGE)) {
+            return getNetIface("Name", name);
+        }
+        LOGGER.debug("Unable to find bridge by name: " + name);
+        setSuccess(false);
+        return null;
+    }
+
+    public Network.Interface getBridgeByIp(String ip)
+            throws Ovm3ResourceException {
+        if (getNetIface(ADDRESS, ip) != null
+                && getNetIface(ADDRESS, ip).getIfType().contentEquals(BRIDGE)) {
+            return getNetIface(ADDRESS, ip);
+        }
+        LOGGER.debug("Unable to find bridge by ip: " + ip);
+        setSuccess(false);
+        return null;
+    }
+
+    /*
+     * configure_virtual_ip, <class
+     * 'agent.api.network.linux_network.LinuxNetwork'> argument: self - default:
+     * None argument: virtual_ip - default: None argument: base_ip - default:
+     * None
+     */
+    public Boolean configureVip(String vip, String baseip)
+            throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("configure_virtual_ip", vip, baseip);
+    }
+
+    public Boolean ovsIpConfig(String net, String optype, String ip,
+            String netmask) throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("ovs_ip_config", net, optype, ip, netmask);
+    }
+
+    /*
+     * Restriction: - data string that starts with leading spaces will be
+     * rejected ovs_if_meta('bond0',
+     * 'ethernet:c0a80100{192.168.1.0}:MANAGEMENT,CLUSTER_HEARTBEAT,LIVE_MIGRATE,VIRTUAL_MACHINE,STORAGE')
+     */
+
+    public Boolean discoverNetwork() throws Ovm3ResourceException {
+        postDiscovery = callWrapper("discover_network");
+        if (postDiscovery == null) {
+            return false;
+        }
+        interfaceList = new HashMap<String, Interface>();
+        Document xmlDocument = prepParse((String) postDiscovery);
+        String path = "//Discover_Network_Result/Network/Active";
+        String bpath = path + "/Bridges/Device";
+
+        netInterfaces = new ArrayList<String>();
+        netInterfaces.addAll(xmlToList(bpath + "/@Name", xmlDocument));
+        for (String b : netInterfaces) {
+            Map<String, String> br = xmlToMap(bpath + "[@Name='" + b
+                    + "']/Family", xmlDocument);
+            /* vifs are here too */
+            String phyInt = (String) this.xmlToMap(
+                    bpath + "[@Name='" + b + "']/Interfaces", xmlDocument).get(
+                    "PhyInterface");
+            Interface iface = new Interface();
+            iface.setInterface(br);
+            iface.setName(b);
+            iface.setIfType(BRIDGE);
+            if (phyInt == null) {
+                iface.setIfType("Local");
+            }
+            iface.setPhysical(phyInt);
+            interfaceList.put(b, iface);
+        }
+        /* add "physical" interfaces */
+        bpath = path + "/Network/Device";
+        netInterfaces = new ArrayList<String>();
+        netInterfaces.addAll(xmlToList(bpath + "/@Name", xmlDocument));
+        for (String p : netInterfaces) {
+            Map<String, String> nf = xmlToMap("//Device[@Name='" + p + "']",
+                    xmlDocument);
+            Interface iface = new Interface();
+            iface.setPhysical(nf.get("Basename"));
+            iface.setName(p);
+            iface.setMac(nf.get("MAC"));
+            iface.setIfType(PHYSICAL);
+            interfaceList.put(p, iface);
+        }
+        /* add virtual interfaces ? */
+        return true;
+    }
+
+    public Boolean startOvsLocalConfig(String br) throws Ovm3ResourceException {
+        String s = (String) ovsLocalConfig(START, br);
+        if (s.startsWith(START)) {
+            return true;
+        }
+        return false;
+    }
+
+    public Boolean stopOvsLocalConfig(String br) throws Ovm3ResourceException {
+        String s = (String) ovsLocalConfig("stop", br);
+        if (s.startsWith("stop")) {
+            return true;
+        }
+        return false;
+    }
+
+    private Object ovsLocalConfig(String action, String br)
+            throws Ovm3ResourceException {
+        return callWrapper("ovs_local_config", action, br);
+    }
+
+    public Boolean startOvsVlanConfig(String dev, int vlan)
+            throws Ovm3ResourceException {
+        return ovsVlanConfig("add", dev, vlan);
+    }
+
+    public Boolean stopOvsVlanConfig(String dev, int vlan)
+            throws Ovm3ResourceException {
+        return ovsVlanConfig("remove", dev, vlan);
+    }
+
+    private Boolean ovsVlanConfig(String action, String net, int vlan)
+            throws Ovm3ResourceException {
+        Object x = callWrapper("ovs_vlan_config", action, net, vlan);
+        if (x == null) {
+            return true;
+        }
+        return false;
+    }
+
+    public Boolean startOvsBrConfig(String br, String dev)
+            throws Ovm3ResourceException {
+        String s = (String) ovsBrConfig(START, br, dev);
+        if (s.startsWith(START)) {
+            return true;
+        }
+        return false;
+    }
+
+    public Boolean stopOvsBrConfig(String br, String dev)
+            throws Ovm3ResourceException {
+        String s = (String) ovsBrConfig("stop", br, dev);
+        if (s.startsWith("stop")) {
+            return true;
+        }
+        return false;
+    }
+
+    public Object ovsBrConfig(String action, String br, String net)
+            throws Ovm3ResourceException {
+        return (Object) callWrapper("ovs_br_config", action, br, net);
+    }
+
+    /* 1 is untagged, goes till 4095 */
+    public Boolean stopOvsVlanBridge(String br, String net, int vlan)
+            throws Ovm3ResourceException {
+        String s = (String) ovsVlanBridge("stop", br, net, vlan);
+        if (s.startsWith("stop")) {
+            return true;
+        }
+        return false;
+    }
+
+    public Boolean startOvsVlanBridge(String br, String net, int vlan)
+            throws Ovm3ResourceException {
+        String s = (String) ovsVlanBridge(START, br, net, vlan);
+        /* 3.2.1 uses start, 3.3.1 and up uses added... */
+        if (s.startsWith(START) || s.startsWith("Added")) {
+            return true;
+        }
+        return false;
+    }
+
+    private Object ovsVlanBridge(String action, String br, String net, int vlan)
+            throws Ovm3ResourceException {
+        return (Object) callWrapper("ovs_vlan_bridge", action, br, net, vlan);
+    }
+
+    /*
+     * deconfigure_virtual_ip, <class
+     * 'agent.api.network.linux_network.LinuxNetwork'> argument: self - default:
+     * None argument: virtual_ip - default: None
+     */
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ntp.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ntp.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ntp.java
new file mode 100644
index 0000000..2402bf5
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ntp.java
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.ArrayList;
+import java.util.List;
+
+public class Ntp extends OvmObject {
+    private List<String> ntpHosts = new ArrayList<String>();
+    private Boolean isServer = null;
+    private Boolean isRunning = null;
+
+    public Ntp(Connection c) {
+        setClient(c);
+    }
+
+    public List<String> addServer(String server) {
+        if (!ntpHosts.contains(server)) {
+            ntpHosts.add(server);
+        }
+        return ntpHosts;
+    }
+
+    public List<String> removeServer(String server) {
+        if (ntpHosts.contains(server)) {
+            ntpHosts.remove(server);
+        }
+        return ntpHosts;
+    }
+
+    public List<String> getServers() {
+        return ntpHosts;
+    }
+    public void setServers(List<String> s) {
+        ntpHosts = s;
+    }
+
+    public Boolean isRunning() {
+        return isRunning;
+    }
+
+    public Boolean isServer() {
+        return isServer;
+    }
+
+    public Boolean getDetails() throws Ovm3ResourceException {
+        return getNtp();
+    }
+
+    /*
+     * get_ntp, <class 'agent.api.host.linux.Linux'> argument: self - default:
+     * None
+     */
+    public Boolean getNtp() throws Ovm3ResourceException {
+        Object[] v = (Object[]) callWrapper("get_ntp");
+        int c = 0;
+        for (Object o : v) {
+            if (o instanceof java.lang.Boolean) {
+                if (c == 0) {
+                    isServer = (Boolean) o;
+                }
+                if (c == 1) {
+                    isRunning = (Boolean) o;
+                }
+                c += 1;
+            } else if (o instanceof java.lang.Object) {
+                Object[] s = (Object[]) o;
+                for (Object m : s) {
+                    addServer((String) m);
+                }
+            }
+        }
+        return true;
+    }
+
+    public Boolean setNtp(List<String> ntpHosts, Boolean running)
+            throws Ovm3ResourceException {
+        if (ntpHosts.isEmpty()) {
+            return false;
+        }
+        return nullIsTrueCallWrapper("set_ntp", ntpHosts, running);
+    }
+
+    /* also cleans the vector */
+    public Boolean setNtp(String server, Boolean running)
+            throws Ovm3ResourceException {
+        ntpHosts = new ArrayList<String>();
+        ntpHosts.add(server);
+        return setNtp(ntpHosts, running);
+    }
+
+    public Boolean setNtp(Boolean running) throws Ovm3ResourceException {
+        return setNtp(ntpHosts, running);
+    }
+
+    public Boolean disableNtp() throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("disable_ntp");
+
+    }
+
+    public Boolean enableNtp() throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("enable_ntp");
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ovm3ResourceException.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ovm3ResourceException.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ovm3ResourceException.java
new file mode 100644
index 0000000..a04a242
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Ovm3ResourceException.java
@@ -0,0 +1,40 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+public class Ovm3ResourceException extends Exception {
+    private static final long serialVersionUID = 1L;
+    private static final Throwable CAUSE = null;
+    public Ovm3ResourceException() {
+        super();
+    }
+
+    public Ovm3ResourceException(String message) {
+        super(message);
+    }
+
+    public Ovm3ResourceException(String message, Throwable cause) {
+        super(message, cause);
+    }
+
+    @Override
+    public Throwable getCause() {
+        return CAUSE;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/OvmObject.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/OvmObject.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/OvmObject.java
new file mode 100644
index 0000000..32bd12a
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/OvmObject.java
@@ -0,0 +1,247 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.io.IOException;
+import java.io.StringReader;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.UUID;
+
+import javax.xml.parsers.DocumentBuilder;
+import javax.xml.parsers.DocumentBuilderFactory;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.xpath.XPath;
+import javax.xml.xpath.XPathConstants;
+import javax.xml.xpath.XPathExpression;
+import javax.xml.xpath.XPathExpressionException;
+import javax.xml.xpath.XPathFactory;
+
+import org.apache.log4j.Logger;
+import org.apache.xmlrpc.XmlRpcException;
+import org.w3c.dom.Document;
+import org.w3c.dom.NodeList;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+
+public class OvmObject {
+    private volatile Connection client;
+    private static List<?> emptyParams = new ArrayList<Object>();
+    private static final Logger LOGGER = Logger
+            .getLogger(OvmObject.class);
+    private boolean success = false;
+
+    public OvmObject() {
+    }
+
+    public Connection getClient() {
+        return client;
+    }
+
+    public synchronized void setClient(Connection c) {
+        client = c;
+    }
+
+    /* remove dashes from uuids */
+    public String deDash(String str) {
+        return str.replaceAll("-", "");
+    }
+    /* generate a uuid */
+    public String newUuid() {
+        return UUID.randomUUID().toString();
+    }
+
+    /* generate a uuid */
+    public String newUuid(String str) {
+        return UUID.nameUUIDFromBytes(str.getBytes()).toString();
+    }
+
+    /* capture most of the calls here */
+    public Object callWrapper(String call) throws Ovm3ResourceException {
+        try {
+            return client.call(call, emptyParams);
+        } catch (XmlRpcException e) {
+            String msg = "Client call " + call  + " to " +  client.getIp() + " went wrong: " + e.getMessage();
+            throw new Ovm3ResourceException(msg, e);
+        }
+    }
+
+    public void setSuccess(boolean s) {
+        success = s;
+    }
+
+    public Boolean getSuccess() {
+        return success;
+    }
+
+    /* nice try but doesn't work like that .. */
+    @SafeVarargs
+    public final <T> Object callWrapper(String call, T... args)
+            throws Ovm3ResourceException {
+        List<T> params = new ArrayList<T>();
+        for (T param : args) {
+            params.add(param);
+        }
+        try {
+            return client.call(call, params);
+        } catch (XmlRpcException e) {
+            String msg = "Client call " + call  + " to " +  client.getIp() + " with " + params + " went wrong: " + e.getMessage();
+            throw new Ovm3ResourceException(msg, e);
+        }
+    }
+
+    /* should check on nil ? */
+    @SafeVarargs
+    public final <T> Boolean nullCallWrapper(String call, Boolean nullReturn, T... args) throws Ovm3ResourceException {
+        Object x = callWrapper(call, args);
+        if (x == null) {
+            return nullReturn;
+        } else if (!nullReturn) {
+            return true;
+        }
+        return false;
+    }
+
+    @SafeVarargs
+    public final <T> Boolean nullIsFalseCallWrapper(String call, T... args) throws Ovm3ResourceException {
+        return nullCallWrapper(call, false, args);
+    }
+    @SafeVarargs
+    public final <T> Boolean nullIsTrueCallWrapper(String call, T... args) throws Ovm3ResourceException {
+        return nullCallWrapper(call, true, args);
+    }
+
+    /* returns a single string */
+    public Map<String, Long> callMap(String call) throws Ovm3ResourceException {
+        return (HashMap<String, Long>) callWrapper(call);
+    }
+
+    public <T> String callString(String call, T... args) throws Ovm3ResourceException {
+        Object result = callWrapper(call, args);
+        if (result == null) {
+            return null;
+        }
+        if (result instanceof String || result instanceof Integer || result instanceof Long || result instanceof HashMap) {
+            return result.toString();
+        }
+
+        Object[] results = (Object[]) result;
+
+        if (results.length == 0) {
+            return null;
+        }
+        if (results.length == 1) {
+            return results[0].toString();
+        }
+        return null;
+    }
+
+    /* was String, Object before */
+    public <E> Map<String, E> xmlToMap(String path, Document xmlDocument)
+            throws Ovm3ResourceException {
+        XPathFactory factory = javax.xml.xpath.XPathFactory.newInstance();
+        XPath xPath = factory.newXPath();
+        try {
+            XPathExpression xPathExpression = xPath.compile(path);
+            NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
+                    XPathConstants.NODESET);
+            Map<String, E> myMap = new HashMap<String, E>();
+            for (int ind = 0; ind < nodeList.getLength(); ind++) {
+                NodeList nodeListFor = nodeList.item(ind).getChildNodes();
+                for (int index = 0; index < nodeListFor.getLength(); index++) {
+                    String rnode = nodeListFor.item(index).getNodeName();
+                    NodeList nodeListFor2 = nodeListFor.item(index).getChildNodes();
+                    if (nodeListFor2.getLength() > 1) {
+                        /* Do we need to figure out all the sub elements here and put them in a map? */
+                    } else {
+                        String element = nodeListFor.item(index).getTextContent();
+                        myMap.put(rnode, (E) element);
+                    }
+                }
+            }
+            return myMap;
+        } catch (XPathExpressionException e) {
+            throw new Ovm3ResourceException("Problem parsing XML to Map:", e);
+        }
+    }
+
+    public List<String> xmlToList(String path, Document xmlDocument)
+            throws Ovm3ResourceException {
+        List<String> list = new ArrayList<String>();
+        XPathFactory factory = javax.xml.xpath.XPathFactory.newInstance();
+        XPath xPath = factory.newXPath();
+        try {
+            XPathExpression xPathExpression = xPath.compile(path);
+            NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
+                    XPathConstants.NODESET);
+            for (int ind = 0; ind < nodeList.getLength(); ind++) {
+                if (!nodeList.item(ind).getTextContent().isEmpty()) {
+                    list.add("" + nodeList.item(ind).getTextContent());
+                } else {
+                    list.add("" + nodeList.item(ind).getNodeValue());
+                }
+            }
+            return list;
+        } catch (XPathExpressionException e) {
+            throw new Ovm3ResourceException("Problem parsing XML to List: ", e);
+        }
+    }
+
+    public String xmlToString(String path, Document xmlDocument)
+            throws Ovm3ResourceException {
+        XPathFactory factory = javax.xml.xpath.XPathFactory.newInstance();
+        XPath xPath = factory.newXPath();
+        try {
+            XPathExpression xPathExpression = xPath.compile(path);
+            NodeList nodeList = (NodeList) xPathExpression.evaluate(xmlDocument,
+                    XPathConstants.NODESET);
+            return nodeList.item(0).getTextContent();
+        } catch (NullPointerException e) {
+            LOGGER.info("Got no items back from parsing, returning null: " + e);
+            return null;
+        } catch (XPathExpressionException e) {
+            throw new Ovm3ResourceException("Problem parsing XML to String: ", e);
+        }
+    }
+
+    public Document prepParse(String input)
+            throws Ovm3ResourceException {
+        DocumentBuilderFactory builderfactory = DocumentBuilderFactory
+                .newInstance();
+        builderfactory.setNamespaceAware(true);
+
+        DocumentBuilder builder;
+        try {
+            builder = builderfactory.newDocumentBuilder();
+        } catch (ParserConfigurationException e) {
+            throw new Ovm3ResourceException("Unable to create document Builder: ", e);
+        }
+        Document xmlDocument;
+        try {
+            xmlDocument = builder.parse(new InputSource(new StringReader(
+                    input)));
+        } catch (SAXException | IOException e) {
+            LOGGER.info(e.getClass() + ": ", e);
+            throw new Ovm3ResourceException("Unable to parse XML: ", e);
+        }
+        return xmlDocument;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Pool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Pool.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Pool.java
new file mode 100644
index 0000000..84fa965
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Pool.java
@@ -0,0 +1,272 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+/*
+ * synonym to the pool python lib in the ovs-agent
+ */
+public class Pool extends OvmObject {
+    private static final Logger LOGGER = Logger
+            .getLogger(Pool.class);
+
+    private final List<String> validRoles = new ArrayList<String>() {
+        {
+            add("xen");
+            add("utility");
+        }
+    };
+    private List<String> poolHosts = new ArrayList<String>();
+    private final List<String> poolRoles = new ArrayList<String>();
+    private String poolMasterVip;
+    private String poolAlias;
+    private String poolId = null;
+
+    public Pool(Connection c) {
+        setClient(c);
+    }
+
+    public String getPoolMasterVip() {
+        return poolMasterVip;
+    }
+
+    public String getPoolAlias() {
+        return poolAlias;
+    }
+
+    public String getPoolId() {
+        return poolId;
+    }
+
+    public List<String> getValidRoles() {
+        return validRoles;
+    }
+
+    public Boolean isInPool(String id) throws Ovm3ResourceException {
+        if (poolId == null) {
+            discoverServerPool();
+        }
+        if (poolId == null) {
+            return false;
+        }
+        if (isInAPool() && poolId.equals(id)) {
+            return true;
+        }
+        return false;
+    }
+
+    public Boolean isInAPool() throws Ovm3ResourceException {
+        if (poolId == null) {
+            discoverServerPool();
+        }
+        if (poolId == null) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean createServerPool(String alias, String id, String vip,
+            int num, String name, String host, List<String> roles) throws Ovm3ResourceException{
+        String role = StringUtils.join(roles, ",");
+        if (!isInAPool()) {
+            Object x = callWrapper("create_server_pool", alias, id, vip, num, name,
+                    host, role);
+            if (x == null) {
+                return true;
+            }
+            return false;
+        } else if (isInPool(id)) {
+            return true;
+        } else {
+            throw new Ovm3ResourceException("Unable to add host is already in  a pool with id : " + poolId);
+        }
+    }
+
+    public Boolean createServerPool(String alias, String id, String vip,
+            int num, String name, String ip) throws Ovm3ResourceException {
+        return createServerPool(alias, id, vip, num, name, ip,
+                getValidRoles());
+    }
+
+    /*
+     * public Boolean updatePoolVirtualIp(String ip) throws
+     * Ovm3ResourceException { Object x = callWrapper("update_pool_virtual_ip",
+     * ip); if (x == null) { poolMasterVip = ip; return true; } return false; }
+     */
+
+    public Boolean leaveServerPool(String uuid) throws Ovm3ResourceException{
+        return nullIsTrueCallWrapper("leave_server_pool", uuid);
+    }
+    /**
+     * Ownership prior to 3.3.x used to be simpler....
+     * @param uuid
+     * @param apiurl
+     * @return
+     * @throws Ovm3ResourceException
+     */
+    public Boolean takeOwnership(String uuid, String apiurl) throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("take_ownership", uuid, apiurl);
+    }
+    /**
+     * New style ownership, we need a dict to go in.
+     *  manager_uuid
+     *  manager_event_url
+     *  manager_statistic_url
+     *  manager_certificate
+     *  signed_server_certificate
+     * @param uuid
+     * @param apiurl
+     * @return
+     * @throws Ovm3ResourceException
+     */
+    public Boolean takeOwnership33x(final String uuid,
+            final String eventUrl,
+            final String statUrl,
+            final String managerCert,
+            final String signedCert) throws Ovm3ResourceException {
+        final Map<String, String> mgrConfig = new HashMap<String, String>() {
+            {
+                put("manager_uuid", uuid);
+                put("manager_event_url", eventUrl);
+                put("manager_statistic_url", statUrl);
+                put("manager_certificate", managerCert);
+                put("signed_server_certificate", signedCert);
+            }
+        };
+        Boolean rc = nullIsTrueCallWrapper("take_ownership", mgrConfig);
+        /* because it restarts when it's done.... 2000? -sigh- */
+        try {
+            Thread.sleep(2000);
+        } catch (InterruptedException e) {
+            throw new Ovm3ResourceException(e.getMessage());
+        }
+        return rc;
+    }
+
+    /*
+     * destroy_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+     * self - default: None argument: pool_uuid - default: None
+     */
+    public Boolean destroyServerPool(String uuid) throws Ovm3ResourceException{
+        return nullIsTrueCallWrapper("destroy_server_pool", uuid);
+    }
+
+    /*
+     * release_ownership, <class 'agent.api.serverpool.ServerPool'> argument:
+     * self - default: None argument: manager_uuid - default: None
+     */
+    public Boolean releaseOwnership(String uuid) throws Ovm3ResourceException{
+        return nullIsTrueCallWrapper("release_ownership", uuid);
+    }
+
+    /* server.discover_pool_filesystem */
+    /*
+     * discover_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+     * self - default: None
+     */
+    public Boolean discoverServerPool() throws Ovm3ResourceException {
+        Object x = callWrapper("discover_server_pool");
+        if (x == null) {
+            return false;
+        }
+
+        Document xmlDocument = prepParse((String) x);
+        String path = "//Discover_Server_Pool_Result/Server_Pool";
+        poolId = xmlToString(path + "/Unique_Id", xmlDocument);
+        poolAlias = xmlToString(path + "/Pool_Alias", xmlDocument);
+        poolMasterVip = xmlToString(path + "/Master_Virtual_Ip",
+                xmlDocument);
+        poolHosts.addAll(xmlToList(path + "//Registered_IP", xmlDocument));
+        if (poolId == null) {
+            return false;
+        }
+        return true;
+    }
+
+    private Boolean setServerRoles() throws Ovm3ResourceException{
+        String roles = StringUtils.join(poolRoles.toArray(), ",");
+        return nullIsTrueCallWrapper("update_server_roles", roles);
+    }
+
+    /* do some sanity check on the valid poolroles */
+    public Boolean setServerRoles(List<String> roles) throws Ovm3ResourceException {
+        poolRoles.addAll(roles);
+        return setServerRoles();
+    }
+
+    private Boolean joinServerPool(String alias, String id, String vip, int num,
+            String name, String host, List<String> roles) throws Ovm3ResourceException{
+        String role = StringUtils.join(roles.toArray(), ",");
+        if (!isInAPool()) {
+            Object x = callWrapper("join_server_pool", alias, id, vip, num, name,
+                    host, role);
+            if (x == null) {
+                return true;
+            }
+            return false;
+        } else if (isInPool(id)) {
+            return true;
+        } else {
+            throw new Ovm3ResourceException("Unable to add host is already in  a pool with id : " + poolId);
+        }
+    }
+
+    public Boolean joinServerPool(String alias, String id, String vip, int num,
+            String name, String host) throws Ovm3ResourceException {
+        return joinServerPool(alias, id, vip, num, name, host, getValidRoles());
+    }
+
+    private Boolean setPoolMemberList() throws Ovm3ResourceException {
+        // should throw exception if no poolHosts set
+        return nullIsTrueCallWrapper("set_pool_member_ip_list", poolHosts);
+    }
+
+    public List<String> getPoolMemberList() throws Ovm3ResourceException {
+        if (poolId == null) {
+            discoverServerPool();
+        }
+        return poolHosts;
+    }
+
+    public Boolean setPoolMemberList(List<String> hosts) throws Ovm3ResourceException {
+        poolHosts = new ArrayList<String>();
+        poolHosts.addAll(hosts);
+        return setPoolMemberList();
+    }
+
+    public Boolean addPoolMember(String host) throws Ovm3ResourceException {
+        getPoolMemberList();
+        poolHosts.add(host);
+        return setPoolMemberList();
+    }
+
+    public Boolean removePoolMember(String host) throws Ovm3ResourceException {
+        getPoolMemberList();
+        poolHosts.remove(host);
+        return setPoolMemberList();
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2.java
new file mode 100644
index 0000000..c5425ac
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/PoolOCFS2.java
@@ -0,0 +1,143 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+public class PoolOCFS2 extends OvmObject {
+    private static final Logger LOGGER = Logger
+            .getLogger(PoolOCFS2.class);
+    private Map<String, String> poolFileSystem = new HashMap<String, String>();
+    private String poolFsTarget;
+    private String poolFsType;
+    private String poolFsNFSBaseId;
+    private String poolFsId;
+    private String poolFsVersion;
+    private String poolFsManagerUuid;
+    private String poolPoolFsId;
+
+    public PoolOCFS2(Connection c) {
+        setClient(c);
+    }
+
+    public String getPoolFsNFSBaseId() {
+        return poolFsNFSBaseId;
+    }
+
+    public String getPoolFsId() {
+        return poolFsId;
+    }
+
+    public String getPoolFsUuid() {
+        return poolFsId;
+    }
+
+    public String getPoolFsTarget() {
+        return poolFsTarget;
+    }
+    public String getPoolFsManagerUuid() {
+        return poolFsManagerUuid;
+    }
+    public String getPoolFsVersion() {
+        return poolFsVersion;
+    }
+    public String getPoolPoolFsId() {
+        return poolPoolFsId;
+    }
+    public String getPoolFsType() {
+        return poolFsType;
+    }
+    public Boolean hasPoolFs(String id) throws Ovm3ResourceException {
+        if (poolFsId == null) {
+            discoverPoolFs();
+        }
+        if (hasAPoolFs() && poolFsId.equals(id)) {
+            return true;
+        }
+        return false;
+    }
+    public Boolean hasAPoolFs() throws Ovm3ResourceException {
+        if (poolFsId == null) {
+            discoverPoolFs();
+        }
+        if (poolFsId == null) {
+            return false;
+        }
+        return true;
+    }
+
+    public Boolean destroyPoolFs(String type, String target, String uuid,
+            String nfsbaseuuid) throws Ovm3ResourceException {
+        // should throw exception if no poolIps set
+        return nullIsTrueCallWrapper("destroy_pool_filesystem", type, target, uuid,
+                nfsbaseuuid);
+    }
+
+    public Boolean destroyPoolFs() throws Ovm3ResourceException {
+        // should throw exception if no poolIps set
+        return nullIsTrueCallWrapper("destroy_pool_filesystem", poolFsType,
+                poolFsTarget, poolFsId, poolFsNFSBaseId);
+    }
+
+    public Boolean createPoolFs(String type, String target, String clustername,
+            String fsid, String nfsbaseid, String managerid) throws Ovm3ResourceException {
+        if (!hasAPoolFs()) {
+            return nullIsTrueCallWrapper("create_pool_filesystem", type, target,
+                    clustername, fsid, nfsbaseid, managerid, fsid);
+        } else if (hasPoolFs(fsid)) {
+            LOGGER.debug("PoolFs already exists on this host: " + fsid);
+            return true;
+        } else {
+            throw new Ovm3ResourceException("Unable to add pool filesystem to host, "+
+                    "pool filesystem with other id found: " + poolFsId);
+        }
+    }
+
+    /* Assume a single pool can be used for a host... */
+    public Boolean discoverPoolFs() throws Ovm3ResourceException{
+        // should throw exception if no poolIps set
+        Object x = callWrapper("discover_pool_filesystem");
+        if (x == null) {
+            return false;
+        }
+        Document xmlDocument = prepParse((String) x);
+        String path = "//Discover_Pool_Filesystem_Result";
+        poolFileSystem = xmlToMap(path + "/Pool_Filesystem", xmlDocument);
+        poolFsTarget = poolFileSystem.get("Pool_Filesystem_Target");
+        poolFsType = poolFileSystem.get("Pool_Filesystem_Type");
+        poolFsNFSBaseId = poolFileSystem.get("Pool_Filesystem_Nfsbase_Uuid");
+        poolFsId = poolFileSystem.get("Pool_Filesystem_Uuid");
+        poolPoolFsId = poolFileSystem.get("Pool_Filesystem_Pool_Uuid");
+        poolFsManagerUuid = poolFileSystem.get("Pool_Filesystem_Manager_Uuid");
+        poolFsVersion = poolFileSystem.get("Pool_Filesystem_Version");
+        return true;
+    }
+
+    public Boolean ocfs2GetMetaData(String device, String filename) throws Ovm3ResourceException {
+        Object x = callWrapper("ocfs2_get_meta_data", device, filename);
+        if (x == null) {
+            return true;
+        }
+        return false;
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Remote.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Remote.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Remote.java
new file mode 100644
index 0000000..adfa239
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Remote.java
@@ -0,0 +1,34 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+public class Remote extends OvmObject {
+
+    public Remote(Connection c) {
+        setClient(c);
+    }
+
+    public Boolean sysShutdown() throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("sys_shutdown");
+    }
+
+    public Boolean sysReboot() throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("sys_reboot");
+    }
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Repository.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Repository.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Repository.java
new file mode 100644
index 0000000..7e842ce
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/Repository.java
@@ -0,0 +1,334 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import org.apache.log4j.Logger;
+import org.w3c.dom.Document;
+
+public class Repository extends OvmObject {
+    private static final Logger LOGGER = Logger.getLogger(Repository.class);
+    private static final String VERSION = "Version";
+    private static final String NAMETAG = "[@Name='";
+    private Object postDiscovery = null;
+    private Object postDbDiscovery = null;
+    private Map<String, RepoDbDetails> repoDbs = new HashMap<String, RepoDbDetails>();
+    private Map<String, RepoDetails> repos = new HashMap<String, RepoDetails>();
+    private List<String> repoDbList = new ArrayList<String>();
+    private List<String> repoList = new ArrayList<String>();
+
+    public Repository(Connection c) {
+        setClient(c);
+    }
+
+    public RepoDbDetails getRepoDb(String id) throws Ovm3ResourceException {
+        if (repoDbs.containsKey(id)) {
+            return repoDbs.get(id);
+        }
+        return null;
+    }
+
+    public List<String> getRepoDbList() throws Ovm3ResourceException {
+        return repoDbList;
+    }
+
+    public RepoDetails getRepo(String id) throws Ovm3ResourceException {
+        if (repos.containsKey(id)) {
+            return repos.get(id);
+        }
+        return null;
+    }
+
+    public List<String> getRepoList() throws Ovm3ResourceException {
+        return repoList;
+    }
+
+    public static class RepoDbDetails {
+        private final Map<String, String> dbEntry = new HashMap<String, String>() {
+            {
+                put("Uuid", null);
+                put("Fs_location", null);
+                put("Mount_point", null);
+                put("Filesystem_type", null);
+                put(VERSION, null);
+                put("Alias", null);
+                put("Manager_uuid", null);
+                put("Status", null);
+            }
+        };
+
+        public RepoDbDetails() {
+        }
+
+        public void setRepoDbDetails(Map<String, String> det) {
+            dbEntry.putAll(det);
+        }
+
+        public void setUuid(String id) {
+            dbEntry.put("Uuid", id);
+        }
+
+        public String getStatus() {
+            return dbEntry.get("Status");
+        }
+
+        public String getManagerUuid() {
+            return dbEntry.get("Manager_uuid");
+        }
+
+        public String getAlias() {
+            return dbEntry.get("Alias");
+        }
+
+        public String getVersion() {
+            return dbEntry.get(VERSION);
+        }
+
+        public String getFilesystemType() {
+            return dbEntry.get("Filesystem_type");
+        }
+
+        public String getMountPoint() {
+            return dbEntry.get("Mount_point");
+        }
+
+        public String getFsLocation() {
+            return dbEntry.get("Fs_location");
+        }
+
+        public String getUuid() {
+            return dbEntry.get("Uuid");
+        }
+
+    }
+
+    public static class RepoDetails {
+        private List<String> templates = new ArrayList<String>();
+        private List<String> virtualMachines = new ArrayList<String>();
+        private List<String> virtualDisks = new ArrayList<String>();
+        private List<String> isos = new ArrayList<String>();
+        private final Map<String, String> dbEntry = new HashMap<String, String>() {
+            {
+                put("Repository_UUID", null);
+                put(VERSION, null);
+                put("Repository_Alias", null);
+                put("Manager_UUID", null);
+            }
+        };
+
+        public RepoDetails() {
+        }
+
+        public String getManagerUuid() {
+            return dbEntry.get("Manager_UUID");
+        }
+
+        public String getAlias() {
+            return dbEntry.get("Repository_Alias");
+        }
+
+        public String getVersion() {
+            return dbEntry.get(VERSION);
+        }
+
+        public String getUuid() {
+            return dbEntry.get("Repository_UUID");
+        }
+
+        public void setRepoDetails(Map<String, String> det) {
+            dbEntry.putAll(det);
+        }
+
+        public void setRepoTemplates(List<String> temp) {
+            templates.addAll(temp);
+        }
+
+        public List<String> getRepoTemplates() {
+            return templates;
+        }
+
+        public void setRepoVirtualMachines(List<String> vms) {
+            virtualMachines.addAll(vms);
+        }
+
+        public List<String> getRepoVirtualMachines() {
+            return virtualMachines;
+        }
+
+        public void setRepoVirtualDisks(List<String> disks) {
+            virtualDisks.addAll(disks);
+        }
+
+        public List<String> getRepoVirtualDisks() {
+            return virtualDisks;
+        }
+
+        public void setRepoISOs(List<String> isolist) {
+            isos.addAll(isolist);
+        }
+
+        public List<String> getRepoISOs() {
+            return isos;
+        }
+    }
+
+    /*
+     * delete_repository, <class 'agent.api.repository.Repository'> argument:
+     * repo_uuid - default: None argument: erase - default: None
+     */
+    public Boolean deleteRepo(String id, Boolean erase)
+            throws Ovm3ResourceException {
+        Object res = callWrapper("delete_repository", id, erase);
+        if (res == null) {
+            return true;
+        }
+        return false;
+    }
+
+    /*
+     * import_virtual_disk, <class 'agent.api.repository.Repository'> argument:
+     * url - default: None argument: virtual_disk_id - default: None argument:
+     * repo_uuid - default: None argument: option - default: None
+     */
+    /* should add timeout ? */
+    public Boolean importVirtualDisk(String url, String vdiskid, String repoid,
+            String option) throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("import_virtual_disk", url, vdiskid,
+                repoid, option);
+    }
+
+    public Boolean importVirtualDisk(String url, String vdiskid, String repoid)
+            throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("import_virtual_disk", url, vdiskid,
+                repoid);
+    }
+
+    /*
+     * discover_repositories, <class 'agent.api.repository.Repository'>
+     * argument: args - default: None
+     */
+    /*
+     * args are repo ids <Discover_Repositories_Result> <RepositoryList/>
+     * </Discover_Repositories_Result>
+     */
+    public Boolean discoverRepo(String id) throws Ovm3ResourceException {
+        postDiscovery = callWrapper("discover_repositories", id);
+        if (postDiscovery == null) {
+            return false;
+        }
+        Document xmlDocument = prepParse((String) postDiscovery);
+        String path = "//Discover_Repositories_Result/RepositoryList/Repository";
+        repoList = new ArrayList<String>();
+        repoList.addAll(xmlToList(path + "/@Name", xmlDocument));
+        for (String name : repoList) {
+            RepoDetails repo = new RepoDetails();
+            repo.setRepoTemplates(xmlToList(path + NAMETAG + id
+                    + "']/Templates/Template/File", xmlDocument));
+            repo.setRepoVirtualMachines(xmlToList(path + NAMETAG + id
+                    + "']/VirtualMachines/VirtualMachine/@Name", xmlDocument));
+            repo.setRepoVirtualDisks(xmlToList(path + NAMETAG + name
+                    + "']/VirtualDisks/Disk", xmlDocument));
+            repo.setRepoISOs(xmlToList(
+                    path + NAMETAG + name + "']/ISOs/ISO", xmlDocument));
+            Map<String, String> details = xmlToMap(path + NAMETAG + name
+                    + "']", xmlDocument);
+            repo.setRepoDetails(details);
+            repos.put(name, repo);
+        }
+        return true;
+    }
+
+    /*
+     * add_repository, <class 'agent.api.repository.Repository'> argument:
+     * fs_location - default: None argument: mount_point - default: None
+     */
+    public Boolean addRepo(String remote, String local)
+            throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("add_repository", remote, local);
+    }
+
+    /**
+     * is the same as discoverRepoDb in principle (takes an id or mountpoint)
+     * get_repository_meta_data, <class 'agent.api.repository.Repository'>
+     * argument: repo_mount_point - default: None
+     */
+
+    /*
+     * mount_repository_fs, <class 'agent.api.repository.Repository'> argument:
+     * fs_location - default: None argument: mount_point - default: None
+     */
+    public Boolean mountRepoFs(String remote, String local)
+            throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("mount_repository_fs", remote, local);
+    }
+
+    /*
+     * unmount_repository_fs, <class 'agent.api.repository.Repository'>
+     * argument: mount_point - default: None
+     */
+    public Boolean unmountRepoFs(String local) throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("unmount_repository_fs", local);
+    }
+
+    /*
+     * create_repository, <class 'agent.api.repository.Repository'> argument:
+     * fs_location - default: None argument: mount_point - default: None
+     * argument: repo_uuid - default: None argument: repo_alias - default: None
+     */
+    public Boolean createRepo(String remote, String local, String repoid,
+            String repoalias) throws Ovm3ResourceException {
+        return nullIsTrueCallWrapper("create_repository", remote, local,
+                repoid, repoalias);
+    }
+
+    /*
+     * discover_repository_db, <class 'agent.api.repository.Repository'>
+     * <Discover_Repository_Db_Result> <RepositoryDbList> <Repository
+     * Uuid="0004fb0000030000aeaca859e4a8f8c0">
+     * <Fs_location>cs-mgmt:/volumes/cs-data/primary</Fs_location>
+     * <Mount_point>/
+     * OVS/Repositories/0004fb0000030000aeaca859e4a8f8c0</Mount_point>
+     * <Filesystem_type>nfs</Filesystem_type> <Version>3.0</Version>
+     * <Alias>MyRepo</Alias>
+     * <Manager_uuid>0004fb00000100000af70d20dcce7d65</Manager_uuid>
+     * <Status>Unmounted</Status> </Repository> <Repository> ... </Repository>
+     * </RepositoryDbList> </Discover_Repository_Db_Result>
+     */
+    public Boolean discoverRepoDb() throws Ovm3ResourceException {
+        postDbDiscovery = callWrapper("discover_repository_db");
+        Document xmlDocument = prepParse((String) postDbDiscovery);
+        String path = "//Discover_Repository_Db_Result/RepositoryDbList/Repository";
+        repoDbList = new ArrayList<String>();
+        repoDbList.addAll(xmlToList(path + "/@Uuid", xmlDocument));
+        for (String id : repoDbList) {
+            RepoDbDetails repoDb = new RepoDbDetails();
+            Map<String, String> rep = xmlToMap(path + "[@Uuid='" + id + "']",
+                    xmlDocument);
+            repoDb.setRepoDbDetails(rep);
+            repoDb.setUuid(id);
+            repoDbs.put(id, repoDb);
+        }
+        return true;
+    }
+
+}

http://git-wip-us.apache.org/repos/asf/cloudstack/blob/c27c6943/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/RpcTypeFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/RpcTypeFactory.java b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/RpcTypeFactory.java
new file mode 100644
index 0000000..1078e6e
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/main/java/com/cloud/hypervisor/ovm3/objects/RpcTypeFactory.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * 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.ovm3.objects;
+
+import org.apache.ws.commons.util.NamespaceContextImpl;
+import org.apache.xmlrpc.common.TypeFactoryImpl;
+import org.apache.xmlrpc.common.XmlRpcController;
+import org.apache.xmlrpc.common.XmlRpcStreamConfig;
+import org.apache.xmlrpc.parser.NullParser;
+import org.apache.xmlrpc.parser.TypeParser;
+import org.apache.xmlrpc.parser.AtomicParser;
+import org.apache.xmlrpc.serializer.NullSerializer;
+import org.apache.xmlrpc.serializer.TypeSerializer;
+import org.apache.xmlrpc.serializer.TypeSerializerImpl;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.ContentHandler;
+
+public class RpcTypeFactory extends TypeFactoryImpl {
+
+    public RpcTypeFactory(XmlRpcController pController) {
+        super(pController);
+    }
+
+    @Override
+    public TypeParser getParser(XmlRpcStreamConfig pConfig,
+            NamespaceContextImpl pContext, String pURI, String pLocalName) {
+        if ("".equals(pURI) && NullSerializer.NIL_TAG.equals(pLocalName)) {
+            return new NullParser();
+        } else if ("i8".equals(pLocalName)) {
+            return new LongTypeParser();
+        } else {
+            return super.getParser(pConfig, pContext, pURI, pLocalName);
+        }
+    }
+
+    public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig,
+            Object pObject) throws SAXException {
+        if (pObject instanceof Long) {
+            return new LongTypeSerializer();
+        } else {
+            return super.getSerializer(pConfig, pObject);
+        }
+    }
+
+    private class LongTypeSerializer extends TypeSerializerImpl {
+        /*
+         * Tag name of an i8 value.
+         */
+        public static final String I8_TAG = "i8";
+        /*
+         * Fully qualified name of an i8 value.
+         */
+        public static final String EX_I8_TAG = "i8";
+        @Override
+        public void write(ContentHandler pHandler, Object pObject)
+                throws SAXException {
+            write(pHandler, I8_TAG, EX_I8_TAG, pObject.toString());
+        }
+    }
+
+    private class LongTypeParser extends AtomicParser {
+        protected void setResult(String pResult) throws SAXException {
+            try {
+                super.setResult(Long.valueOf(pResult.trim()));
+            } catch (NumberFormatException e) {
+                throw new SAXParseException("Failed to parse long value: "
+                        + pResult, getDocumentLocator());
+            }
+        }
+    }
+}