diff --git a/src/oca/java/lib/LICENSE.txt b/src/oca/java/lib/LICENSE.txt deleted file mode 100644 index d645695673..0000000000 --- a/src/oca/java/lib/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - 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. diff --git a/src/oca/java/lib/NOTICE.txt b/src/oca/java/lib/NOTICE.txt deleted file mode 100644 index 3a6553bd7f..0000000000 --- a/src/oca/java/lib/NOTICE.txt +++ /dev/null @@ -1,5 +0,0 @@ -Apache XML-RPC -Copyright 1999-2009 The Apache Software Foundation - -This product includes software developed at -The Apache Software Foundation (http://www.apache.org/). diff --git a/src/oca/java/lib/ws-commons-util-1.0.2.jar b/src/oca/java/lib/ws-commons-util-1.0.2.jar deleted file mode 100644 index 3fc364e7f6..0000000000 Binary files a/src/oca/java/lib/ws-commons-util-1.0.2.jar and /dev/null differ diff --git a/src/oca/java/lib/xmlrpc-client-3.1.2.jar b/src/oca/java/lib/xmlrpc-client-3.1.2.jar deleted file mode 100644 index 9c33bb4f92..0000000000 Binary files a/src/oca/java/lib/xmlrpc-client-3.1.2.jar and /dev/null differ diff --git a/src/oca/java/lib/xmlrpc-common-3.1.2.jar b/src/oca/java/lib/xmlrpc-common-3.1.2.jar deleted file mode 100644 index 707d1b3c5b..0000000000 Binary files a/src/oca/java/lib/xmlrpc-common-3.1.2.jar and /dev/null differ diff --git a/src/oca/java/test/AclTest.java b/src/oca/java/test/AclTest.java deleted file mode 100644 index 5fb4e978ac..0000000000 --- a/src/oca/java/test/AclTest.java +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.*; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.acl.*; - -public class AclTest -{ - - private static Acl acl; - private static AclPool aclPool; - - private static Client client; - - private static OneResponse res; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - aclPool = new AclPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - for(Acl rule : aclPool) - { - if( rule.id() > 4 ) - { - rule.delete(); - } - } - } - - @Test - public void defaultRules() - { - res = aclPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertEquals(5, aclPool.getLength()); - } -/* - @Test - public void hexAllocate() - { - // Allocate rule "#1 VM+HOST/@1 INFO+CREATE" - res = Acl.allocate(client, "0x100000001", "0x3200000001", "0x8"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - acl = aclPool.getById( res.getIntMessage() ); - - assertNotNull(acl); - - assertEquals(res.getIntMessage(), acl.id()); - assertEquals(0x100000001L, acl.user()); - assertEquals(0x3200000001L, acl.resource()); - assertEquals(0x8L, acl.rights()); - assertEquals("#1 VM+HOST/@1 CREATE",acl.toString()); - } -*/ -/* - @Test - public void numericAllocate() - { - // Allocate rule "#1 VM+HOST/@1 USE" - res = Acl.allocate(client, 0x100000001L, 214748364801L, 0x1L); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - acl = aclPool.getById( res.getIntMessage() ); - - assertNotNull(acl); - - assertEquals(res.getIntMessage(), acl.id()); - assertEquals(0x100000001L, acl.user()); - assertEquals(0x3200000001L, acl.resource()); - assertEquals(0x1L, acl.rights()); - assertEquals("#1 VM+HOST/@1 USE", acl.toString()); - } -*/ - @Test - public void ruleAllocate() - { - try - { - res = Acl.allocate(client, "@507 IMAGE/#456 MANAGE #102"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - acl = aclPool.getById( res.getIntMessage() ); - - assertNotNull(acl); - - assertEquals(res.getIntMessage(), acl.id()); - assertEquals(0x2000001fbL, acl.user()); - assertEquals(0x81000001c8L, acl.resource()); - assertEquals(0x2L, acl.rights()); - assertEquals("@507 IMAGE/#456 MANAGE #102", acl.toString()); - } - catch (RuleParseException e) - { - assertTrue( false ); - } - } - - @Test - public void parseRules() - { - String[] rules = { - "#3 TEMPLATE/#0 USE", - "#2 IMAGE/#0 USE", - "@107 IMAGE+TEMPLATE/@100 USE", - "* VM+IMAGE+TEMPLATE/@100 CREATE+USE", - "#2345 VM+IMAGE+TEMPLATE/* CREATE+USE", - "@7 HOST/#100 USE+MANAGE", - "* HOST+DATASTORE/%100 MANAGE+USE", - "@107 NET/%100 USE" - }; - - long[] users = { - 0x100000003L, - 0x100000002L, - 0x20000006bL, - 0x400000000L, - 0x100000929L, - 0x200000007L, - 0x400000000L, - 0x20000006bL - }; - - long[] resources = { - 0x20100000000L, - 0x8100000000L, - 0x28200000064L, - 0x29200000064L, - 0x29400000000L, - 0x2100000064L, - 0x102800000064L, - 0x4800000064L - }; - - long[] rights = { - 0x1L, - 0x1L, - 0x1L, - 0x9L, - 0x9L, - 0x3L, - 0x3L, - 0x1L - }; - - for( int i = 0; i < rules.length; i++ ) - { - try - { - res = Acl.allocate(client, rules[i]); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - acl = aclPool.getById( res.getIntMessage() ); - - assertNotNull(acl); - - assertEquals(res.getIntMessage(), acl.id()); - assertEquals(users[i], acl.user()); - assertEquals(resources[i], acl.resource()); - assertEquals(rights[i], acl.rights()); - } - catch (RuleParseException e) - { - assertTrue( - "Rule " + rules[i] - + " has been wrongly reported as invalid; " - + e.getMessage(), - false); - } - catch (AssertionError e) - { - assertTrue( - "Rule " + rules[i] - + " assert failure; " - + e.getMessage(), - false); - } - } - } - - @Test - public void delete() - { - try - { - res = Acl.allocate(client, "#1 HOST/#2 USE"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - assertEquals( 6, aclPool.getLength() ); - - res = Acl.delete(client, res.getIntMessage()); - assertTrue( res.getErrorMessage(), !res.isError() ); - - aclPool.info(); - assertEquals( 5, aclPool.getLength() ); - } - catch (RuleParseException e) - { - assertTrue( - "Rule has been wrongly reported as invalid; " - + e.getMessage(), - false); - } - } - - @Test - public void wrongRules() - { - String[] rules = { - "#-3 TEMPLATE/#0 USE", - "#+3 TEMPLATE/#0 USE", - "@3+ TEMPLATE/#0 USE", - "*3 TEMPLATE/#0 USE", - "# TEMPLATE/#0 USE", - "@@ TEMPLATE/#0 USE", - "@#3 TEMPLATE/#0 USE", - "#3 TEMPLATE+HOS/#0 USE", - "#3 /#0 USE", - "#3 TEMPLATE/# USE", - "#3 TEMPLATE/% USE", - "#3 TEMPLATE/#5 USE CREATE", - "#3 TEMPLATE/#5", - "#3 ", - "", - "#2 IMAGE @10654 USE", - "#2 IMAGE/ USE", - "#2 IMAGE#0 USE", - "#2 IMAGE/# USE", - "#2 IMAGE/@- USE", - "#2 IMAGE/#0/#0 USE", - "#2 IMAGE/#0/USE CREATE", - "#2 IMAGE/#0/USE+CREATE", - "#2 IMAGE/#0 IFO", - "#2 IMAGE/#0 USE+CREAT", - }; - - for( int i = 0; i < rules.length; i++ ) - { - try - { - res = Acl.allocate(client, rules[i]); - - assertTrue( "Rule " + rules[i] + - " should have thrown an exception", - false); - } - catch (RuleParseException e) - { - } - } - } -} diff --git a/src/oca/java/test/DocumentTest.java b/src/oca/java/test/DocumentTest.java deleted file mode 100644 index 16e27a1140..0000000000 --- a/src/oca/java/test/DocumentTest.java +++ /dev/null @@ -1,163 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; - - -public class DocumentTest -{ - private static GenericObjA objA; - private static GenericObjB objB; - private static GenericObjAPool objAPool; - private static GenericObjBPool objBPool; - - private static Client client; - - private static OneResponse res; - - private static String nameA = "obj_one"; - private static String nameB = "obj_two"; - - private static String template_one = - "NAME = \"" + nameA + "\"\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - private static String template_two = - "NAME = \"" + nameB + "\"\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - objAPool = new GenericObjAPool(client); - objBPool = new GenericObjBPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = GenericObjA.allocate(client, template_one); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oidA = Integer.parseInt(res.getMessage()); - objA = new GenericObjA(oidA, client); - - res = GenericObjB.allocate(client, template_two); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oidB = Integer.parseInt(res.getMessage()); - objB = new GenericObjB(oidB, client); - - res = objA.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = objB.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - objA.delete(); - objB.delete(); - } - - @Test - public void sameOidSpace() - { - assertTrue( - "objA id : " + objA.getId() + "; objB id : " + objB.getId(), - objB.id() == objA.id()+1 ); - } - - @Test - public void differentPools() - { - res = objAPool.infoAll(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean foundA = false; - boolean foundB = false; - - for(GenericObjA ob : objAPool) - { - foundA = foundA || ob.getName().equals(nameA); - foundB = foundB || ob.getName().equals(nameB); - } - - assertTrue( foundA ); - assertTrue( !foundB ); - - - - res = objBPool.infoMine(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - foundA = false; - foundB = false; - - for(GenericObjB ob : objBPool) - { - foundA = foundA || ob.getName().equals(nameA); - foundB = foundB || ob.getName().equals(nameB); - } - - assertTrue( !foundA ); - assertTrue( foundB ); - } - - @Test - public void lock() - { - res = objA.lock("doctest"); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( res.getMessage(), res.getBooleanMessage() == true ); - - res = objA.lock("doctest"); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( res.getMessage(), res.getBooleanMessage() == false ); - - res = objA.unlock("doctest"); - assertTrue( res.getErrorMessage(), !res.isError() ); - } -} diff --git a/src/oca/java/test/GenericObjA.java b/src/oca/java/test/GenericObjA.java deleted file mode 100644 index b75bbebd57..0000000000 --- a/src/oca/java/test/GenericObjA.java +++ /dev/null @@ -1,25 +0,0 @@ -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.document.Document; -import org.w3c.dom.Node; - -public class GenericObjA extends Document -{ - private static final int TYPE = 200; - - public GenericObjA(int id, Client client) - { - super(id, client); - } - - public GenericObjA(Node xmlElement, Client client) - { - super(xmlElement, client); - } - - - public static OneResponse allocate(Client client, String description) - { - return Document.allocate(client, description, TYPE); - } -} \ No newline at end of file diff --git a/src/oca/java/test/GenericObjAPool.java b/src/oca/java/test/GenericObjAPool.java deleted file mode 100644 index fe63f198a5..0000000000 --- a/src/oca/java/test/GenericObjAPool.java +++ /dev/null @@ -1,53 +0,0 @@ -import java.util.AbstractList; -import java.util.Iterator; - -import org.opennebula.client.Client; -import org.opennebula.client.document.DocumentPool; -import org.w3c.dom.Node; - - -public class GenericObjAPool extends DocumentPool implements Iterable -{ - private static final int TYPE = 200; - - @Override - protected int type() - { - return TYPE; - } - - public GenericObjAPool(Client client) - { - super(client); - } - - public GenericObjAPool(Client client, int filter) - { - super(client, filter); - } - - @Override - public GenericObjA factory(Node node) - { - return new GenericObjA(node, client); - } - - @Override - public Iterator iterator() - { - AbstractList ab = new AbstractList() - { - public int size() - { - return getLength(); - } - - public GenericObjA get(int index) - { - return (GenericObjA) item(index); - } - }; - - return ab.iterator(); - } -} diff --git a/src/oca/java/test/GenericObjB.java b/src/oca/java/test/GenericObjB.java deleted file mode 100644 index 41c6e799ed..0000000000 --- a/src/oca/java/test/GenericObjB.java +++ /dev/null @@ -1,25 +0,0 @@ -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.document.Document; -import org.w3c.dom.Node; - -public class GenericObjB extends Document -{ - private static final int TYPE = 201; - - public GenericObjB(int id, Client client) - { - super(id, client); - } - - public GenericObjB(Node xmlElement, Client client) - { - super(xmlElement, client); - } - - - public static OneResponse allocate(Client client, String description) - { - return Document.allocate(client, description, TYPE); - } -} \ No newline at end of file diff --git a/src/oca/java/test/GenericObjBPool.java b/src/oca/java/test/GenericObjBPool.java deleted file mode 100644 index 04025070e3..0000000000 --- a/src/oca/java/test/GenericObjBPool.java +++ /dev/null @@ -1,53 +0,0 @@ -import java.util.AbstractList; -import java.util.Iterator; - -import org.opennebula.client.Client; -import org.opennebula.client.document.DocumentPool; -import org.w3c.dom.Node; - - -public class GenericObjBPool extends DocumentPool implements Iterable -{ - private static final int TYPE = 201; - - @Override - protected int type() - { - return TYPE; - } - - public GenericObjBPool(Client client) - { - super(client); - } - - public GenericObjBPool(Client client, int filter) - { - super(client, filter); - } - - @Override - public GenericObjB factory(Node node) - { - return new GenericObjB(node, client); - } - - @Override - public Iterator iterator() - { - AbstractList ab = new AbstractList() - { - public int size() - { - return getLength(); - } - - public GenericObjB get(int index) - { - return (GenericObjB) item(index); - } - }; - - return ab.iterator(); - } -} diff --git a/src/oca/java/test/GroupTest.java b/src/oca/java/test/GroupTest.java deleted file mode 100644 index 8fe138e4c0..0000000000 --- a/src/oca/java/test/GroupTest.java +++ /dev/null @@ -1,306 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.*; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.OneSystem; -import org.opennebula.client.group.Group; -import org.opennebula.client.group.GroupPool; -import org.opennebula.client.user.*; -import org.w3c.dom.Node; -import java.util.Hashtable; - -public class GroupTest -{ - - private static Group group; - private static GroupPool groupPool; - private static User user; - - private static Client client; - - private static OneResponse res; - - private static String group_name = "test_group"; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - groupPool = new GroupPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = Group.allocate(client, group_name); - - assertTrue( res.getErrorMessage(), !res.isError() ); - - int group_id = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - group = new Group(group_id, client); - - res = User.allocate(client, "new_test_user", "new_test_password"); - - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - user = new User(uid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - user.delete(); - group.delete(); - } - - @Test - public void allocate() - { - group.delete(); - - res = Group.allocate(client, group_name); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int group_id = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - group = new Group(group_id, client); - - - groupPool.info(); - - boolean found = false; - for(Group img : groupPool) - { - found = found || img.getName().equals(group_name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = group.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( group.id() >= 100 ); - assertTrue( group.getName().equals(group_name) ); - } - - @Test - public void delete() - { - res = group.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = group.info(); - assertTrue( res.isError() ); - - res = groupPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(Group g : groupPool) - { - found = found || g.getName().equals(group_name); - } - - assertTrue( !found ); - } - - @Test - public void defaultqutoas() - { - OneSystem system = new OneSystem(client); - - res = system.getGroupQuotas(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = system.setGroupQuotas("VM = [ VMS = 7, MEMORY = 0, CPU = 3, SYSTEM_DISK_SIZE = 1 ]"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - Node node = system.getGroupQuotasXML(); - XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); - - try - { - assertTrue( xpath.evaluate("VM_QUOTA/VM/VMS", node).equals("7") ); - } catch (XPathExpressionException e) - { - assertTrue(e.getMessage(), false); - } - } - - @Test - public void addAdmin() - { - res = group.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertFalse( group.contains(user.id()) ); - assertFalse( group.containsAdmin(user.id()) ); - - res = group.addAdmin( user.id() ); - assertTrue( res.isError() ); - - group.info(); - assertFalse( group.contains(user.id()) ); - assertFalse( group.containsAdmin(user.id()) ); - - res = user.chgrp( group.id() ); - assertTrue( res.getErrorMessage(), !res.isError() ); - - group.info(); - assertTrue( group.contains(user.id()) ); - assertFalse( group.containsAdmin(user.id()) ); - - res = group.addAdmin( user.id() ); - assertTrue( res.getErrorMessage(), !res.isError() ); - - group.info(); - assertTrue( group.contains(user.id()) ); - assertTrue( group.containsAdmin(user.id()) ); - } - - - @Test - public void delAdmin() - { - res = group.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = group.delAdmin( user.id() ); - assertTrue( res.isError() ); - - res = user.chgrp( group.id() ); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = group.delAdmin( user.id() ); - assertTrue( res.isError() ); - - res = group.addAdmin( user.id() ); - assertTrue( res.getErrorMessage(), !res.isError() ); - - group.info(); - assertTrue( group.contains(user.id()) ); - assertTrue( group.containsAdmin(user.id()) ); - - res = group.delAdmin( user.id() ); - assertTrue( res.getErrorMessage(), !res.isError() ); - - group.info(); - assertTrue( group.contains(user.id()) ); - assertFalse( group.containsAdmin(user.id()) ); - } - - @Test - public void userGroupRelations() - { - Hashtable users = new Hashtable(); - Hashtable groups = new Hashtable(); - - // Create all users and groups. Add user_* to corresponding group_* - String[] names = {"a", "b", "c", "d"}; - for(String name : names) - { - res = User.allocate(client, "user_"+name, "password"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - users.put( name, - new User(Integer.parseInt(res.getMessage()), client ) - ); - - res = Group.allocate(client, "group_"+name); - assertTrue( res.getErrorMessage(), !res.isError() ); - - groups.put( name, - new Group(Integer.parseInt(res.getMessage()), client ) - ); - - users.get(name).addgroup( groups.get(name).id() ); - } - - // Add all users to group_b - for( User u : users.values() ) - { - u.addgroup( groups.get("b").id() ); - } - - // Change user_c & _d main group - users.get("c").chgrp( groups.get("d").id() ); - users.get("d").chgrp( groups.get("c").id() ); - - - // Check cross-references so far - for( User u : users.values() ) - { - assertTrue( !u.info().isError() ); - } - - for( Group g : groups.values() ) - { - assertTrue( !g.info().isError() ); - } - - assertTrue( groups.get("a").contains( users.get("a").id() ) ); - assertFalse( groups.get("a").contains( users.get("b").id() ) ); - assertFalse( groups.get("a").contains( users.get("c").id() ) ); - assertFalse( groups.get("a").contains( users.get("d").id() ) ); - - assertTrue( groups.get("b").contains( users.get("a").id() ) ); - assertTrue( groups.get("b").contains( users.get("b").id() ) ); - assertTrue( groups.get("b").contains( users.get("c").id() ) ); - assertTrue( groups.get("b").contains( users.get("d").id() ) ); - - assertFalse( groups.get("c").contains( users.get("a").id() ) ); - assertFalse( groups.get("c").contains( users.get("b").id() ) ); - assertTrue( groups.get("c").contains( users.get("c").id() ) ); - assertTrue( groups.get("c").contains( users.get("d").id() ) ); - assertFalse( groups.get("d").contains( users.get("a").id() ) ); - assertFalse( groups.get("d").contains( users.get("b").id() ) ); - assertTrue( groups.get("d").contains( users.get("c").id() ) ); - assertTrue( groups.get("d").contains( users.get("d").id() ) ); - } -} diff --git a/src/oca/java/test/HostTest.java b/src/oca/java/test/HostTest.java deleted file mode 100644 index 4e6b875191..0000000000 --- a/src/oca/java/test/HostTest.java +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.host.Host; -import org.opennebula.client.host.HostPool; -import org.w3c.dom.Node; - -public class HostTest -{ - class HostXML extends Host - { - public HostXML(Node node, Client client){ super(node, client); } - } - - private static Host host; - private static HostPool hostPool; - private static Client client; - private OneResponse res; - private static String name = "new_test_host"; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - hostPool = new HostPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = Host.allocate(client, name, "dummy", "dummy"); - - int hid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1; - host = new Host(hid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - host.delete(); - Thread.sleep(2000); - } - - @Test - public void allocate() - { - String name = "allocate_test"; - - res = Host.allocate(client, name, "im_dummy", "vmm_dummy"); - assertTrue( res.getErrorMessage(), !res.isError() ); -// assertTrue( res.getMessage().equals("0") ); - - hostPool.info(); - - boolean found = false; - for(Host h : hostPool) - { - found = found || h.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = host.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( host.getId().equals("0") ); - assertTrue( host.id() >= 0 ); - -// assertTrue( host.shortStateStr().equals("on") ); - } - - @Test - public void enable() - { - res = host.enable(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - host.info(); - assertTrue( host.isEnabled() ); - } - - @Test - public void disable() - { - res = host.disable(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - host.info(); - assertTrue( !host.isEnabled() ); - } - - @Test - public void delete() - { - String name = host.getName(); - - res = host.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = host.info(); - assertTrue( res.isError() ); - - res = hostPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(Host h : hostPool) - { - found = found || h.getName().equals(name); - } - - assertTrue( !found ); - } - - @Test - public void update() - { - res = host.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( host.xpath("TEMPLATE/ATT2").equals( "" ) ); - - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = host.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = host.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( host.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( host.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( host.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - -/* - @Test - public void attributes() - { - DocumentBuilder builder; - Document doc; - Element xml; - - try - { - builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); - - doc = builder.parse( new File("./fixtures/host.xml") ); - xml = doc.getDocumentElement(); - - host = new HostXML(xml, client); - - assertTrue( host.xpath("ID").equals("7") ); - assertTrue( host.xpath("NAME").equals("dummyhost") ); - assertTrue( host.xpath("STATE").equals("2") ); - assertTrue( host.xpath("IM_MAD").equals("im_dummy") ); - assertTrue( host.xpath("LAST_MON_TIME").equals("1277733596") ); - assertTrue( host.xpath("HOST_SHARE/MEM_USAGE").equals("1572864") ); - assertTrue( host.xpath("HOST_SHARE/CPU_USAGE").equals("300") ); - assertTrue( host.xpath("HOST_SHARE/FREE_CPU").equals("800") ); - assertTrue( host.xpath("HOST_SHARE/RUNNING_VMS").equals("3") ); - assertTrue( host.xpath("TEMPLATE/CPUSPEED").equals("2.2GHz") ); - assertTrue( host.xpath("TEMPLATE/HYPERVISOR").equals("dummy") ); - assertTrue( host.xpath("TEMPLATE/TOTALMEMORY").equals("16777216") ); - - } catch (Exception e) - { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } -*/ -} diff --git a/src/oca/java/test/ImageTest.java b/src/oca/java/test/ImageTest.java deleted file mode 100644 index ee987af35b..0000000000 --- a/src/oca/java/test/ImageTest.java +++ /dev/null @@ -1,260 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.image.*; - - - -public class ImageTest -{ - - private static Image image; - private static ImagePool imagePool; - - private static Client client; - - private static OneResponse res; - private static int cont = 0; - - private static String template() - { - cont++; - - return "NAME = \"test_img_" + cont + "\"\n" + - "PATH = /etc/hosts\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - } - - /** - * Wait until the Image changes to the specified state. - * There is a time-out of 10 seconds. - */ - static void waitAssert(Image img, String state) - { - int n_steps = 10; - int step = 1000; - - int i = 0; - - img.info(); - - while( !( img.stateString().equals(state) || i > n_steps ) - && !img.stateString().equals("ERROR") ) - { - try{ Thread.sleep(step); } catch (Exception e){} - - img.info(); - i++; - } - - assertTrue( - "Image timeout, wanted state: " + state + "; it is in state " - + img.stateString(), img.stateString().equals(state) ); - } - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - imagePool = new ImagePool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = Image.allocate(client, template(), 1); - - int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - image = new Image(imgid, client); - - waitAssert(image, "READY"); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - image.delete(); - } - - @Test - public void allocate() - { - image.delete(); - - res = Image.allocate(client, template(), 1); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - image = new Image(imgid, client); - - - res = imagePool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(Image img : imagePool) - { - found = found || img.getName().equals("test_img_"+cont); - } - - assertTrue( found ); - } - - @Test - public void clone_method() - { - res = image.clone("cloned_image"); - assertTrue(res.getErrorMessage(), !res.isError()); - - int imgid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - Image cloned_image = new Image(imgid, client); - - res = imagePool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(Image img : imagePool) - { - found = found || img.getName().equals("cloned_image"); - } - - assertTrue( found ); - - res = cloned_image.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( cloned_image.getName().equals("cloned_image") ); - } - - @Test - public void info() - { - res = image.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( image.getId().equals("0") ); -// assertTrue( image.id() == 0 ); - assertTrue( image.getName().equals("test_img_"+cont) ); - } - - @Test - public void update() - { - res = image.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( image.xpath("TEMPLATE/ATT1").equals( "VAL1" ) ); - assertTrue( image.xpath("TEMPLATE/ATT2").equals( "VAL2" ) ); - - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = image.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = image.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( image.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( image.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( image.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void enable() - { - res = image.enable(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - image.info(); - assertTrue( image.isEnabled() ); - } - - @Test - public void disable() - { - res = image.disable(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - image.info(); - assertTrue( res.getErrorMessage(), !image.isEnabled() ); - } - - @Test - public void publish() - { - res = image.publish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - image.info(); - assertTrue( image.xpath("PERMISSIONS/GROUP_U").equals( "1" ) ); - } - - @Test - public void unpublish() - { - res = image.unpublish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - image.info(); - assertTrue( image.xpath("PERMISSIONS/GROUP_U").equals( "0" ) ); - } - - @Test - public void attributes() - { - res = image.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( image.xpath("ID").equals("0") ); - assertTrue( image.xpath("NAME").equals("test_img_"+cont) ); - } - - @Test - public void delete() - { - res = image.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// res = image.info(); -// assertTrue( res.isError() ); - } -} diff --git a/src/oca/java/test/SecurityGroupTest.java b/src/oca/java/test/SecurityGroupTest.java deleted file mode 100644 index a57019a8d7..0000000000 --- a/src/oca/java/test/SecurityGroupTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.group.Group; -import org.opennebula.client.secgroup.*; -import org.opennebula.client.user.User; - - - - -public class SecurityGroupTest -{ - - private static SecurityGroup sg; - private static SecurityGroupPool pool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_sg"; - - - private static String template_str = - "NAME = \"" + name + "\"\n" + - "DESCRIPTION = \"test security group\"\n"+ - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - pool = new SecurityGroupPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = SecurityGroup.allocate(client, template_str); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - sg = new SecurityGroup(oid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - sg.delete(); - } - - @Test - public void allocate() - { - sg.delete(); - - res = SecurityGroup.allocate(client, template_str); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - sg = new SecurityGroup(oid, client); - - - pool.info(); - - boolean found = false; - for(SecurityGroup temp : pool) - { - found = found || temp.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.getName().equals(name) ); - } - - @Test - public void update() - { - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.xpath("TEMPLATE/ATT1").equals( "VAL1" ) ); - assertTrue( sg.xpath("TEMPLATE/ATT2").equals( "VAL2" ) ); - - String new_sg = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = sg.update(new_sg); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( sg.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( sg.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( sg.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void chmod() - { - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - String owner_a = sg.xpath("PERMISSIONS/OWNER_A"); - String group_a = sg.xpath("PERMISSIONS/GROUP_A"); - - res = sg.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_A").equals(owner_a) ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_A").equals(group_a) ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_A").equals("0") ); - } - - @Test - public void chmod_octet() - { - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.chmod(640); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.xpath("PERMISSIONS/OWNER_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_A").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_U").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_M").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_A").equals("0") ); - - res = sg.chmod("147"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_M").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OWNER_A").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( sg.xpath("PERMISSIONS/OTHER_A").equals("1") ); - } - - @Test - public void attributes() - { - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( sg.xpath("ID").equals("0") ); - assertTrue( sg.xpath("NAME").equals(name) ); - } - - @Test - public void delete() - { - res = sg.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.info(); - assertTrue( res.isError() ); - } - - @Test - public void chown() - { - // Create a new User and Group - res = User.allocate(client, "sg_test_user", "password"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - - res = Group.allocate(client, "sg_test_group"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int gid = Integer.parseInt(res.getMessage()); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.uid() == 0 ); - assertTrue( sg.gid() == 0 ); - - res = sg.chown(uid, gid); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.uid() == uid ); - assertTrue( sg.gid() == gid ); - - res = sg.chgrp(0); - - res = sg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( sg.uid() == uid ); - assertTrue( sg.gid() == 0 ); - } -} diff --git a/src/oca/java/test/SessionTest.java b/src/oca/java/test/SessionTest.java deleted file mode 100644 index 03a392dadd..0000000000 --- a/src/oca/java/test/SessionTest.java +++ /dev/null @@ -1,87 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.*; - -import org.junit.Test; -import org.opennebula.client.*; -import org.w3c.dom.Node; - -public class SessionTest { - - @Test - public void createSession() - { - Client oneClient = null; - try - { - oneClient = new Client(); - } - catch (Exception e) - { - System.out.println(e.getMessage()); - } - - assertNotNull(oneClient); - } - - @Test - public void wrong_url() - { - Client oneClient = null; - try - { - // The HTTP is misspelled - oneClient = new Client(null,"HTP://localhost:2633/RPC2"); - } - catch (Exception e) - { -// System.out.println(e.getMessage()); - } - - assertNull("Client should complain about misspelled url", oneClient); - } - - @Test - public void version() - { - Client oneClient = null; - try - { - oneClient = new Client(); - } - catch (Exception e) - { - assertTrue( e.getMessage(), false ); - } - - OneSystem system = new OneSystem(oneClient); - - OneResponse res = system.getOnedVersion(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = system.getConfiguration(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - Node config = system.getConfigurationXML(); - assertTrue( "XML configuration is null", config != null ); - - boolean compatible = system.compatibleVersion(); - assertTrue( - "Incompatible version reported, " + - OneSystem.VERSION + ", " + system.getOnedVersion().getMessage(), - compatible ); - } -} diff --git a/src/oca/java/test/TemplateTest.java b/src/oca/java/test/TemplateTest.java deleted file mode 100644 index 397509cf8d..0000000000 --- a/src/oca/java/test/TemplateTest.java +++ /dev/null @@ -1,304 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.group.Group; -import org.opennebula.client.template.*; -import org.opennebula.client.user.User; -import org.opennebula.client.vm.VirtualMachine; - - - -public class TemplateTest -{ - - private static Template template; - private static TemplatePool templatePool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_template"; - - - private static String template_str = - "NAME = \"" + name + "\"\n" + - "CPU = \"1\"\n" + - "MEMORY = \"128\"\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - templatePool = new TemplatePool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = Template.allocate(client, template_str); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - template = new Template(oid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - template.delete(); - } - - @Test - public void allocate() - { - template.delete(); - - res = Template.allocate(client, template_str); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - template = new Template(oid, client); - - - templatePool.info(); - - boolean found = false; - for(Template temp : templatePool) - { - found = found || temp.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( template.getId().equals("0") ); -// assertTrue( template.id() == 0 ); - assertTrue( template.getName().equals(name) ); - } - - @Test - public void update() - { - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.xpath("TEMPLATE/ATT1").equals( "VAL1" ) ); - assertTrue( template.xpath("TEMPLATE/ATT2").equals( "VAL2" ) ); - - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = template.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( template.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( template.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( template.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void publish() - { - res = template.publish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - template.info(); - assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); - } - - @Test - public void unpublish() - { - res = template.unpublish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - template.info(); - assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("0") ); - } - - @Test - public void chmod() - { - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - String owner_a = template.xpath("PERMISSIONS/OWNER_A"); - String group_a = template.xpath("PERMISSIONS/GROUP_A"); - - res = template.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals(owner_a) ); - assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals(group_a) ); - assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") ); - } - - @Test - public void chmod_octet() - { - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.chmod(640); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("0") ); - - res = template.chmod("147"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_M").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OWNER_A").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( template.xpath("PERMISSIONS/OTHER_A").equals("1") ); - } - - @Test - public void attributes() - { - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( template.xpath("ID").equals("0") ); - assertTrue( template.xpath("NAME").equals(name) ); - } - - @Test - public void delete() - { - res = template.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.info(); - assertTrue( res.isError() ); - } - - @Test - public void chown() - { - // Create a new User and Group - res = User.allocate(client, "template_test_user", "password"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - - res = Group.allocate(client, "template_test_group"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int gid = Integer.parseInt(res.getMessage()); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.uid() == 0 ); - assertTrue( template.gid() == 0 ); - - res = template.chown(uid, gid); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.uid() == uid ); - assertTrue( template.gid() == gid ); - - res = template.chgrp(0); - - res = template.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( template.uid() == uid ); - assertTrue( template.gid() == 0 ); - } - - @Test - public void instantiate() - { - res = template.instantiate("new_vm_name"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int vm_id = Integer.parseInt(res.getMessage()); - VirtualMachine vm = new VirtualMachine(vm_id, client); - - res = vm.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vm.getName().equals( "new_vm_name" ) ); - } -} diff --git a/src/oca/java/test/UserTest.java b/src/oca/java/test/UserTest.java deleted file mode 100644 index 36b76b95c4..0000000000 --- a/src/oca/java/test/UserTest.java +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.*; - -import javax.xml.xpath.XPath; -import javax.xml.xpath.XPathExpressionException; -import javax.xml.xpath.XPathFactory; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.OneSystem; -import org.opennebula.client.user.User; -import org.opennebula.client.user.UserPool; -import org.opennebula.client.group.Group; -import org.w3c.dom.Node; - -public class UserTest -{ - - private static User user; - private static UserPool userPool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_user"; - private static String password = "new_test_password"; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - userPool = new UserPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = User.allocate(client, name, password); - - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - user = new User(uid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - user.delete(); - } - - - @Test - public void allocate() - { - userPool.info(); - - boolean found = false; - for(User u : userPool) - { - found = found || u.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void allocateInGroup() - { - user.delete(); - - res = Group.allocate(client, "group_a"); - assertTrue( res.getErrorMessage(), !res.isError() ); - int group_a_id = Integer.parseInt(res.getMessage()); - Group group_a = new Group(group_a_id, client); - - res = Group.allocate(client, "group_b"); - assertTrue( res.getErrorMessage(), !res.isError() ); - int group_b_id = Integer.parseInt(res.getMessage()); - Group group_b = new Group(group_b_id, client); - - res = Group.allocate(client, "group_c"); - assertTrue( res.getErrorMessage(), !res.isError() ); - int group_c_id = Integer.parseInt(res.getMessage()); - Group group_c = new Group(group_c_id, client); - - Integer[] gids = {group_b_id, group_a_id}; - res = User.allocate(client, "test_user_in_group", "pass", "", gids); - - assertTrue( res.getErrorMessage(), !res.isError() ); - - user = new User(Integer.parseInt(res.getMessage()), client); - - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( user.gid() == group_b_id ); - - group_a.info(); - group_b.info(); - group_c.info(); - - assertTrue( group_a.contains(user.id()) ); - assertTrue( group_b.contains(user.id()) ); - assertFalse( group_c.contains(user.id()) ); - } - - @Test - public void info() - { - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( user.id() >= 0 ); - assertTrue( user.getName().equals(name) ); - } - - @Test - public void attributes() - { - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( user.xpath("NAME").equals(name) ); - assertTrue( user.xpath("ENABLED").equals("1") ); - } - - @Test - public void chauth() - { - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( user.xpath("AUTH_DRIVER").equals("core") ); - - res = user.chauth("new_driver", password); - - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( user.xpath("AUTH_DRIVER").equals("new_driver") ); - } - - @Test - public void update() - { - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = user.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( user.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( user.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( user.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void delete() - { - res = user.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( user.isEnabled() ); - - res = user.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = user.info(); - assertTrue( res.getErrorMessage(), res.isError() ); - } - - @Test - public void defaultqutoas() - { - OneSystem system = new OneSystem(client); - - res = system.getUserQuotas(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = system.setUserQuotas("VM = [ VMS = 7, MEMORY = 0, CPU = 3, SYSTEM_DISK_SIZE = 1 ]"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - Node node = system.getUserQuotasXML(); - XPathFactory factory = XPathFactory.newInstance(); - XPath xpath = factory.newXPath(); - - try - { - assertTrue( xpath.evaluate("VM_QUOTA/VM/VMS", node).equals("7") ); - } catch (XPathExpressionException e) - { - assertTrue(e.getMessage(), false); - } - } -} diff --git a/src/oca/java/test/VMGroupTest.java b/src/oca/java/test/VMGroupTest.java deleted file mode 100644 index b3c6c140fe..0000000000 --- a/src/oca/java/test/VMGroupTest.java +++ /dev/null @@ -1,266 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.group.Group; -import org.opennebula.client.vmgroup.*; -import org.opennebula.client.user.User; - - - - -public class VMGroupTest -{ - - private static VMGroup vmg; - private static VMGroupPool pool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_vmg"; - - - private static String template_str = - "NAME = \"" + name + "\"\n" + - "DESCRIPTION = \"test vmgroup\"\n"+ - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - pool = new VMGroupPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = VMGroup.allocate(client, template_str); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vmg = new VMGroup(oid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - vmg.delete(); - } - - @Test - public void allocate() - { - vmg.delete(); - - res = VMGroup.allocate(client, template_str); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vmg = new VMGroup(oid, client); - - - pool.info(); - - boolean found = false; - for(VMGroup temp : pool) - { - found = found || temp.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.getName().equals(name) ); - } - - @Test - public void update() - { - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.xpath("TEMPLATE/ATT1").equals( "VAL1" ) ); - assertTrue( vmg.xpath("TEMPLATE/ATT2").equals( "VAL2" ) ); - - String new_vmg = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = vmg.update(new_vmg); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( vmg.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( vmg.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( vmg.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void chmod() - { - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - String owner_a = vmg.xpath("PERMISSIONS/OWNER_A"); - String group_a = vmg.xpath("PERMISSIONS/GROUP_A"); - - res = vmg.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_A").equals(owner_a) ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_A").equals(group_a) ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_A").equals("0") ); - } - - @Test - public void chmod_octet() - { - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.chmod(640); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.xpath("PERMISSIONS/OWNER_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_A").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_U").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_M").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_A").equals("0") ); - - res = vmg.chmod("147"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_M").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OWNER_A").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( vmg.xpath("PERMISSIONS/OTHER_A").equals("1") ); - } - - @Test - public void attributes() - { - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( vmg.xpath("ID").equals("0") ); - assertTrue( vmg.xpath("NAME").equals(name) ); - } - - @Test - public void delete() - { - res = vmg.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.info(); - assertTrue( res.isError() ); - } - - @Test - public void chown() - { - // Create a new User and Group - res = User.allocate(client, "vmg_test_user", "password"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - - res = Group.allocate(client, "vmg_test_group"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int gid = Integer.parseInt(res.getMessage()); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.uid() == 0 ); - assertTrue( vmg.gid() == 0 ); - - res = vmg.chown(uid, gid); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.uid() == uid ); - assertTrue( vmg.gid() == gid ); - - res = vmg.chgrp(0); - - res = vmg.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmg.uid() == uid ); - assertTrue( vmg.gid() == 0 ); - } -} diff --git a/src/oca/java/test/VdcTest.java b/src/oca/java/test/VdcTest.java deleted file mode 100644 index 284e5473c9..0000000000 --- a/src/oca/java/test/VdcTest.java +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.vdc.*; -import org.opennebula.client.group.*; -import org.opennebula.client.cluster.*; - - -public class VdcTest -{ - - private static Vdc vdc; - private static VdcPool vdcPool; - - private static Client client; - - private static OneResponse res; - private static int cont = 0; - - private static String template() - { - cont++; - - return "NAME = \"test_vdc_" + cont + "\"\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - } - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - vdcPool = new VdcPool(client); - - Group.allocate(client, "testgroup"); - Cluster.allocate(client, "testcluster"); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = Vdc.allocate(client, template()); - - int vdcid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vdc = new Vdc(vdcid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - vdc.delete(); - } - - @Test - public void allocate() - { - vdc.delete(); - - res = Vdc.allocate(client, template()); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int vdcid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vdc = new Vdc(vdcid, client); - - - res = vdcPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(Vdc vdc : vdcPool) - { - found = found || vdc.getName().equals("test_vdc_"+cont); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( vdc.getId().equals("0") ); -// assertTrue( vdc.id() == 0 ); - assertTrue( vdc.getName().equals("test_vdc_"+cont) ); - } - - @Test - public void update() - { - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vdc.xpath("TEMPLATE/ATT1").equals( "VAL1" ) ); - assertTrue( vdc.xpath("TEMPLATE/ATT2").equals( "VAL2" ) ); - - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = vdc.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( vdc.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( vdc.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( vdc.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - @Test - public void attributes() - { - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// assertTrue( vdc.xpath("ID").equals("0") ); - assertTrue( vdc.xpath("NAME").equals("test_vdc_"+cont) ); - } - - @Test - public void addGroup() - { - res = vdc.addGroup(100); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vdc.xpath("GROUPS/ID").equals("100") ); - } - - @Test - public void addCluster() - { - res = vdc.addCluster(0, 100); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vdc.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vdc.xpath("CLUSTERS/CLUSTER/ZONE_ID").equals("0") ); - assertTrue( vdc.xpath("CLUSTERS/CLUSTER/CLUSTER_ID").equals("100") ); - } - - @Test - public void delete() - { - res = vdc.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - -// res = vdc.info(); -// assertTrue( res.isError() ); - } -} diff --git a/src/oca/java/test/VirtualMachineTest.java b/src/oca/java/test/VirtualMachineTest.java deleted file mode 100644 index 17d63d4a39..0000000000 --- a/src/oca/java/test/VirtualMachineTest.java +++ /dev/null @@ -1,361 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.datastore.Datastore; -import org.opennebula.client.host.Host; -import org.opennebula.client.image.Image; -import org.opennebula.client.vm.VirtualMachine; -import org.opennebula.client.vm.VirtualMachinePool; - - -public class VirtualMachineTest -{ - - private static VirtualMachine vm; - private static VirtualMachinePool vmPool; - - private static Client client; - - private static int hid_A, hid_B; - - private static OneResponse res; - private static String name = "new_test_machine"; - - - /** - * Wait until the VM changes to the specified state. - * There is a time-out of 10 seconds. - */ - void waitAssert(VirtualMachine vm, String state, String lcmState) - { - int n_steps = 100; - int step = 100; - - int i = 0; - - vm.info(); - - while( !( (vm.stateStr().equals(state) && (!state.equals("ACTIVE") || vm.lcmStateStr().equals(lcmState) ))|| i > n_steps )) - { - try{ Thread.sleep(step); } catch (Exception e){} - - vm.info(); - i++; - } - - assertTrue( vm.stateStr().equals(state) ); - if(state.equals("ACTIVE")) - { - assertTrue( vm.lcmStateStr().equals(lcmState) ); - } - } - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - vmPool = new VirtualMachinePool(client); - - - res = Host.allocate(client, "host_A", - "dummy", "dummy"); - hid_A = Integer.parseInt( res.getMessage() ); - - res = Host.allocate(client, "host_B", - "dummy", "dummy"); - hid_B = Integer.parseInt( res.getMessage() ); - - Datastore systemDs = new Datastore(0, client); - systemDs.update("TM_MAD = dummy"); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - String template = "NAME = " + name + "\n"+ - "MEMORY = 512\n" + - "CPU = 1\n" + - "CONTEXT = [DNS = 192.169.1.4]"; - - res = VirtualMachine.allocate(client, template); - int vmid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1; - - vm = new VirtualMachine(vmid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - vm.recover(3); - waitAssert(vm, "DONE", "-"); - - vm = null; - } - - @Test - public void allocate() - { - res = vmPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(VirtualMachine vm : vmPool) - { - found = found || vm.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void update() - { - res = vm.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vm.getName().equals(name) ); - } - - @Test - public void hold() - { - res = vm.hold(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "HOLD", "-"); - } - - @Test - public void release() - { - vm.hold(); - - res = vm.release(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "PENDING", "-"); - } - - @Test - public void deploy() - { - res = vm.deploy(hid_A); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "ACTIVE", "RUNNING"); - } - - @Test - public void migrate() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.migrate(hid_B); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "ACTIVE", "RUNNING"); - } - - @Test - public void liveMigrate() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.migrate(hid_B, true); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "ACTIVE", "RUNNING"); - } - - @Test - public void terminate() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.terminate(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "DONE", "-"); - } - - @Test - public void terminatehard() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.terminate(true); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "DONE", "-"); - } - - @Test - public void stop() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.stop(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "STOPPED", "-"); - } - - @Test - public void suspend() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.suspend(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "SUSPENDED", "-"); - } - - @Test - public void resume() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - - vm.suspend(); - waitAssert(vm, "SUSPENDED", "-"); - - res = vm.resume(); - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "ACTIVE", "RUNNING"); - } - - @Test - public void delete() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - res = vm.recover(3); - - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "DONE", "-"); - } - - @Test - public void restart() - { - // TODO - } - - @Test - public void deleteRecreate() - { - vm.deploy(hid_A); - waitAssert(vm, "ACTIVE", "RUNNING"); - res = vm.recover(4); - - assertTrue( res.getErrorMessage(), !res.isError() ); - waitAssert(vm, "PENDING", "-"); - } - - @Test - public void attributes() - { - res = vm.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vm.xpath("NAME").equals(name) ); - assertTrue( vm.xpath("TEMPLATE/MEMORY").equals("512") ); -// assertTrue( vm.xpath("ID").equals("0") ); - assertTrue( vm.xpath("TEMPLATE/MEMORY").equals("512") ); - assertTrue( vm.xpath("TEMPLATE/CONTEXT/DNS").equals("192.169.1.4") ); - } - - // TODO -/* - @Test - public void savedisk() - { - String img_template = - "NAME = \"test_img\"\n" + - "PATH = /etc/hosts\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - res = Image.allocate(client, img_template, 1); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int imgid = Integer.parseInt(res.getMessage()); - - Image img = new Image(imgid, client); - ImageTest.waitAssert(img, "READY"); - - - String template = "NAME = savedisk_vm\n"+ - "MEMORY = 512\n" + - "CPU = 1\n" + - "CONTEXT = [DNS = 192.169.1.4]\n" + - "DISK = [ IMAGE = test_img ]"; - - res = VirtualMachine.allocate(client, template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int vmid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1; - - vm = new VirtualMachine(vmid, client); - - res = vm.deploy(hid_A); - assertTrue( res.getErrorMessage(), !res.isError() ); - - waitAssert(vm, "ACTIVE", "RUNNING"); - - res = vm.savedisk(0, "New_image"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int new_imgid = Integer.parseInt(res.getMessage()); - assertTrue( new_imgid == imgid+1 ); - - res = vm.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - } -*/ - @Test - public void resize() - { - res = vm.resize("CPU = 2.5\nMEMORY = 512\nVCPU = 0", true); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vm.resize("CPU = 1\nMEMORY = 128\nVCPU = 2", false); - assertTrue( res.getErrorMessage(), !res.isError() ); - } -} diff --git a/src/oca/java/test/VirtualNetworkTest.java b/src/oca/java/test/VirtualNetworkTest.java deleted file mode 100644 index 3d3a492056..0000000000 --- a/src/oca/java/test/VirtualNetworkTest.java +++ /dev/null @@ -1,234 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.vnet.VirtualNetwork; -import org.opennebula.client.vnet.VirtualNetworkPool; - -public class VirtualNetworkTest -{ - - private static VirtualNetwork vnet; - private static VirtualNetworkPool vnetPool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_vnet"; - - - private static String template = - "NAME = " + name + "\n"+ - "BRIDGE = vbr0\n" + - "VN_MAD = dummy\n" + - "NETWORK_ADDRESS = 192.168.0.0\n"+ - "AR = [ TYPE = IP4, IP = 192.168.0.1, SIZE = 254 ]\n"; - - private static String second_template = - "NAME = \"Net number one\"\n" + - "BRIDGE = br1\n" + - "VN_MAD = dummy\n" + - "AR = [ TYPE = IP4, IP=130.10.0.1, SIZE = 1]"; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - vnetPool = new VirtualNetworkPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = VirtualNetwork.allocate(client, template); - - assertTrue( res.getErrorMessage(), !res.isError() ); - - int vnid = !res.isError() ? Integer.parseInt(res.getMessage()) : -1; - vnet = new VirtualNetwork(vnid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - vnet.delete(); - } - - - @Test - public void allocate() - { - vnetPool.info(); - - boolean found = false; - for(VirtualNetwork vn : vnetPool) - { - found = found || vn.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = vnet.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( vnet.getName().equals(name) ); - } - - @Test - public void attributes() - { - res = vnet.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vnet.xpath("NAME").equals(name) ); - assertTrue( vnet.xpath("BRIDGE").equals("vbr0") ); - } - - @Test - public void delete() - { - res = vnet.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.info(); - assertTrue( res.isError() ); - } - - @Test - public void addAr() - { - res = VirtualNetwork.allocate(client, second_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - VirtualNetwork second_vnet = - new VirtualNetwork(Integer.parseInt(res.getMessage()), client); - - res = second_vnet.addAr("AR = [IP = 130.10.0.5, SIZE = 1, TYPE = IP4]"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = second_vnet.addAr("AR = [IP = 130.10.0.6, MAC = 50:20:20:20:20:20, SIZE = 1, TYPE = IP4]"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = second_vnet.addAr("130.10.0.6"); - assertTrue( res.isError() ); - - second_vnet.delete(); - } - - @Test - public void rmAr() - { - res = VirtualNetwork.allocate(client, second_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - VirtualNetwork second_vnet = - new VirtualNetwork(Integer.parseInt(res.getMessage()), client); - - res = second_vnet.rmAr(0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = second_vnet.rmAr(0); - assertTrue( res.isError() ); - - second_vnet.delete(); - } - - @Test - public void updateAr() - { - String new_template = - "AR = [ AR_ID = 0, ATT2 = NEW_VAL, ATT3 = VAL3 ]"; - - res = vnet.updateAr(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( vnet.xpath("AR_POOL/AR[AR_ID=0]/ATT1").equals( "" ) ); - assertTrue( vnet.xpath("AR_POOL/AR[AR_ID=0]/ATT2").equals( "NEW_VAL" ) ); - assertTrue( vnet.xpath("AR_POOL/AR[AR_ID=0]/ATT3").equals( "VAL3" ) ); - } - - @Test - public void hold() - { - res = vnet.hold("192.168.0.10"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.hold("192.168.0.11", 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.hold("192.168.100.1"); - assertTrue( res.isError() ); - - res = vnet.release("192.168.0.10"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.release("192.168.0.11", 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.release("192.168.0.10"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - vnet.delete(); - } - - @Test - public void update() - { - String new_template = "ATT2 = NEW_VAL\n" + - "ATT3 = VAL3"; - - res = vnet.update(new_template); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vnet.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - assertTrue( vnet.xpath("TEMPLATE/ATT1").equals( "" ) ); - assertTrue( vnet.xpath("TEMPLATE/ATT2").equals( "NEW_VAL" ) ); - assertTrue( vnet.xpath("TEMPLATE/ATT3").equals( "VAL3" ) ); - } - - // TODO: reserve, free - -} diff --git a/src/oca/java/test/VirtualRouterTest.java b/src/oca/java/test/VirtualRouterTest.java deleted file mode 100644 index c0e5cac40a..0000000000 --- a/src/oca/java/test/VirtualRouterTest.java +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************* - * Copyright 2002-2017, OpenNebula Project, OpenNebula Systems - * - * 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. - ******************************************************************************/ -import static org.junit.Assert.assertTrue; - -import org.junit.After; -import org.junit.AfterClass; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; -import org.opennebula.client.Client; -import org.opennebula.client.OneResponse; -import org.opennebula.client.group.Group; -import org.opennebula.client.template.*; -import org.opennebula.client.vrouter.*; -import org.opennebula.client.vm.*; -import org.opennebula.client.user.User; -import org.opennebula.client.vm.VirtualMachine; - - - -public class VirtualRouterTest -{ - private static VirtualRouter vrouter; - private static VirtualRouterPool vrouterPool; - - private static Client client; - - private static OneResponse res; - private static String name = "new_test_vrouter"; - - - private static String template_str = - "NAME = \"" + name + "\"\n" + - "VROUTER = YES\n" + - "ATT1 = \"VAL1\"\n" + - "ATT2 = \"VAL2\""; - - /** - * @throws java.lang.Exception - */ - @BeforeClass - public static void setUpBeforeClass() throws Exception - { - client = new Client(); - vrouterPool = new VirtualRouterPool(client); - } - - /** - * @throws java.lang.Exception - */ - @AfterClass - public static void tearDownAfterClass() throws Exception - { - } - - /** - * @throws java.lang.Exception - */ - @Before - public void setUp() throws Exception - { - res = VirtualRouter.allocate(client, template_str); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vrouter = new VirtualRouter(oid, client); - } - - /** - * @throws java.lang.Exception - */ - @After - public void tearDown() throws Exception - { - vrouter.delete(); - } - - @Test - public void allocate() - { - vrouter.delete(); - - res = VirtualRouter.allocate(client, template_str); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int oid = res.isError() ? -1 : Integer.parseInt(res.getMessage()); - vrouter = new VirtualRouter(oid, client); - - - res = vrouterPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - boolean found = false; - for(VirtualRouter temp : vrouterPool) - { - found = found || temp.getName().equals(name); - } - - assertTrue( found ); - } - - @Test - public void info() - { - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.getName().equals(name) ); - } - - @Test - public void publish() - { - res = vrouter.publish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - vrouter.info(); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_U").equals("1") ); - } - - @Test - public void unpublish() - { - res = vrouter.unpublish(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - vrouter.info(); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_U").equals("0") ); - } - - @Test - public void chmod() - { - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - String owner_a = vrouter.xpath("PERMISSIONS/OWNER_A"); - String group_a = vrouter.xpath("PERMISSIONS/GROUP_A"); - - res = vrouter.chmod(0, 1, -1, 1, 0, -1, 1, 1, 0); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_A").equals(owner_a) ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_A").equals(group_a) ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_A").equals("0") ); - } - - @Test - public void chmod_octet() - { - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.chmod(640); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_M").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_A").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_U").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_M").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_A").equals("0") ); - - res = vrouter.chmod("147"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_U").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_M").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OWNER_A").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_M").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/GROUP_A").equals("0") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_U").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_M").equals("1") ); - assertTrue( vrouter.xpath("PERMISSIONS/OTHER_A").equals("1") ); - } - - @Test - public void attributes() - { - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.xpath("NAME").equals(name) ); - } - - @Test - public void delete() - { - res = vrouter.delete(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.info(); - assertTrue( res.isError() ); - } - - @Test - public void chown() - { - // Create a new User and Group - res = User.allocate(client, "template_test_user", "password"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int uid = Integer.parseInt(res.getMessage()); - - res = Group.allocate(client, "template_test_group"); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int gid = Integer.parseInt(res.getMessage()); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.uid() == 0 ); - assertTrue( vrouter.gid() == 0 ); - - res = vrouter.chown(uid, gid); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.uid() == uid ); - assertTrue( vrouter.gid() == gid ); - - res = vrouter.chgrp(0); - - res = vrouter.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vrouter.uid() == uid ); - assertTrue( vrouter.gid() == 0 ); - } - - @Test - public void instantiate() - { - VirtualMachinePool vmPool = new VirtualMachinePool(client); - - res = vmPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmPool.getLength() == 0 ); - - String tmpl_str = - "NAME = vrtemplate\n"+ - "CPU = 0.1\n"+ - "VROUTER = YES\n"+ - "MEMORY = 64\n"; - - res = Template.allocate(client, tmpl_str); - assertTrue( res.getErrorMessage(), !res.isError() ); - - int tmplid = Integer.parseInt(res.getMessage()); - - res = vrouter.instantiate(3, tmplid); - assertTrue( res.getErrorMessage(), !res.isError() ); - - res = vmPool.info(); - assertTrue( res.getErrorMessage(), !res.isError() ); - - assertTrue( vmPool.getLength() == 3 ); - } -} diff --git a/src/oca/java/test/all_tests.sh b/src/oca/java/test/all_tests.sh deleted file mode 100755 index d0ad6a0be9..0000000000 --- a/src/oca/java/test/all_tests.sh +++ /dev/null @@ -1,89 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems # -# # -# 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. # -#--------------------------------------------------------------------------- # - -if [ -z $ONE_LOCATION ]; then - ONEDCONF_LOCATION="/etc/one/oned.conf" -else - ONEDCONF_LOCATION="$ONE_LOCATION/etc/oned.conf" -fi - -if [ -f $ONEDCONF_LOCATION ]; then - echo "$ONEDCONF_LOCATION has to be overwritten, move it to a safe place." - exit -1 -fi - -if [ -z $ONE_LOCATION ]; then - sudo cp oned.conf $ONEDCONF_LOCATION -else - cp oned.conf $ONEDCONF_LOCATION -fi - -export ONE_XMLRPC=http://localhost:2633/RPC2 - -RC=0 - -LOG_FILE="/tmp/one-java-test.txt" - -rm $LOG_FILE - -./test.sh HostTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh ImageTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh SessionTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh UserTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh VirtualMachineTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh VirtualNetworkTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh TemplateTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh GroupTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh AclTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh DocumentTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh VdcTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh SecurityGroupTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh VirtualRouterTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -./test.sh VMGroupTest 2>&1 | tee -a $LOG_FILE -let RC=RC+$? - -echo "" -echo "Output saved in $LOG_FILE" - -exit $RC \ No newline at end of file diff --git a/src/oca/java/test/oned.conf b/src/oca/java/test/oned.conf deleted file mode 100644 index 95f732c096..0000000000 --- a/src/oca/java/test/oned.conf +++ /dev/null @@ -1,1011 +0,0 @@ -#******************************************************************************* -# OpenNebula Configuration file -#******************************************************************************* - -#******************************************************************************* -# Daemon configuration attributes -#------------------------------------------------------------------------------- -# MANAGER_TIMER: Time in seconds the core uses to evaluate periodical functions. -# MONITORING_INTERVAL cannot have a smaller value than MANAGER_TIMER. -# -# MONITORING_INTERVAL: Time in seconds between host and VM monitorization. -# -# MONITORING_THREADS: Max. number of threads used to process monitor messages -# -# HOST_PER_INTERVAL: Number of hosts monitored in each interval. -# HOST_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring -# information. Use 0 to disable HOST monitoring recording. -# -# VM_INDIVIDUAL_MONITORING: VM monitoring information is obtained along with the -# host information. For some custom monitor drivers you may need activate the -# individual VM monitoring process. -# VM_PER_INTERVAL: Number of VMs monitored in each interval, if the individual -# VM monitoring is set to yes. -# VM_MONITORING_EXPIRATION_TIME: Time, in seconds, to expire monitoring -# information. Use 0 to disable VM monitoring recording. -# -# SCRIPTS_REMOTE_DIR: Remote path to store the monitoring and VM management -# scripts. -# -# PORT: Port where oned will listen for xmlrpc calls. -# LISTEN_ADDRESS: Host IP to listen on for xmlrpc calls (default: all IPs). -# -# DB: Configuration attributes for the database backend -# backend : can be sqlite or mysql (default is sqlite) -# server : (mysql) host name or an IP address for the MySQL server -# port : (mysql) port for the connection to the server. -# If set to 0, the default port is used. -# user : (mysql) user's MySQL login ID -# passwd : (mysql) the password for user -# db_name : (mysql) the database name -# -# VNC_PORTS: VNC port pool for automatic VNC port assignment, if possible the -# port will be set to ``START`` + ``VMID`` -# start : first port to assign -# reserved: comma separated list of ports -# -# LOG: Configuration for the logging system -# system: defines the logging system: -# file to log in the oned.log file -# syslog to use the syslog facilities -# std to use the default log stream (stderr) to use with systemd -# debug_level: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG -# -# VM_SUBMIT_ON_HOLD: Forces VMs to be created on hold state instead of pending. -# Values: YES or NO. -#******************************************************************************* - -LOG = [ - SYSTEM = "file", - DEBUG_LEVEL = 3 -] - -#MANAGER_TIMER = 15 - -MONITORING_INTERVAL = 60 -MONITORING_THREADS = 50 - -#HOST_PER_INTERVAL = 15 -#HOST_MONITORING_EXPIRATION_TIME = 43200 - -#VM_INDIVIDUAL_MONITORING = "no" -#VM_PER_INTERVAL = 5 -#VM_MONITORING_EXPIRATION_TIME = 14400 - -SCRIPTS_REMOTE_DIR=/var/tmp/one - -PORT = 2633 - -LISTEN_ADDRESS = "0.0.0.0" - -DB = [ BACKEND = "sqlite" ] - -# Sample configuration for MySQL -# DB = [ BACKEND = "mysql", -# SERVER = "localhost", -# PORT = 0, -# USER = "oneadmin", -# PASSWD = "oneadmin", -# DB_NAME = "opennebula" ] - -VNC_PORTS = [ - START = 5900 -# RESERVED = "6800, 6801, 9869" -] - -#VM_SUBMIT_ON_HOLD = "NO" - -#******************************************************************************* -# Federation configuration attributes -#------------------------------------------------------------------------------- -# Control the federation capabilities of oned. Operation in a federated setup -# requires a special DB configuration. -# -# FEDERATION: Federation attributes -# MODE: Operation mode of this oned. -# STANDALONE no federated.This is the default operational mode -# MASTER this oned is the master zone of the federation -# SLAVE this oned is a slave zone -# ZONE_ID: The zone ID as returned by onezone command -# MASTER_ONED: The xml-rpc endpoint of the master oned, e.g. -# http://master.one.org:2633/RPC2 -#******************************************************************************* - -FEDERATION = [ - MODE = "STANDALONE", - ZONE_ID = 0, - MASTER_ONED = "" -] - -#******************************************************************************* -# Default showback cost -#------------------------------------------------------------------------------- -# The following attributes define the default cost for Virtual Machines that -# don't have a CPU, MEMORY or DISK cost. This is used by the oneshowback -# calculate method. -#******************************************************************************* - -DEFAULT_COST = [ - CPU_COST = 0, - MEMORY_COST = 0, - DISK_COST = 0 -] - -#******************************************************************************* -# XML-RPC server configuration -#------------------------------------------------------------------------------- -# These are configuration parameters for oned's xmlrpc-c server -# -# MAX_CONN: Maximum number of simultaneous TCP connections the server -# will maintain -# -# MAX_CONN_BACKLOG: Maximum number of TCP connections the operating system -# will accept on the server's behalf without the server accepting them from -# the operating system -# -# KEEPALIVE_TIMEOUT: Maximum time in seconds that the server allows a -# connection to be open between RPCs -# -# KEEPALIVE_MAX_CONN: Maximum number of RPCs that the server will execute on -# a single connection -# -# TIMEOUT: Maximum time in seconds the server will wait for the client to -# do anything while processing an RPC. This timeout will be also used when -# proxy calls to the master in a federation. -# -# RPC_LOG: Create a separated log file for xml-rpc requests, in -# "/var/log/one/one_xmlrpc.log". -# -# MESSAGE_SIZE: Buffer size in bytes for XML-RPC responses. -# -# LOG_CALL_FORMAT: Format string to log XML-RPC calls. Interpreted strings: -# %i -- request id -# %m -- method name -# %u -- user id -# %U -- user name -# %l -- param list -# %p -- user password -# %g -- group id -# %G -- group name -# %a -- auth token -# %% -- % -#******************************************************************************* - -#MAX_CONN = 15 -#MAX_CONN_BACKLOG = 15 -#KEEPALIVE_TIMEOUT = 15 -#KEEPALIVE_MAX_CONN = 30 -#TIMEOUT = 15 -#RPC_LOG = NO -#MESSAGE_SIZE = 1073741824 -#LOG_CALL_FORMAT = "Req:%i UID:%u %m invoked %l" - -#******************************************************************************* -# Physical Networks configuration -#******************************************************************************* -# NETWORK_SIZE: Here you can define the default size for the virtual networks -# -# MAC_PREFIX: Default MAC prefix to be used to create the auto-generated MAC -# addresses is defined here (this can be overwritten by the Virtual Network -# template) -# -# VLAN_IDS: VLAN ID pool for the automatic VLAN_ID assignment. This pool -# is for 802.1Q networks (Open vSwitch and 802.1Q drivers). The driver -# will try first to allocate VLAN_IDS[START] + VNET_ID -# start: First VLAN_ID to use -# reserved: Comma separated list of VLAN_IDs -# -# VXLAN_IDS: Automatic VXLAN Network ID (VNI) assignment. This is used -# for vxlan networks. -# start: First VNI to use -# NOTE: reserved is not supported by this pool -#******************************************************************************* - -NETWORK_SIZE = 254 - -MAC_PREFIX = "02:00" - -VLAN_IDS = [ - START = "2", - RESERVED = "0, 1, 4095" -] - -VXLAN_IDS = [ - START = "2" -] - -#******************************************************************************* -# DataStore Configuration -#******************************************************************************* -# DATASTORE_LOCATION: Path for Datastores. It IS the same for all the hosts -# and front-end. It defaults to /var/lib/one/datastores (in self-contained mode -# defaults to $ONE_LOCATION/var/datastores). Each datastore has its own -# directory (called BASE_PATH) in the form: $DATASTORE_LOCATION/ -# You can symlink this directory to any other path if needed. BASE_PATH is -# generated from this attribute each time oned is started. -# -# DATASTORE_CAPACITY_CHECK: Checks that there is enough capacity before -# creating a new image. Defaults to Yes -# -# DEFAULT_IMAGE_TYPE: This can take values -# OS Image file holding an operating system -# CDROM Image file holding a CDROM -# DATABLOCK Image file holding a datablock, created as an empty block -# -# DEFAULT_DEVICE_PREFIX: This can be set to -# hd IDE prefix -# sd SCSI -# vd KVM virtual disk -# -# DEFAULT_CDROM_DEVICE_PREFIX: Same as above but for CDROM devices. -#******************************************************************************* - -#DATASTORE_LOCATION = /var/lib/one/datastores - -DATASTORE_CAPACITY_CHECK = "yes" - -DEFAULT_IMAGE_TYPE = "OS" -DEFAULT_DEVICE_PREFIX = "hd" - -DEFAULT_CDROM_DEVICE_PREFIX = "hd" - -#******************************************************************************* -# Information Driver Configuration -#******************************************************************************* -# You can add more information managers with different configurations but make -# sure it has different names. -# -# name : name for this information manager -# -# executable: path of the information driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# arguments : for the driver executable, usually a probe configuration file, -# can be an absolute path or relative to $ONE_LOCATION/etc (or -# /etc/one/ if OpenNebula was installed in /) -#******************************************************************************* - -#------------------------------------------------------------------------------- -# Information Collector for KVM IM's. -#------------------------------------------------------------------------------- -# This driver CANNOT BE ASSIGNED TO A HOST, and needs to be used with KVM -# -h prints this help. -# -a Address to bind the collectd socket (default 0.0.0.0) -# -p UDP port to listen for monitor information (default 4124) -# -f Interval in seconds to flush collected information (default 5) -# -t Number of threads for the server (default 50) -# -i Time in seconds of the monitorization push cycle. This parameter must -# be smaller than MONITORING_INTERVAL, otherwise push monitorization will -# not be effective. -#------------------------------------------------------------------------------- -IM_MAD = [ - NAME = "collectd", - EXECUTABLE = "collectd", - ARGUMENTS = "-p 4124 -f 5 -t 50 -i 20" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# KVM UDP-push Information Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -#------------------------------------------------------------------------------- -IM_MAD = [ - NAME = "kvm", - SUNSTONE_NAME = "KVM", - EXECUTABLE = "one_im_ssh", - ARGUMENTS = "-r 3 -t 15 kvm" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# KVM SSH-pull Information Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -#------------------------------------------------------------------------------- -# IM_MAD = [ -# NAME = "kvm", -# SUNSTONE_NAME = "kvm-ssh", -# EXECUTABLE = "one_im_ssh", -# ARGUMENTS = "-r 3 -t 15 kvm-probes" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# vCenter Information Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -#------------------------------------------------------------------------------- -#IM_MAD = [ -# NAME = "vcenter", -# SUNSTONE_NAME = "VMWare vCenter", -# EXECUTABLE = "one_im_sh", -# ARGUMENTS = "-c -t 15 -r 0 vcenter" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# EC2 Information Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -#------------------------------------------------------------------------------- -#IM_MAD = [ -# NAME = "ec2", -# SUNSTONE_NAME = "Amazon EC2", -# EXECUTABLE = "one_im_sh", -# ARGUMENTS = "-c -t 1 -r 0 ec2" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Azure Information Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -#------------------------------------------------------------------------------- -#IM_MAD = [ -# NAME = "az", -# SUNSTONE_NAME = "Microsoft Azure", -# EXECUTABLE = "one_im_sh", -# ARGUMENTS = "-c -t 1 -r 0 az" ] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Dummy Information Driver Manager Configuration -#------------------------------------------------------------------------------- -#IM_MAD = [ NAME="dummy", SUNSTONE_NAME="Testing", EXECUTABLE="one_im_dummy"] -#------------------------------------------------------------------------------- - -#******************************************************************************* -# Virtualization Driver Configuration -#******************************************************************************* -# You can add more virtualization managers with different configurations but -# make sure it has different names. -# -# name : name of the virtual machine manager driver -# -# executable: path of the virtualization driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# arguments : for the driver executable -# -# default : default values and configuration parameters for the driver, can -# be an absolute path or relative to $ONE_LOCATION/etc (or -# /etc/one/ if OpenNebula was installed in /) -# -# type : driver type, supported drivers: xen, kvm, xml -# -# keep_snapshots: do not remove snapshots on power on/off cycles and live -# migrations if the hypervisor supports that. -# -# imported_vms_actions : comma-separated list of actions supported -# for imported vms. The available actions are: -# migrate -# live-migrate -# terminate -# terminate-hard -# undeploy -# undeploy-hard -# hold -# release -# stop -# suspend -# resume -# delete -# delete-recreate -# reboot -# reboot-hard -# resched -# unresched -# poweroff -# poweroff-hard -# disk-attach -# disk-detach -# nic-attach -# nic-detach -# snap-create -# snap-delete -#******************************************************************************* - -#------------------------------------------------------------------------------- -# KVM Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -# -l actions executed locally, command can be -# overridden for each action. -# Valid actions: deploy, shutdown, cancel, save, restore, migrate, poll -# An example: "-l migrate=migrate_local,save" -# -p more than one action per host in parallel, needs support from hypervisor -# -s to execute remote commands, bash by default -# -# Note: You can use type = "qemu" to use qemu emulated guests, e.g. if your -# CPU does not have virtualization extensions or use nested Qemu-KVM hosts -#------------------------------------------------------------------------------- -VM_MAD = [ - NAME = "kvm", - SUNSTONE_NAME = "KVM", - EXECUTABLE = "one_vmm_exec", - ARGUMENTS = "-t 15 -r 0 kvm", - DEFAULT = "vmm_exec/vmm_exec_kvm.conf", - TYPE = "kvm", - KEEP_SNAPSHOTS = "no", - IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, - resume, delete, reboot, reboot-hard, resched, unresched, disk-attach, - disk-detach, nic-attach, nic-detach, snap-create, snap-delete" -] - -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# vCenter Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of hosts monitored at the same time -# -p more than one action per host in parallel, needs support from hypervisor -# -s to execute commands, bash by default -# -d default snapshot strategy. It can be either 'detach' or 'suspend'. It -# defaults to 'suspend'. -#------------------------------------------------------------------------------- -#VM_MAD = [ -# NAME = "vcenter", -# SUNSTONE_NAME = "VMWare vCenter", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-p -t 15 -r 0 vcenter -s sh", -# DEFAULT = "vmm_exec/vmm_exec_vcenter.conf", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "yes", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, -# snap-create, snap-delete" -#] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# EC2 Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of actions performed at the same time -#------------------------------------------------------------------------------- -#VM_MAD = [ -# NAME = "ec2", -# SUNSTONE_NAME = "Amazon EC2", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 ec2", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "no", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, -# snap-create, snap-delete" -#] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Azure Virtualization Driver Manager Configuration -# -r number of retries when monitoring a host -# -t number of threads, i.e. number of actions performed at the same time -#------------------------------------------------------------------------------- -#VM_MAD = [ -# NAME = "az", -# SUNSTONE_NAME = "Microsoft Azure", -# EXECUTABLE = "one_vmm_sh", -# ARGUMENTS = "-t 15 -r 0 az", -# TYPE = "xml", -# KEEP_SNAPSHOTS = "no", -# IMPORTED_VMS_ACTIONS = "terminate, terminate-hard, hold, release, suspend, -# resume, delete, reboot, reboot-hard, resched, unresched, poweroff, -# poweroff-hard, disk-attach, disk-detach, nic-attach, nic-detach, -# snap-create, snap-delete" -#] -#------------------------------------------------------------------------------- - -#------------------------------------------------------------------------------- -# Dummy Virtualization Driver Configuration -#------------------------------------------------------------------------------- -VM_MAD = [ NAME="dummy", SUNSTONE_NAME="Testing", EXECUTABLE="one_vmm_dummy", - TYPE="xml" ] -#------------------------------------------------------------------------------- - -#******************************************************************************* -# Transfer Manager Driver Configuration -#******************************************************************************* -# You can add more transfer managers with different configurations but make -# sure it has different names. -# name : name for this transfer driver -# -# executable: path of the transfer driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# arguments : -# -t: number of threads, i.e. number of transfers made at the same time -# -d: list of transfer drivers separated by commas, if not defined all the -# drivers available will be enabled -#******************************************************************************* - -TM_MAD = [ - EXECUTABLE = "one_tm", - ARGUMENTS = "-t 15 -d dummy,lvm,shared,fs_lvm,qcow2,ssh,ceph,dev,vcenter,iscsi_libvirt" -] - -#******************************************************************************* -# Datastore Driver Configuration -#******************************************************************************* -# Drivers to manage the datastores, specialized for the storage backend -# executable: path of the transfer driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# arguments : for the driver executable -# -t number of threads, i.e. number of repo operations at the same time -# -d datastore mads separated by commas -# -s system datastore tm drivers, used to monitor shared system ds. -#******************************************************************************* - -DATASTORE_MAD = [ - EXECUTABLE = "one_datastore", - ARGUMENTS = "-t 15 -d dummy,fs,lvm,ceph,dev,iscsi_libvirt,vcenter -s shared,ssh,ceph,fs_lvm,qcow2" -] - -#******************************************************************************* -# Marketplace Driver Configuration -#******************************************************************************* -# Drivers to manage different marketplaces, specialized for the storage backend -# executable: path of the transfer driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# arguments : for the driver executable -# -t number of threads, i.e. number of repo operations at the same time -# -m marketplace mads separated by commas -#******************************************************************************* - -MARKET_MAD = [ - EXECUTABLE = "one_market", - ARGUMENTS = "-t 15 -m http,s3,one" -] - -#******************************************************************************* -# Hook Manager Configuration -#******************************************************************************* -# The Driver (HM_MAD) -# ----------------------------------------------- -# -# Used to execute the Hooks: -# executable: path of the hook driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# arguments : for the driver executable, can be an absolute path or relative -# to $ONE_LOCATION/etc (or /etc/one/ if OpenNebula was installed -# in /) -# -# Virtual Machine Hooks (VM_HOOK) -# ------------------------------- -# -# Defined by: -# name : for the hook, useful to track the hook (OPTIONAL) -# on : when the hook should be executed, -# - CREATE, when the VM is created (onevm create) -# - PROLOG, when the VM is in the prolog state -# - RUNNING, after the VM is successfully booted -# - UNKNOWN, when the VM is in the unknown state -# - SHUTDOWN, after the VM is shutdown -# - STOP, after the VM is stopped (including VM image transfers) -# - DONE, after the VM is deleted or shutdown -# - CUSTOM, user defined specific STATE and LCM_STATE combination -# of states to trigger the hook. -# command : path is relative to $ONE_LOCATION/var/remotes/hook -# (self-contained) or to /var/lib/one/remotes/hook (system-wide). -# That directory will be copied on the hosts under -# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist -# on the target host -# arguments : for the hook. You can access to VM information with $ -# - $ID, the ID of the virtual machine -# - $TEMPLATE, the VM template in xml and base64 encoded -# - $PREV_STATE, the previous STATE of the Virtual Machine -# - $PREV_LCM_STATE, the previous LCM STATE of the Virtual Machine -# remote : values, -# - YES, The hook is executed in the host where the VM was -# allocated -# - NO, The hook is executed in the OpenNebula server (default) -# -# Example Virtual Machine Hook -# ---------------------------- -# -# VM_HOOK = [ -# name = "advanced_hook", -# on = "CUSTOM", -# state = "ACTIVE", -# lcm_state = "BOOT_UNKNOWN", -# command = "log.rb", -# arguments = "$ID $PREV_STATE $PREV_LCM_STATE" ] -# -# Host Hooks (HOST_HOOK) -# ------------------------------- -# -# Defined by: -# name : for the hook, useful to track the hook (OPTIONAL) -# on : when the hook should be executed, -# - CREATE, when the Host is created (onehost create) -# - ERROR, when the Host enters the error state -# - DISABLE, when the Host is disabled -# command : path is relative to $ONE_LOCATION/var/remotes/hook -# (self-contained) or to /var/lib/one/remotes/hook (system-wide). -# That directory will be copied on the hosts under -# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist -# on the target host. -# arguments : for the hook. You can use the following Host information: -# - $ID, the ID of the host -# - $TEMPLATE, the Host template in xml and base64 encoded -# remote : values, -# - YES, The hook is executed in the host -# - NO, The hook is executed in the OpenNebula server (default) -# -# Virtual Network (VNET_HOOK) -# Virtual Router (VROUTER_HOOK) -# User (USER_HOOK) -# Group (GROUP_HOOK) -# Image (IMAGE_HOOK) -# ------------------------------- -# -# These hooks are executed when one of the referring entities are created or -# removed. Each hook is defined by: -# name : for the hook, useful to track the hook (OPTIONAL) -# on : when the hook should be executed, -# - CREATE, when the vnet is created -# - REMOVE, when the vnet is removed -# command : path is relative to $ONE_LOCATION/var/remotes/hook -# (self-contained) or to /var/lib/one/remotes/hook (system-wide). -# That directory will be copied on the hosts under -# SCRIPTS_REMOTE_DIR. It can be an absolute path that must exist -# on the target host. -# arguments : for the hook. You can use the following Host information: -# - $ID, the ID of the host -# - $TEMPLATE, the vnet template in xml and base64 encoded -# -# Please note: In a Federation, User and Group hooks can only be defined in -# the master OpenNebula. -#------------------------------------------------------------------------------- -HM_MAD = [ - EXECUTABLE = "one_hm" ] - -#******************************************************************************* -# Fault Tolerance Hooks -#******************************************************************************* -# This hook is used to perform recovery actions when a host fails. -# Script to implement host failure tolerance -# It can be set to -# -m migrate VMs to another host. Only for images in shared storage -# -r recreate VMs running in the host. State will be lost. -# -d delete VMs running in the host -# Additional flags -# -f force resubmission of suspended VMs -# -p avoid resubmission if host comes -# back after n monitoring cycles -#******************************************************************************* -# -#HOST_HOOK = [ -# NAME = "error", -# ON = "ERROR", -# COMMAND = "ft/host_error.rb", -# ARGUMENTS = "$ID -m -p 5", -# REMOTE = "no" ] -#------------------------------------------------------------------------------- - -#******************************************************************************* -# Auth Manager Configuration -#******************************************************************************* -# AUTH_MAD: The Driver that will be used to authenticate (authn) and -# authorize (authz) OpenNebula requests. If defined OpenNebula will use the -# built-in auth policies. -# -# executable: path of the auth driver executable, can be an -# absolute path or relative to $ONE_LOCATION/lib/mads (or -# /usr/lib/one/mads/ if OpenNebula was installed in /) -# -# authn : list of authentication modules separated by commas, if not -# defined all the modules available will be enabled -# authz : list of authentication modules separated by commas -# -# DEFAULT_AUTH: The default authentication driver to use when OpenNebula does -# not know the user and needs to authenticate it externally. If you want to -# use "default" (not recommended, but supported for backwards compatibility -# reasons) make sure you create a symlink pointing to the actual authentication -# driver in /var/lib/one/remotes/auth, and add "default" to the 'auth' -# parameter in the 'AUTH_MAD' section. -# -# SESSION_EXPIRATION_TIME: Time in seconds to keep an authenticated token as -# valid. During this time, the driver is not used. Use 0 to disable session -# caching -# -# ENABLE_OTHER_PERMISSIONS: Whether or not users can set the permissions for -# 'other', so publishing or sharing resources with others. Users in the oneadmin -# group will still be able to change these permissions. Values: YES or NO. -# -# DEFAULT_UMASK: Similar to Unix umask, sets the default resources permissions. -# Its format must be 3 octal digits. For example a umask of 137 will set -# the new object's permissions to 640 "um- u-- ---" -#******************************************************************************* - -AUTH_MAD = [ - EXECUTABLE = "one_auth_mad", - AUTHN = "ssh,x509,ldap,server_cipher,server_x509" -] - -#DEFAULT_AUTH = "default" - -SESSION_EXPIRATION_TIME = 900 - -#ENABLE_OTHER_PERMISSIONS = "YES" - -DEFAULT_UMASK = 177 - -#******************************************************************************* -# OneGate -# ONEGATE_ENDPOINT: The URL for the onegate server (the Gate to OpenNebula for -# VMs). The onegate server is started using a separate command. The endpoint -# MUST be consistent with the values in onegate-server.conf -#******************************************************************************* - -#ONEGATE_ENDPOINT = "http://frontend:5030" - -#******************************************************************************* -# Restricted Attributes Configuration -#******************************************************************************* -# The following attributes are restricted to users outside the oneadmin group -#******************************************************************************* - -VM_RESTRICTED_ATTR = "CONTEXT/FILES" -VM_RESTRICTED_ATTR = "NIC/MAC" -VM_RESTRICTED_ATTR = "NIC/VLAN_ID" -VM_RESTRICTED_ATTR = "NIC/BRIDGE" -VM_RESTRICTED_ATTR = "NIC_DEFAULT/MAC" -VM_RESTRICTED_ATTR = "NIC_DEFAULT/VLAN_ID" -VM_RESTRICTED_ATTR = "NIC_DEFAULT/BRIDGE" -VM_RESTRICTED_ATTR = "DISK/TOTAL_BYTES_SEC" -VM_RESTRICTED_ATTR = "DISK/READ_BYTES_SEC" -VM_RESTRICTED_ATTR = "DISK/WRITE_BYTES_SEC" -VM_RESTRICTED_ATTR = "DISK/TOTAL_IOPS_SEC" -VM_RESTRICTED_ATTR = "DISK/READ_IOPS_SEC" -VM_RESTRICTED_ATTR = "DISK/WRITE_IOPS_SEC" -#VM_RESTRICTED_ATTR = "DISK/SIZE" -VM_RESTRICTED_ATTR = "DISK/ORIGINAL_SIZE" -VM_RESTRICTED_ATTR = "CPU_COST" -VM_RESTRICTED_ATTR = "MEMORY_COST" -VM_RESTRICTED_ATTR = "DISK_COST" -VM_RESTRICTED_ATTR = "PCI" -VM_RESTRICTED_ATTR = "USER_INPUTS" - -#VM_RESTRICTED_ATTR = "RANK" -#VM_RESTRICTED_ATTR = "SCHED_RANK" -#VM_RESTRICTED_ATTR = "REQUIREMENTS" -#VM_RESTRICTED_ATTR = "SCHED_REQUIREMENTS" - -IMAGE_RESTRICTED_ATTR = "SOURCE" - -#******************************************************************************* -# The following restricted attributes only apply to VNets that are a reservation. -# Normal VNets do not have restricted attributes. -#******************************************************************************* - -VNET_RESTRICTED_ATTR = "VN_MAD" -VNET_RESTRICTED_ATTR = "PHYDEV" -VNET_RESTRICTED_ATTR = "VLAN_ID" -VNET_RESTRICTED_ATTR = "BRIDGE" - -VNET_RESTRICTED_ATTR = "AR/VN_MAD" -VNET_RESTRICTED_ATTR = "AR/PHYDEV" -VNET_RESTRICTED_ATTR = "AR/VLAN_ID" -VNET_RESTRICTED_ATTR = "AR/BRIDGE" - -#******************************************************************************* -# Inherited Attributes Configuration -#******************************************************************************* -# The following attributes will be copied from the resource template to the -# instantiated VMs. More than one attribute can be defined. -# -# INHERIT_IMAGE_ATTR: Attribute to be copied from the Image template -# to each VM/DISK. -# -# INHERIT_DATASTORE_ATTR: Attribute to be copied from the Datastore template -# to each VM/DISK. -# -# INHERIT_VNET_ATTR: Attribute to be copied from the Network template -# to each VM/NIC. -#******************************************************************************* - -#INHERIT_IMAGE_ATTR = "EXAMPLE" -#INHERIT_IMAGE_ATTR = "SECOND_EXAMPLE" -#INHERIT_DATASTORE_ATTR = "COLOR" -#INHERIT_VNET_ATTR = "BANDWIDTH_THROTTLING" - -INHERIT_DATASTORE_ATTR = "CEPH_HOST" -INHERIT_DATASTORE_ATTR = "CEPH_SECRET" -INHERIT_DATASTORE_ATTR = "CEPH_USER" -INHERIT_DATASTORE_ATTR = "CEPH_KEY" -INHERIT_DATASTORE_ATTR = "CEPH_CONF" -INHERIT_DATASTORE_ATTR = "POOL_NAME" - -INHERIT_DATASTORE_ATTR = "ISCSI_USER" -INHERIT_DATASTORE_ATTR = "ISCSI_USAGE" -INHERIT_DATASTORE_ATTR = "ISCSI_HOST" - -INHERIT_IMAGE_ATTR = "ISCSI_USER" -INHERIT_IMAGE_ATTR = "ISCSI_USAGE" -INHERIT_IMAGE_ATTR = "ISCSI_HOST" -INHERIT_IMAGE_ATTR = "ISCSI_IQN" - -INHERIT_DATASTORE_ATTR = "GLUSTER_HOST" -INHERIT_DATASTORE_ATTR = "GLUSTER_VOLUME" - -INHERIT_DATASTORE_ATTR = "DISK_TYPE" -INHERIT_DATASTORE_ATTR = "VCENTER_ADAPTER_TYPE" -INHERIT_DATASTORE_ATTR = "VCENTER_DISK_TYPE" -INHERIT_DATASTORE_ATTR = "VCENTER_DS_REF" -INHERIT_DATASTORE_ATTR = "VCENTER_DS_IMAGE_DIR" -INHERIT_DATASTORE_ATTR = "VCENTER_DS_VOLATILE_DIR" -INHERIT_DATASTORE_ATTR = "VCENTER_INSTANCE_ID" - - -INHERIT_IMAGE_ATTR = "DISK_TYPE" -INHERIT_IMAGE_ATTR = "VCENTER_ADAPTER_TYPE" -INHERIT_IMAGE_ATTR = "VCENTER_DISK_TYPE" - -INHERIT_VNET_ATTR = "VLAN_TAGGED_ID" -INHERIT_VNET_ATTR = "FILTER_IP_SPOOFING" -INHERIT_VNET_ATTR = "FILTER_MAC_SPOOFING" -INHERIT_VNET_ATTR = "MTU" - -#******************************************************************************* -# Transfer Manager Driver Behavior Configuration -#******************************************************************************* -# The configuration for each driver is defined in TM_MAD_CONF. These -# values are used when creating a new datastore and should not be modified -# since they define the datastore behavior. -# name : name of the transfer driver, listed in the -d option of the -# TM_MAD section -# ln_target : determines how the persistent images will be cloned when -# a new VM is instantiated. -# NONE: The image will be linked and no more storage capacity will be used -# SELF: The image will be cloned in the Images datastore -# SYSTEM: The image will be cloned in the System datastore -# clone_target : determines how the non persistent images will be -# cloned when a new VM is instantiated. -# NONE: The image will be linked and no more storage capacity will be used -# SELF: The image will be cloned in the Images datastore -# SYSTEM: The image will be cloned in the System datastore -# shared : determines if the storage holding the system datastore is shared -# among the different hosts or not. Valid values: "yes" or "no" -# ds_migrate : The driver allows migrations across datastores. Valid values: -# "yes" or "no". Note: THIS ONLY APPLIES TO SYSTEM DS. -#******************************************************************************* - -TM_MAD_CONF = [ - NAME = "dummy", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES", - DS_MIGRATE = "YES" -] - -TM_MAD_CONF = [ - NAME = "lvm", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES" -] - -TM_MAD_CONF = [ - NAME = "shared", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES", - DS_MIGRATE = "YES" -] - -TM_MAD_CONF = [ - NAME = "fs_lvm", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED="YES" -] - -TM_MAD_CONF = [ - NAME = "qcow2", LN_TARGET = "NONE", CLONE_TARGET = "SYSTEM", SHARED = "YES" -] - -TM_MAD_CONF = [ - NAME = "ssh", LN_TARGET = "SYSTEM", CLONE_TARGET = "SYSTEM", SHARED = "NO", - DS_MIGRATE = "YES" -] - -TM_MAD_CONF = [ - NAME = "ceph", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES", - DS_MIGRATE = "NO" -] - -TM_MAD_CONF = [ - NAME = "iscsi_libvirt", LN_TARGET = "NONE", CLONE_TARGET = "SELF", SHARED = "YES", - DS_MIGRATE = "NO" -] - -TM_MAD_CONF = [ - NAME = "dev", LN_TARGET = "NONE", CLONE_TARGET = "NONE", SHARED = "YES" -] - -TM_MAD_CONF = [ - NAME = "vcenter", LN_TARGET = "NONE", CLONE_TARGET = "NONE", SHARED = "YES" -] - -#******************************************************************************* -# Datastore Manager Driver Behavior Configuration -#******************************************************************************* -# The configuration for each driver is defined in DS_MAD_CONF. These -# values are used when creating a new datastore and should not be modified -# since they define the datastore behavior. -# name : name of the transfer driver, listed in the -d option of the -# DS_MAD section -# required_attrs : comma separated list of required attributes in the DS -# template -# persistent_only: specifies whether the datastore can only manage persistent -# images -#******************************************************************************* - -DS_MAD_CONF = [ - NAME = "ceph", - REQUIRED_ATTRS = "DISK_TYPE,BRIDGE_LIST", - PERSISTENT_ONLY = "NO", - MARKETPLACE_ACTIONS = "export" -] - -DS_MAD_CONF = [ - NAME = "dev", REQUIRED_ATTRS = "DISK_TYPE", PERSISTENT_ONLY = "YES" -] - -DS_MAD_CONF = [ - NAME = "iscsi_libvirt", REQUIRED_ATTRS = "DISK_TYPE,ISCSI_HOST", - PERSISTENT_ONLY = "YES" -] - -DS_MAD_CONF = [ - NAME = "dummy", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO" -] - -DS_MAD_CONF = [ - NAME = "fs", REQUIRED_ATTRS = "", PERSISTENT_ONLY = "NO", - MARKETPLACE_ACTIONS = "export" -] - -DS_MAD_CONF = [ - NAME = "lvm", REQUIRED_ATTRS = "DISK_TYPE,BRIDGE_LIST", - PERSISTENT_ONLY = "NO" -] - -DS_MAD_CONF = [ - NAME = "vcenter", - REQUIRED_ATTRS = "VCENTER_INSTANCE_ID, VCENTER_DS_REF, VCENTER_DC_REF", - PERSISTENT_ONLY = "NO", - MARKETPLACE_ACTIONS = "export" -] - -#******************************************************************************* -# MarketPlace Driver Behavior Configuration -#******************************************************************************* -# The configuration for each driver is defined in MARKET_MAD_CONF. These -# values are used when creating a new marketplaces and should not be modified -# since they define the marketplace behavior. -# name : name of the market driver -# required_attrs : comma separated list of required attributes in the Market -# template -# app_actions: List of actions allowed for a MarketPlaceApp -# - monitor The apps of the marketplace will be monitored -# - create, the app in the marketplace -# - delete, the app from the marketplace -# public: set to yes for external marketplaces. A public marketplace can be -# removed even if it has registered apps. -#******************************************************************************* - -MARKET_MAD_CONF = [ - NAME = "one", - SUNSTONE_NAME = "OpenNebula.org Marketplace", - REQUIRED_ATTRS = "", - APP_ACTIONS = "monitor", - PUBLIC = "yes" -] - -MARKET_MAD_CONF = [ - NAME = "http", - SUNSTONE_NAME = "HTTP server", - REQUIRED_ATTRS = "BASE_URL,PUBLIC_DIR", - APP_ACTIONS = "create, delete, monitor" -] - -MARKET_MAD_CONF = [ - NAME = "s3", - SUNSTONE_NAME = "Amazon S3", - REQUIRED_ATTRS = "ACCESS_KEY_ID,SECRET_ACCESS_KEY,REGION,BUCKET", - APP_ACTIONS = "create, delete, monitor" -] diff --git a/src/oca/java/test/test.sh b/src/oca/java/test/test.sh deleted file mode 100755 index fc6e35c2e1..0000000000 --- a/src/oca/java/test/test.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2017, OpenNebula Project, OpenNebula Systems # -# # -# 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. # -#--------------------------------------------------------------------------- # - -# Usage: test.sh -# For instance: test.sh ImageTest - - -if [ -z $ONE_LOCATION ]; then - DB_LOCATION="/var/lib/one/one.db" - LOG_LOCATION="/var/log/one" - AUTH_LOCATION="/var/lib/one/.one" -else - DB_LOCATION="$ONE_LOCATION/var/one.db" - LOG_LOCATION="$ONE_LOCATION/var" - AUTH_LOCATION="$ONE_LOCATION/var/.one" -fi - -if [ -f $DB_LOCATION ]; then - echo "$DB_LOCATION has to be overwritten, move it to a safe place." - exit -1 -fi - -echo "=========================================================================" -echo "Doing $1" -echo "=========================================================================" - -rm -rf $AUTH_LOCATION - -PID=$$ - -oned -f & - -sleep 2; - -until grep 'Datastore default (1) successfully monitored' $LOG_LOCATION/oned.log; do - sleep 1; -done - -echo 'SAFE_DIRS = "/"' > /tmp/one-javatest-ds.txt -onedatastore update --append 1 /tmp/one-javatest-ds.txt - -java -cp ../lib/*:../jar/*:. org.junit.runner.JUnitCore $1 - -CODE=$? - -pkill -P $PID oned -sleep 4s; -pkill -9 -P $PID oned -rm -f $DB_LOCATION - -exit $CODE \ No newline at end of file