You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cloudstack.apache.org by da...@apache.org on 2014/06/23 12:39:53 UTC
[3/8] CLOUDSTACK-6967: Now with module!
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Pool.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Pool.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Pool.java
new file mode 100644
index 0000000..2b87c70
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Pool.java
@@ -0,0 +1,362 @@
+/*******************************************************************************
+ * Licensed 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.object;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.w3c.dom.Document;
+import org.apache.commons.lang.StringUtils;
+import org.apache.xmlrpc.XmlRpcException;
+
+/*
+ * synonym to the pool python lib in the ovs-agent
+ */
+public class Pool extends OvmObject {
+ /*
+ * {Pool_Filesystem_Target=cs-mgmt:/volumes/cs-data/secondary,
+ * Pool_Filesystem_Type=nfs,
+ * Pool_Filesystem_Nfsbase_Uuid=b8ca41cb-3469-4f74-a086-dddffe37dc2d,
+ * Pool_Filesystem_Uuid=0004fb0000050000e70fbddeb802208f}
+ */
+ private List<String> validRoles = new ArrayList<String>() {
+ {
+ add("utility");
+ add("xen");
+ }
+ };
+ private Boolean _poolDisc = false;
+ public Map<String, String> poolFileSystem = new HashMap<String, String>();
+ public List<String> poolIps = new ArrayList<String>();
+ private List<String> poolRoles = new ArrayList<String>();
+ public List<String> poolMembers = new ArrayList<String>();
+ public String poolMasterVip;
+ public String poolAlias;
+ public String poolId = "";
+
+ public Pool(Connection c) throws ParserConfigurationException, IOException,
+ Exception {
+ client = c;
+ discoverServerPool();
+ }
+
+ public String getPoolMasterVip() {
+ return this.poolMasterVip;
+ }
+
+ public String getPoolAlias() {
+ return this.poolAlias;
+ }
+
+ public String getPoolId() {
+ return this.poolId;
+ }
+
+ /* TODO: check the toString for the list x,x */
+ public List<String> getValidRoles() {
+ return this.validRoles;
+ }
+
+ public void setPoolIps(List<String> ips) {
+ this.poolIps = new ArrayList<String>();
+ this.poolIps.addAll(ips);
+ }
+
+ /*
+ * create_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: pool_alias - default: None argument:
+ * pool_uuid - default: None argument: pool_virtual_ip - default: None
+ * argument: node_number - default: None argument: server_hostname -
+ * default: None argument: server_ip - default: None argument: roles -
+ * default: None
+ */
+ public Boolean createServerPool(String alias, String id, String vip,
+ int num, String name, String ip, List<String> roles)
+ throws XmlRpcException {
+ String role = roles.toString();
+ role = "xen,utility";
+ Object x = callWrapper("create_server_pool", alias, id, vip, num, name,
+ ip,
+ role);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean createServerPool(String alias, String id, String vip,
+ int num, String name, String ip) throws XmlRpcException {
+ return this.createServerPool(alias,
+ id,
+ vip,
+ num,
+ name,
+ ip,
+ getValidRoles());
+ }
+ public Boolean createServerPool(int num, String name, String ip)
+ throws XmlRpcException {
+ return createServerPool(poolAlias, poolId, poolMasterVip, num, name,
+ ip, poolRoles);
+ }
+
+ /*
+ * update_pool_virtual_ip, <class 'agent.api.serverpool.ServerPool'>
+ * argument: self - default: None argument: new_pool_vip - default: None
+ */
+ public Boolean updatePoolVirtualIp(String ip) throws XmlRpcException {
+ Object x = callWrapper("update_pool_virtual_ip", ip);
+ if (x == null) {
+ this.poolMasterVip = ip;
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * leave_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: pool_uuid - default: None
+ */
+ public Boolean leaveServerPool(String uuid) throws XmlRpcException {
+ Object x = callWrapper("leave_server_pool", uuid);
+ if (x == null)
+ return true;
+ return false;
+ }
+
+ /*
+ * set_server_pool_alias, <class 'agent.api.serverpool.ServerPool'>
+ * argument: self - default: None argument: pool_alias - default: None
+ */
+ public Boolean setServerPoolAlias(String alias) throws XmlRpcException {
+ Object x = callWrapper("set_server_pool_alias", alias);
+ if (x == null) {
+ this.poolAlias = alias;
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * take_ownership, <class 'agent.api.serverpool.ServerPool'> argument: self
+ * - default: None argument: manager_uuid - default: None argument:
+ * manager_core_api_url - default: None
+ * take_ownership('0004fb00000100000af70d20dcce7d65',
+ * 'https://2f55e3b9efa6f067ad54a7b144bb6f2e:
+ * ******@0.0.0.0:7002/ovm/core/OVMManagerCoreServlet')
+ */
+ public Boolean takeOwnership(String uuid, String apiurl)
+ throws XmlRpcException {
+ Object x = callWrapper("take_ownership", uuid, apiurl);
+ if (x == null) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * destroy_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: pool_uuid - default: None
+ */
+ public Boolean destroyServerPool(String uuid) throws XmlRpcException {
+ Object x = callWrapper("destroy_server_pool", uuid);
+ if (x == null) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * release_ownership, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: manager_uuid - default: None
+ */
+ public Boolean releaseOwnership(String uuid) throws XmlRpcException {
+ Object x = callWrapper("release_ownership", uuid);
+ if (x == null) {
+ return true;
+ }
+ return false;
+ }
+
+ /* server.discover_pool_filesystem */
+ /*
+ * discover_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None
+ */
+ public Boolean discoverServerPool() throws ParserConfigurationException,
+ IOException, Exception {
+ /* forcefull rediscover for now */
+ if (this._poolDisc) {
+ return true;
+ }
+ Object x = callWrapper("discover_server_pool");
+ if (x == null) {
+ return false;
+ }
+
+ try {
+ Document xmlDocument = prepParse((String) x);
+ String path = "//Discover_Server_Pool_Result/Server_Pool";
+ this.poolId = xmlToString(path + "/Unique_Id", xmlDocument);
+ this.poolAlias = xmlToString(path + "/Pool_Alias", xmlDocument);
+ this.poolMasterVip = xmlToString(path + "/Master_Virtual_Ip",
+ xmlDocument);
+ this.poolMembers = xmlToList(path + "/Member_List", xmlDocument);
+ this.poolIps
+ .addAll(xmlToList(path + "//Registered_IP", xmlDocument));
+ this._poolDisc = true;
+ } catch (Exception e) {
+ if (e.getMessage() == null) {
+ System.err.println("No pool to discover: " + e.getMessage());
+ } else {
+ System.err.println("Error in pooldiscovery: " + e.getMessage());
+ }
+ }
+
+ return true;
+ }
+
+ /*
+ * update_server_roles, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: roles - default: None ?> list or sring
+ */
+ private Boolean validPoolRole(String role) throws Exception {
+ for (String r : this.validRoles) {
+ if (r.contentEquals(role)) {
+ return true;
+ }
+ }
+ throw new Exception("Illegal role: " + role);
+ }
+
+ private Boolean validPoolRole(List<String> roles) throws Exception {
+ for (String r : roles) {
+ return validPoolRole(r);
+ }
+ return false;
+ }
+
+ public Boolean setServerRoles() throws XmlRpcException, Exception {
+ validPoolRole(this.poolRoles);
+ String roles = StringUtils.join(this.poolRoles.toArray(), ",");
+ Object x = callWrapper("update_server_roles", roles);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /* do some sanity check on the valid poolroles */
+ public Boolean setServerRoles(List<String> roles) throws Exception {
+ this.poolRoles.addAll(roles);
+ return setServerRoles();
+ }
+
+
+ public void addServerRole(String role) throws Exception {
+ validPoolRole(role);
+ this.poolRoles.add(role);
+ }
+
+ public void removeServerRole(String role) {
+ this.poolRoles.remove(role);
+ }
+
+ public boolean serverHasRole(String role) {
+ for (String r : this.poolRoles) {
+ if (r.contentEquals(role)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ /*
+ * join_server_pool, <class 'agent.api.serverpool.ServerPool'> argument:
+ * self - default: None argument: pool_alias - default: None argument:
+ * pool_uuid - default: None argument: pool_virtual_ip - default: None
+ * argument: node_number - default: None argument: server_hostname -
+ * default: None argument: server_ip - default: None argument: roles -
+ * default: None
+ */
+ /* allow these to be set before ? */
+ public Boolean joinServerPool(String alias, String id, String vip, int num,
+ String name, String ip, List<String> roles) throws XmlRpcException {
+ String role = StringUtils.join(roles.toArray(), ",");
+ Object x = callWrapper("join_server_pool", alias, id, vip, num, name,
+ ip,
+ role);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean joinServerPool(String alias, String id, String vip, int num,
+ String name, String ip) throws XmlRpcException {
+ return joinServerPool(alias, id, vip, num, name, ip, getValidRoles());
+ }
+
+ public Boolean joinServerPool(int num, String name, String ip)
+ throws XmlRpcException {
+ return joinServerPool(poolAlias, poolId, poolMasterVip, num, name, ip,
+ poolRoles);
+ }
+
+ /*
+ * set_pool_member_ip_list, <class 'agent.api.serverpool.ServerPool'>
+ * argument: self - default: None argument: ip_list - default: None
+ */
+ public Boolean setPoolMemberIpList() throws XmlRpcException {
+ // should throw exception if no poolIps set
+ Object x = callWrapper("set_pool_member_ip_list", this.poolIps);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public List getPoolMemberIpList() throws XmlRpcException, Exception {
+ if (poolIps.size() == 0) {
+ this.discoverServerPool();
+ }
+ return poolIps;
+ }
+
+ /* TODO: need to change the logic here */
+ public Boolean setPoolMemberIpList(String ip) throws XmlRpcException {
+ this.poolIps = new ArrayList<String>();
+ this.poolIps.add(ip);
+ return setPoolMemberIpList();
+ }
+
+ public Boolean addPoolMemberIp(String ip) throws XmlRpcException, Exception {
+ this.getPoolMemberIpList();
+ this.poolIps.add(ip);
+ return setPoolMemberIpList();
+ }
+
+ /* meh */
+ public Boolean removePoolMemberIp(String ip) throws XmlRpcException,
+ Exception {
+ this.getPoolMemberIpList();
+ this.poolIps.remove(ip);
+ return setPoolMemberIpList();
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/PoolOCFS2.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/PoolOCFS2.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/PoolOCFS2.java
new file mode 100644
index 0000000..1759224
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/PoolOCFS2.java
@@ -0,0 +1,157 @@
+/*******************************************************************************
+ * Licensed 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.object;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xmlrpc.XmlRpcException;
+import org.w3c.dom.Document;
+
+/* should ingest this into Pool */
+public class PoolOCFS2 extends OvmObject {
+ public Map<String, String> poolFileSystem = new HashMap<String, String>();
+ public String poolFsTarget;
+ public String poolFsType;
+ public String poolFsNFSBaseId;
+ public String poolFsId;
+
+ public String poolFsNFSBaseId() {
+ return this.poolFsNFSBaseId;
+ }
+
+ public String poolFsId() {
+ return this.poolFsId;
+ }
+
+ public String poolFsUuid() {
+ return this.poolFsId;
+ }
+
+ public String poolFsTarget() {
+ return this.poolFsTarget;
+ }
+
+ public PoolOCFS2(Connection c) {
+ client = c;
+ }
+
+ /*
+ * destroy_pool_filesystem, <class 'agent.api.poolfs.ocfs2.PoolOCFS2'>
+ * argument: self - default: None argument: poolfs_type - default: None
+ * argument: poolfs_target - default: None argument: poolfs_uuid - default:
+ * None argument: poolfs_nfsbase_uuid - default: None
+ */
+ public Boolean destroyPoolFs(String type, String target, String uuid,
+ String nfsbaseuuid) throws ParserConfigurationException,
+ IOException, Exception {
+ // should throw exception if no poolIps set
+ Object x = callWrapper("destroy_pool_filesystem", type, target, uuid,
+ nfsbaseuuid);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean destroyPoolFs() throws ParserConfigurationException,
+ IOException, Exception {
+ // should throw exception if no poolIps set
+ Object x = callWrapper("destroy_pool_filesystem", poolFsType,
+ poolFsTarget, poolFsId, poolFsNFSBaseId);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * create_pool_filesystem, <class 'agent.api.poolfs.ocfs2.PoolOCFS2'>
+ * argument: self - default: None argument: poolfs_type - default: None
+ * argument: poolfs_target - default: None argument: cluster_name - default:
+ * None argument: poolfs_uuid - default: None argument: poolfs_nfsbase_uuid
+ * - default: None argument: manager_uuid - default: None argument:
+ * pool_uuid - default: None argument: block_size - default: None argument:
+ * cluster_size - default: None argument: journal_size - default: None
+ */
+ /*
+ * create_pool_filesystem('nfs', 'cs-mgmt:/volumes/cs-data/secondary',
+ * 'ba9aaf00ae5e2d73', '0004fb0000050000e70fbddeb802208f',
+ * 'b8ca41cb-3469-4f74-a086-dddffe37dc2d',
+ * '0004fb00000100000af70d20dcce7d65', '0004fb0000020000ba9aaf00ae5e2d73')
+ */
+ public Boolean createPoolFs(String type, String target, String clustername,
+ String fsid, String nfsbaseid, String managerid, String id)
+ throws XmlRpcException {
+ Object x = callWrapper("create_pool_filesystem", type, target,
+ clustername, fsid, nfsbaseid, managerid, id);
+ // System.out.println(x);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean createPoolFs(String type, String target, String clustername,
+ String fsid, String nfsbaseid, String managerid, String id,
+ int blocksize, int clustersize, int journalsize)
+ throws XmlRpcException {
+ Object x = callWrapper("create_pool_filesystem", type, target,
+ clustername, fsid, nfsbaseid, managerid, id, blocksize,
+ clustersize, journalsize);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * discover_pool_filesystem, <class 'agent.api.poolfs.ocfs2.PoolOCFS2'>
+ * argument: self - default: None
+ */
+ public Boolean discoverPoolFs() throws ParserConfigurationException,
+ IOException, Exception {
+ // should throw exception if no poolIps set
+ Object x = callWrapper("discover_pool_filesystem");
+ 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");
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * ocfs2_get_meta_data, <class 'agent.api.poolfs.ocfs2.PoolOCFS2'> argument:
+ * self - default: None argument: device - default: None argument: filename
+ * - default: None
+ */
+ public Boolean ocfs2GetMetaData(String device, String filename)
+ throws XmlRpcException {
+ Object x = callWrapper("ocfs2_get_meta_data", device, filename);
+ // System.out.println(x);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Remote.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Remote.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Remote.java
new file mode 100644
index 0000000..a2ae0a4
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Remote.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * Licensed 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.object;
+
+import org.apache.xmlrpc.XmlRpcException;
+
+/*
+ * should become an interface implementation
+ */
+public class Remote extends OvmObject {
+
+ public Remote(Connection c) {
+ client = c;
+ }
+
+ /*
+ * sys_shutdown, <class
+ * 'agent.api.remote.linux_remote.LinuxRemoteManagement'> argument: self -
+ * default: None
+ */
+ public Boolean sysShutdown() throws XmlRpcException {
+ Object x = callWrapper("sys_shutdown");
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * remote_power_off, <class
+ * 'agent.api.remote.linux_remote.LinuxRemoteManagement'> argument: self -
+ * default: None argument: controller_type - default: None ?> figure this
+ * one out in the source argument: tgt_host - default: None argument:
+ * bmc_username - default: None argument: bmc_password - default: None
+ */
+
+ /*
+ * sys_reboot, <class 'agent.api.remote.linux_remote.LinuxRemoteManagement'>
+ * argument: self - default: None
+ */
+ public Boolean sysReboot() throws XmlRpcException {
+ Object x = callWrapper("sys_reboot");
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * remote_power_on, <class
+ * 'agent.api.remote.linux_remote.LinuxRemoteManagement'> argument: self -
+ * default: None argument: controller_type - default: None ?> same here
+ * argument: tgt - default: None argument: arg1 - default: None argument:
+ * arg2 - default: None
+ */
+
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Repository.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Repository.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Repository.java
new file mode 100644
index 0000000..d45f198
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/Repository.java
@@ -0,0 +1,205 @@
+/*******************************************************************************
+ * Licensed 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.object;
+
+import java.util.Map;
+
+import org.apache.xmlrpc.XmlRpcException;
+
+/*
+ * should become an interface implementation
+ */
+public class Repository extends OvmObject {
+
+ public Repository(Connection c) {
+ client = c;
+ }
+
+ /*
+ * delete_repository, <class 'agent.api.repository.Repository'> argument:
+ * repo_uuid - default: None argument: erase - default: None
+ */
+ public Boolean deleteRepo(String id, Boolean erase) throws XmlRpcException {
+ Object x = callWrapper("delete_repository", id, erase);
+ if (x == 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 XmlRpcException {
+ Object x = callWrapper("import_virtual_disk", url, vdiskid, repoid, option);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+ public Boolean importVirtualDisk(String url, String vdiskid, String repoid) throws XmlRpcException {
+ Object x = callWrapper("import_virtual_disk", url, vdiskid, repoid);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * 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(Map<String, String> args)
+ throws XmlRpcException {
+ Object x = callWrapper("discover_repositories", args);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean discoverRepo(String id) throws XmlRpcException {
+ Object x = callWrapper("discover_repositories", id);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * 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 XmlRpcException {
+ Object x = callWrapper("add_repository", remote, local);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * get_repository_meta_data, <class 'agent.api.repository.Repository'>
+ * argument: repo_mount_point - default: None
+ */
+ public Boolean getRepoMetaData(String local) throws XmlRpcException {
+ Object x = callWrapper("get_repository_meta_data", local);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * 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 XmlRpcException {
+ Object x = callWrapper("mount_repository_fs", remote, local);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * unmount_repository_fs, <class 'agent.api.repository.Repository'>
+ * argument: mount_point - default: None
+ */
+ public Boolean unmountRepoFs(String local) throws XmlRpcException {
+ Object x = callWrapper("unmount_repository_fs", local);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * 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 XmlRpcException {
+ Object x = callWrapper("create_repository", remote, local, repoid,
+ repoalias);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * 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 XmlRpcException {
+ Object x = callWrapper("discover_repository_db");
+ // System.out.println(x);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * edit_repository_db, <class 'agent.api.repository.Repository'> argument:
+ * repo_uuid - default: None argument: db_changes - default: None
+ */
+ public Boolean editRepoDb(String repoId, Map<String, String> changes)
+ throws XmlRpcException {
+ Object x = callWrapper("edit_repository_db", repoId, changes);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * import_ISO, <class 'agent.api.repository.Repository'> argument: url -
+ * default: None argument: iso_id - default: None argument: repo_uuid -
+ * default: None argument: option - default: None ?> it throws an error when
+ * you add this...
+ */
+ /*
+ * is async, need to find a way to do something with that.... add timeout
+ * too
+ */
+ public Boolean importIso(String url, String isoId, String repoId,
+ String option) throws XmlRpcException {
+ Object x = callWrapper("import_ISO", url, isoId, repoId);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/RpcTypeFactory.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/RpcTypeFactory.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/RpcTypeFactory.java
new file mode 100644
index 0000000..240efef
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/RpcTypeFactory.java
@@ -0,0 +1,92 @@
+/*******************************************************************************
+ * Licensed 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.
+ ******************************************************************************/
+/*
+ * Dealing with nil..... -sigh-
+ * http://libjack.com/2009/03/26/java-magento-xmlrpc-api-nil-issue/
+ *
+ * i8 - aka long
+ */
+
+package com.cloud.hypervisor.ovm3.object;
+
+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 (pLocalName.equals("i8")) {
+ 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(new Long(pResult.trim()));
+ } catch (NumberFormatException e) {
+ throw new SAXParseException("Failed to parse long value: "
+ + pResult, getDocumentLocator());
+ }
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/cloudstack/blob/189972bc/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/StoragePlugin.java
----------------------------------------------------------------------
diff --git a/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/StoragePlugin.java b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/StoragePlugin.java
new file mode 100644
index 0000000..c311523
--- /dev/null
+++ b/plugins/hypervisors/ovm3/src/com/cloud/hypervisor/ovm3/object/StoragePlugin.java
@@ -0,0 +1,876 @@
+/*******************************************************************************
+ * Licensed 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.object;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+import javax.xml.parsers.ParserConfigurationException;
+
+import org.apache.xmlrpc.XmlRpcException;
+import org.w3c.dom.Document;
+
+/*
+ * should become an interface implementation
+ */
+public class StoragePlugin extends OvmObject {
+ /* nfs or iscsi should be an "enabled" flag */
+ /*
+ * storage_plugin_mount('oracle.generic.NFSPlugin.GenericNFSPlugin', {
+ * 'status': '', 'admin_user': '', 'admin_host': '', 'uuid':
+ * '0004fb00000900000c2461c2f62ba43e', 'total_sz': 0, 'admin_passwd':
+ * '******', 'storage_desc': '', 'free_sz': 0, 'access_host': 'cs-mgmt',
+ * 'storage_type': 'FileSys', 'alloc_sz': 0, 'access_grps': [], 'used_sz':
+ * 0, 'name': '0004fb00000900000c2461c2f62ba43e'}, { 'status': '', 'uuid':
+ * 'b8ca41cb-3469-4f74-a086-dddffe37dc2d', 'ss_uuid':
+ * '0004fb00000900000c2461c2f62ba43e', 'size': '263166853120', 'free_sz':
+ * '259377299456', 'state': 1, 'access_grp_names': [], 'access_path':
+ * 'cs-mgmt:/volumes/cs-data/secondary', 'name':
+ * 'nfs:/volumes/cs-data/secondary'},
+ * '/nfsmnt/b8ca41cb-3469-4f74-a086-dddffe37dc2d', '', True, [])
+ */
+ private String pluginType = "oracle.generic.NFSPlugin.GenericNFSPlugin";
+
+ /* TODO: subclass */
+ /*
+ * Json, but then it's xml... {'status': '', 'admin_user': '', 'admin_host':
+ * '', 'uuid': '0004fb00000900000c2461c2f62ba43e', 'total_sz': 0,
+ * 'admin_passwd': '******', 'storage_desc': '', 'free_sz': 0,
+ * 'access_host': 'cs-mgmt', 'storage_type': 'FileSys', 'alloc_sz': 0,
+ * 'access_grps': [], 'used_sz': 0, 'name':
+ * '0004fb00000900000c2461c2f62ba43e'}
+ */
+ private Map<String, Object> baseProps = new HashMap<String, Object>() {
+ {
+ put("status", ""); /* empty */
+ put("admin_user", ""); /* auth */
+ put("admin_host", ""); /* auth host */
+ put("uuid", ""); /* no dash uuid */
+ put("total_sz", "");
+ put("admin_passwd", ""); /* iscsi or fc */
+ put("storage_desc", ""); /* description */
+ put("free_sz", 0);
+ put("access_host", ""); /* remote host for fs */
+ put("storage_type", "FileSys"); /* type, guess lun ? */
+ put("alloc_size", 0);
+ put("access_groups", new ArrayList<String>());
+ put("sed_size", 0);
+ put("name", ""); /* uuid no dashes */
+ };
+ };
+
+ public String setUuid(String val) {
+ this.baseProps.put("uuid", val);
+ return val;
+ }
+
+ public String getUuid() {
+ return (String) this.baseProps.get("uuid");
+ }
+
+ public String setName(String val) {
+ this.baseProps.put("name", val);
+ return val;
+ }
+
+ public String getName() {
+ return (String) this.baseProps.get("name");
+ }
+
+ public String setFsType(String val) {
+ this.baseProps.put("storage_type", val);
+ return val;
+ }
+
+ public String getFsType() {
+ return (String) this.baseProps.get("storage_type");
+ }
+
+ public String setFsHost(String val) {
+ this.baseProps.put("access_host", val);
+ return val;
+ }
+
+ public String getFsHost() {
+ return (String) this.baseProps.get("access_host");
+ }
+
+ public String setFsServer(String val) {
+ return this.setFsHost(val);
+ }
+
+ public String getFsServer() {
+ return this.getFsHost();
+ }
+
+ /* TODO: subclass */
+ /*
+ * Meh {'status': '', 'uuid': 'b8ca41cb-3469-4f74-a086-dddffe37dc2d',
+ * 'ss_uuid': '0004fb00000900000c2461c2f62ba43e', 'size': '263166853120',
+ * 'free_sz': '259377299456', 'state': 1, 'access_grp_names': [],
+ * 'access_path': 'cs-mgmt:/volumes/cs-data/secondary', 'name':
+ * 'nfs:/volumes/cs-data/secondary'}
+ */
+ private Map<String, Object> ssProps = new HashMap<String, Object>() {
+ {
+ put("status", ""); /* empty */
+ put("uuid", ""); /* with dashes */
+ put("ss_uuid", ""); /* no dashes */
+ put("size", "");
+ put("free_sz", "");
+ put("state", 1); /* guess this is active ? */
+ put("access_grp_names", new ArrayList<String>());
+ put("access_path", ""); /* remote path */
+ put("name", ""); /* just a name */
+ put("mount_options", new ArrayList<String>()); /*
+ * array of values
+ * which match normal
+ * mount options
+ */
+ };
+ };
+
+ public String setFsSourcePath(String val) {
+ this.ssProps.put("access_path", val);
+ return val;
+ }
+
+ public String getFsSourcePath() {
+ return (String) this.ssProps.get("access_path");
+ }
+
+ public String setMntUuid(String val) {
+ this.ssProps.put("uuid", val);
+ return val;
+ }
+
+ public String getMntUuid() {
+ return (String) this.ssProps.get("uuid");
+ }
+
+ public String setSsUuid(String val) {
+ this.ssProps.put("ss_uuid", val);
+ return val;
+ }
+
+ public String getSsUuid() {
+ return (String) this.ssProps.get("ss_uuid");
+ }
+
+ public String setSsName(String val) {
+ this.ssProps.put("name", val);
+ return val;
+ }
+
+ public String getSsName() {
+ return (String) this.ssProps.get("ss_uuid");
+ }
+
+ public String getFreeSize() {
+ return this.ssProps.get("free_sz").toString();
+ }
+
+ public String getTotalSize() {
+ return this.ssProps.get("size").toString();
+ }
+
+ public String getSize() {
+ return this.ssProps.get("size").toString();
+ }
+
+ /* TODO: subclass */
+ /* {'fr_type': 'File',
+ 'ondisk_sz': '48193536',
+ 'fs_uuid': '7718562d-872f-47a7-b454-8f9cac4ffa3a',
+ 'file_path': '/nfsmnt/7718562d-872f-47a7-b454-8f9cac4ffa3a/0004fb0000060000d4a1d2ec05a5e799.img',
+ 'file_sz': '52380672'}
+ */
+ private Map<String, Object> fileProps = new HashMap<String, Object>() {
+ {
+ put("fr_type", "");
+ put("ondisk_sz", "");
+ put("fs_uuid", "");
+ put("file_path", "");
+ put("file_sz", "");
+ }
+ };
+
+ public String getFileName() {
+ return (String) this.fileProps.get("file_path");
+ }
+ public long getFileSize() {
+ return Long.parseLong((String) this.fileProps.get("file_sz"));
+ }
+ private String mountPoint = "";
+
+ public String setFsMountPoint(String val) {
+ this.mountPoint = val;
+ return val;
+ }
+
+ public String getFsMountPoint() {
+ return mountPoint;
+ }
+
+ public String unknown = ""; /* empty */
+ public Boolean active = true;
+ public List<String> someList = new ArrayList<String>(); /* empty */
+
+ public StoragePlugin(Connection c) {
+ client = c;
+ }
+
+ /*
+ * storage_plugin_resizeFileSystem, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getStatus, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ * meh ?
+ */
+
+ /*
+ * storage_plugin_validate, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_setQoS, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /* TODO: make more generic now only for files
+ * storage_plugin_create, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ * - calls resize secretly.. after "create"
+ */
+ public Boolean storagePluginCreate(String poolUuid, String host,
+ String file, Long size) throws XmlRpcException {
+ /* this is correct ordering stuff */
+ String uuid = this.deDash(poolUuid);
+ ssProps.put("uuid", uuid);
+ ssProps.put("access_host", host);
+ ssProps.put("storage_type", "FileSys");
+ ssProps.put("name", "");
+ ssProps.put("status", "");
+ ssProps.put("admin_user", "");
+ ssProps.put("admin_passwd", "");
+ ssProps.put("admin_host", "");
+ ssProps.put("total_sz", "");
+ ssProps.put("free_sz", "");
+ ssProps.put("used_sz", "");
+ ssProps.put("access_grps", "");
+ ssProps.put("storage_desc", "");
+
+ baseProps.put("ss_uuid", uuid);
+ baseProps.put("state", 2);
+ baseProps.put("uuid", poolUuid);
+ /* some more bogus values */
+ baseProps.put("status", "");
+ baseProps.put("access_path", "");
+ baseProps.put("access_grp_names", "");
+ baseProps.put("name", "");
+ baseProps.put("size", "");
+
+ /*
+ * fileProps.put("fr_type", "File");
+ * fileProps.put("fs_uuid", ssuuid);
+ * fileProps.put("file_path", file);
+ * fileProps.put("file_sz", "");
+ * fileProps.put("ondisk_sz", "");
+ */
+ Object x = (HashMap<String, Object>)callWrapper("storage_plugin_create",
+ this.pluginType, this.ssProps, this.baseProps, file, "File", size);
+
+ if (x == null)
+ return true;
+
+ return true;
+ }
+
+ /*
+ * storage_plugin_createAccessGroups, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_deviceTeardown, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_startPresent, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_listFileSystems, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+ public Boolean storagePluginListFs(String type) throws XmlRpcException {
+ this.pluginType = type;
+ return storagePluginListFs();
+ }
+
+ public Boolean storagePluginListFs() throws XmlRpcException {
+ Map<String, String> y = new HashMap<String, String>();
+ Object x = callWrapper("storage_plugin_listFileSystems",
+ this.pluginType, y);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * storage_plugin_getFileSystemCloneLimits, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getQoSList, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_stopPresent, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_isCloneable, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /**
+ * .
+ * storage_plugin_mount, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+ public final Boolean storagePluginMount(String nfsHost, String nfsPath,
+ String mntUuid, String mountPoint) throws XmlRpcException {
+ String propUuid = this.deDash(mntUuid);
+ this.setUuid(propUuid);
+ this.setName(propUuid);
+ this.setFsServer(nfsHost);
+ this.setFsSourcePath(nfsHost + ":" + nfsPath);
+ this.setMntUuid(mntUuid);
+ this.setSsUuid(propUuid);
+ this.setSsName("nfs:" + nfsPath);
+ this.setFsMountPoint(mountPoint);
+ this.storagePluginMount();
+ Map<String, Object> x = (Map<String, Object>) callWrapper(
+ "storage_plugin_mount", this.pluginType, this.baseProps,
+ this.ssProps, this.mountPoint, this.unknown, this.active,
+ this.someList);
+ // System.out.println(x);
+ if (x == null) {
+ return true;
+ }
+ return false;
+ }
+
+ /*
+ * {ss_uuid=eb1dbafadee9450d876239bb5e3b7f4a,
+ * mount_options=[Ljava.lang.Object;@2d8dea20, status=,
+ * name=nfs:/volumes/cs-data/secondary, state=1,
+ * access_path=cs-mgmt:/volumes/cs-data/secondary,
+ * uuid=6ab917b0-a070-4254-8fe2-e2163ee0e885,
+ * access_grp_names=[Ljava.lang.Object;@4005f23d, free_sz=, size=}
+ */
+ public Boolean storagePluginMount() throws XmlRpcException {
+ Map<String, Object> x = (Map<String, Object>) callWrapper(
+ "storage_plugin_mount", this.pluginType, this.baseProps,
+ this.ssProps, this.mountPoint, this.unknown, this.active,
+ this.someList);
+ // System.out.println(x);
+ if (x == null) {
+ return true;
+ }
+ // System.out.println(x);
+ /*
+ * {ss_uuid=1b8685bf625642cb92ddd4c0d7b18620,
+ * mount_options=[Ljava.lang.Object;@6f479e5f, status=,
+ * name=nfs:/volumes/cs-data/secondary, state=1,
+ * access_path=cs-mgmt:/volumes/cs-data/secondary,
+ * uuid=54d78233-508f-4632-92a6-97fc1311ca23,
+ * access_grp_names=[Ljava.lang.Object;@46eea80c, free_sz=, size=}
+ */
+
+ /*
+ * if (!x.get("ss_uuid").equals(this.ssProps.get("ss_uuid"))) { return
+ * false; } this.ssProps.put("mount_options", x.get("mount_options"));
+ * this.ssProps.put("access_grp_names", x.get("access_grp_names"));
+ */
+ return false;
+ }
+
+ /**
+ * .
+ * storage_plugin_unmount, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ * @return boolean
+ * @throws XmlRpcException
+ */
+ public final Boolean storagePluginUnmount() throws XmlRpcException {
+ Object x = callWrapper("storage_plugin_unmount", this.pluginType,
+ this.baseProps, this.ssProps, this.mountPoint, this.active);
+ if (x == null) {
+ return true;
+ }
+
+ return false;
+ }
+
+ /*
+ * storage_plugin_resize, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_deviceSizeRefresh, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+ /*
+ * storage_plugin_getStorageNames, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_splitClone, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_destroyFileSystem, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_snapRestore, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_updateSERecords, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getSnapLimits, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * discover_storage_plugins, <class 'agent.api.storageplugin.StoragePlugin'>
+ */
+ /*
+ * <Discover_Storage_Plugins_Result> <storage_plugin_info_list>
+ * <storage_plugin_info plugin_impl_name="oracle.ocfs2.OCFS2.OCFS2Plugin">
+ * <fs_api_version>1,2,7</fs_api_version>
+ * <generic_plugin>False</generic_plugin>
+ * <plugin_version>0.1.0-38</plugin_version>
+ * <filesys_type>LocalFS</filesys_type>
+ * <extended_api_version>None</extended_api_version> <plugin_desc>Oracle
+ * OCFS2 File system Storage Connect Plugin</plugin_desc>
+ * <cluster_required>True</cluster_required> <plugin_name>Oracle OCFS2 File
+ * system</plugin_name> <fs_extra_info_help>None</fs_extra_info_help>
+ * <required_api_vers>1,2,7</required_api_vers>
+ * <file_extra_info_help>None</file_extra_info_help>
+ * <ss_extra_info_help>None</ss_extra_info_help>
+ * <filesys_name>ocfs2</filesys_name> <vendor_name>Oracle</vendor_name>
+ * <plugin_type>ifs</plugin_type> <abilities>
+ * <resize_is_sync>YES</resize_is_sync> <clone_is_sync>YES</clone_is_sync>
+ * <access_control>NO</access_control>
+ * <custom_clone_name>YES</custom_clone_name>
+ * <require_storage_name>NO</require_storage_name>
+ * <backing_device_type>DEVICE_SINGLE</backing_device_type>
+ * <splitclone_while_open>NO</splitclone_while_open>
+ * <custom_snap_name>YES</custom_snap_name> <snapshot>ONLINE</snapshot>
+ * <splitclone>UNSUPPORTED</splitclone> <snap_is_sync>YES</snap_is_sync>
+ * <snapclone>ONLINE</snapclone> <splitclone_is_sync>NO</splitclone_is_sync>
+ * <clone>ONLINE</clone> <resize>ONLINE</resize>
+ * <snapclone_is_sync>YES</snapclone_is_sync> </abilities>
+ * </storage_plugin_info> <storage_plugin_info
+ * plugin_impl_name="oracle.generic.SCSIPlugin.GenericPlugin"> ....
+ */
+ public Boolean discoverStoragePlugins()
+ throws ParserConfigurationException, IOException, Exception {
+ Object result = callWrapper("discover_storage_plugins");
+ // System.out.println(result);
+ Document xmlDocument = prepParse((String) result);
+ /* could be more subtle */
+ String path = "//Discover_Storage_Plugins_Result/storage_plugin_info_list";
+ /*
+ * Capabilities = xmlToMap(path+"/Capabilities", xmlDocument); VMM =
+ * xmlToMap(path+"/VMM", xmlDocument); NTP = xmlToMap(path+"/NTP",
+ * xmlDocument); Date_Time = xmlToMap(path+"/Date_Time", xmlDocument);
+ * Generic = xmlToMap(path, xmlDocument);
+ */
+ if (result != null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * storage_plugin_deviceResize, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getCloneLimits, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /* TODO: is used for files and dirs..., we only implement files for now...
+ * storage_plugin_destroy, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+ public Boolean storagePluginDestroy(String poolUuid, String file) throws XmlRpcException {
+ /* clean the props, the empty ones are checked, but not for content... */
+ // String uuid = this.deDash(poolUuid);
+ baseProps.put("uuid", "");
+ baseProps.put("access_host", "");
+ baseProps.put("storage_type", "FileSys");
+ ssProps.put("ss_uuid", "");
+ ssProps.put("access_path", "");
+ ssProps.put("uuid", poolUuid);
+ fileProps.put("fr_type", "File");
+ fileProps.put("fs_uuid", poolUuid);
+ fileProps.put("file_path", file);
+ fileProps.put("file_sz", "");
+ fileProps.put("ondisk_sz", "");
+ Object x = (HashMap<String, Object>) callWrapper(
+ "storage_plugin_destroy", this.pluginType, this.baseProps,
+ this.ssProps, this.fileProps);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean storagePluginDestroy() throws XmlRpcException {
+ /* clean the props */
+ Object x = (HashMap<String, Object>) callWrapper(
+ "storage_plugin_destroy", this.pluginType, this.baseProps,
+ this.ssProps, this.fileProps);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ /*
+ * storage_plugin_isSnapable, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getStorageServerInfo, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_removeFromAccessGroup, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_renameAccessGroup, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_stop, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_createMultiSnap, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getCurrentSnaps, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getFileInfo, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+ public Boolean storagePluginGetFileInfo() throws XmlRpcException {
+ fileProps = (HashMap<String, Object>)callWrapper("storage_plugin_getFileInfo",
+ this.pluginType, this.baseProps, this.fileProps);
+ if (fileProps == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean storagePluginGetFileInfo(String file) throws XmlRpcException {
+ fileProps.put("file_path", file);
+ fileProps = (HashMap<String, Object>)callWrapper("storage_plugin_getFileInfo",
+ this.pluginType,
+ this.ssProps,
+ this.baseProps,
+ this.fileProps);
+ if (fileProps == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean storagePluginGetFileInfo(String poolUuid, String host,
+ String file) throws XmlRpcException {
+ /* file path is the full path */
+ String uuid = this.deDash(poolUuid);
+ baseProps.put("uuid", poolUuid);
+ baseProps.put("access_host", host);
+ ssProps.put("access_path", "");
+ ssProps.put("uuid", uuid);
+ ssProps.put("state", 1);
+ ssProps.put("ss_uuid", poolUuid);
+ ssProps.put("name", "");
+ fileProps.put("file_path", file);
+ fileProps = (HashMap<String, Object>)callWrapper("storage_plugin_getFileInfo",
+ this.pluginType,
+ this.ssProps,
+ this.baseProps,
+ this.fileProps);
+ if (fileProps == null)
+ return true;
+
+ return false;
+ }
+
+ /* TODO: input checking of ss and base
+ /*
+ * storage_plugin_getFileSystemInfo, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ * requires a minumum of uuid, access_host, storage_type
+ * ss_uuid, access_path, uuid (the ss
+ */
+ public Boolean storagePluginGetFileSystemInfo(String propUuid,
+ String mntUuid, String nfsHost, String nfsPath)
+ throws XmlRpcException {
+ /* clean the props */
+ this.setUuid(propUuid);
+ this.setSsUuid(propUuid);
+ this.setMntUuid(mntUuid);
+ this.setFsHost(nfsHost);
+ this.setFsSourcePath(nfsHost + ":" + nfsPath);
+ this.setFsType("FileSys");
+ Map<String, Object> props = (HashMap<String, Object>) callWrapper(
+ "storage_plugin_getFileSystemInfo", this.pluginType,
+ this.baseProps, this.ssProps);
+ this.ssProps = props;
+ if (props == null)
+ return false;
+
+ return true;
+ }
+
+ /* TODO: double check base and ss ordering!!!! */
+ public Boolean storagePluginGetFileSystemInfo() throws XmlRpcException {
+ HashMap<String, Object> props = (HashMap<String, Object>) callWrapper(
+ "storage_plugin_getFileSystemInfo", this.pluginType,
+ this.baseProps, this.ssProps);
+ this.ssProps = props;
+ // System.out.println(props);
+ if (props == null)
+ return false;
+
+ return true;
+ }
+
+ /*
+ * storage_plugin_clone, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_list, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_getInfo, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_snapRemove, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getCapabilities, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_createSnap, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_getFileSystemSnapLimits, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_remove, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_getCurrentClones, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_online, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_isRestorable, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_iSCSI_logoutTarget, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: target - default: None
+ * argument: portal - default: None
+ */
+
+ /*
+ * storage_plugin_discover, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_start, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_removeAccessGroups, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_refresh, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_getAccessGroups, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_iSCSI_deletePortal, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: portal - default: None
+ */
+
+ /*
+ * storage_plugin_createFileSystem, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_cloneFromSnap, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_addToAccessGroup, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+
+ /*
+ * storage_plugin_offline, <class 'agent.api.storageplugin.StoragePlugin'>
+ * argument: impl_name - default: None
+ */
+
+ /*
+ * storage_plugin_listMountPoints, <class
+ * 'agent.api.storageplugin.StoragePlugin'> argument: impl_name - default:
+ * None
+ */
+ /* should really make that stuff a class as this is weird now... */
+ public Boolean storagePluginListMounts() throws XmlRpcException {
+ Object x = callWrapper("storage_plugin_listMountPoints",
+ this.pluginType, this.baseProps);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+
+ public Boolean storagePluginListMounts(String uuid) throws XmlRpcException {
+ /* should allow for putting in the uuid */
+ Object x = callWrapper("storage_plugin_listMountPoints",
+ this.pluginType, this.baseProps);
+ if (x == null)
+ return true;
+
+ return false;
+ }
+}