Merge branch 'master' into feature-1691

Conflicts:
	include/DispatchManager.h
	include/LifeCycleManager.h
	include/RequestManagerVirtualMachine.h
	include/VirtualMachineManager.h
	include/VirtualMachineManagerDriver.h
	src/cli/onevm
	src/dm/DispatchManagerActions.cc
	src/lcm/LifeCycleManager.cc
	src/lcm/LifeCycleStates.cc
	src/mad/ruby/VirtualMachineDriver.rb
	src/oca/java/src/org/opennebula/client/vm/VirtualMachine.java
	src/oca/ruby/opennebula/virtual_machine.rb
	src/onedb/3.8.1_to_3.9.80.rb
	src/rm/RequestManager.cc
	src/rm/RequestManagerVirtualMachine.cc
	src/vmm/VirtualMachineManager.cc
	src/vmm/VirtualMachineManagerDriver.cc
	src/vmm_mad/dummy/one_vmm_dummy.rb
This commit is contained in:
Ruben S. Montero committed 2013-03-06 15:59:58 +01:00
commit 5b117c6d2d
992 files changed
+15911 -4714

No files matched your search

+3 -3
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# 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 #
@@ -83,8 +83,8 @@ do_documentation()
-doctitle 'OpenNebula Cloud API Specification' \
-header '<b>OpenNebula</b><br><font size="-1">Cloud API</font>' \
-bottom 'Visit <a
href="http://opennebula.org/">OpenNebula.org</a><br>Copyright 2002-2012 &copy;
OpenNebula Project Leads (OpenNebula.org).'
href="http://opennebula.org/">OpenNebula.org</a><br>Copyright 2002-2013 &copy;
OpenNebula Project (OpenNebula.org), C12G Labs.'
}
do_jar()
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -129,16 +129,6 @@ public class Client{
return call("system.version");
}
/**
* Calls OpenNebula and retrieves oned configuration
*
* @return The server's xml-rpc response encapsulated
*/
public OneResponse get_config()
{
return call("system.config");
}
//--------------------------------------------------------------------------
// PRIVATE ATTRIBUTES AND METHODS
//--------------------------------------------------------------------------
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -32,12 +32,84 @@ public class OneSystem
private static final String GROUP_QUOTA_INFO = "groupquota.info";
private static final String GROUP_QUOTA_UPDATE = "groupquota.update";
public static final String VERSION = "3.9.0";
public OneSystem(Client client)
{
this.client = client;
}
/**
* Calls OpenNebula and retrieves the oned version
*
* @return The server's xml-rpc response encapsulated
*/
public OneResponse getOnedVersion()
{
return client.call("system.version");
}
/**
* Returns whether of not the oned version is the same as the OCA version
*
* @return true if oned is the same version
*/
public boolean compatibleVersion()
{
OneResponse r = getOnedVersion();
if (r.isError())
{
return false;
}
String[] ocaVersion = VERSION.split("\\.", 3);
String[] onedVersion = r.getMessage().split("\\.", 3);
return ocaVersion.length == onedVersion.length &&
ocaVersion[0].equals(onedVersion[0]) &&
ocaVersion[1].equals(onedVersion[1]);
}
/**
* Calls OpenNebula and retrieves oned configuration
*
* @return The server's xml-rpc response encapsulated
*/
public OneResponse getConfiguration()
{
return client.call("system.config");
}
/**
* Calls OpenNebula and retrieves oned configuration
*
* @return The xml root node in case of success, null otherwise
*/
public Node getConfigurationXML()
{
OneResponse r = getConfiguration();
Node xml = null;
if (r.isError())
{
return null;
}
try
{
DocumentBuilder builder =
DocumentBuilderFactory.newInstance().newDocumentBuilder();
Document doc = builder.parse(
new ByteArrayInputStream(r.getMessage().getBytes()));
xml = doc.getDocumentElement();
}
catch (Exception e) {}
return xml;
}
/**
* Gets the default user quota limits
*
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -52,6 +52,7 @@ public class Acl extends PoolElement{
tmpUsers.put("#", 0x0000000100000000L);
tmpUsers.put("@", 0x0000000200000000L);
tmpUsers.put("*", 0x0000000400000000L);
tmpUsers.put("%", 0x0000000800000000L);
USERS = Collections.unmodifiableMap(tmpUsers);
@@ -339,7 +340,7 @@ public class Acl extends PoolElement{
*/
private static long calculateIds(String id) throws RuleParseException
{
if( !id.matches("^([#@]\\d+|\\*)$") )
if( !id.matches("^([#@%]\\d+|\\*)$") )
{
throw new RuleParseException("ID string '" + id + "' malformed");
}
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -65,6 +65,7 @@ public abstract class Document extends PoolElement
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String CLONE = METHOD_PREFIX + "clone";
private static final String RENAME = METHOD_PREFIX + "rename";
/**
* Creates a new Document representation.
@@ -215,6 +216,17 @@ public abstract class Document extends PoolElement
return client.call(CLONE, id, name);
}
/**
* Renames this document
*
* @param name New name for the document.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse rename(String name)
{
return client.call(RENAME, id, name);
}
// =================================
// Helpers
// =================================
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public class Image extends PoolElement
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String CHTYPE = METHOD_PREFIX + "chtype";
private static final String CLONE = METHOD_PREFIX + "clone";
private static final String RENAME = METHOD_PREFIX + "rename";
private static final String[] IMAGE_STATES =
{"INIT", "READY", "USED", "DISABLED", "LOCKED",
@@ -265,6 +266,19 @@ public class Image extends PoolElement
return client.call(CLONE, id, name);
}
/**
* Renames this Image
*
* @param client XML-RPC Client.
* @param id The Image id of the target Image.
* @param name New name for the Image.
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse rename(Client client, int id, String name)
{
return client.call(RENAME, id, name);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@@ -498,6 +512,17 @@ public class Image extends PoolElement
return clone(client, id, name);
}
/**
* Renames this Image
*
* @param name New name for the Image.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse rename(String name)
{
return rename(client, id, name);
}
// =================================
// Helpers
// =================================
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -36,6 +36,7 @@ public class Template extends PoolElement
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String INSTANTIATE = METHOD_PREFIX + "instantiate";
private static final String CLONE = METHOD_PREFIX + "clone";
private static final String RENAME = METHOD_PREFIX + "rename";
/**
* Creates a new Template representation.
@@ -199,11 +200,15 @@ public class Template extends PoolElement
* @param client XML-RPC Client.
* @param id The template id of the target template.
* @param name A string containing the name of the VM instance, can be empty.
* @param onHold False to create this VM in pending state, true on hold
* @param template User provided Template to merge with the one
* being instantiated
* @return If successful the message contains the VM Instance ID.
*/
public static OneResponse instantiate(Client client, int id, String name)
public static OneResponse instantiate(Client client, int id, String name,
boolean onHold, String template)
{
return client.call(INSTANTIATE, id, name);
return client.call(INSTANTIATE, id, name, onHold, template);
}
/**
@@ -219,6 +224,19 @@ public class Template extends PoolElement
return client.call(CLONE, id, name);
}
/**
* Renames this Template
*
* @param client XML-RPC Client.
* @param id The Template id of the target Template.
* @param name New name for the Template.
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse rename(Client client, int id, String name)
{
return client.call(RENAME, id, name);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@@ -368,6 +386,20 @@ public class Template extends PoolElement
return chmod(client, id, octet);
}
/**
* Creates a VM instance from a Template
*
* @param name A string containing the name of the VM instance, can be empty.
* @param onHold False to create this VM in pending state, true on hold
* @param template User provided Template to merge with the one
* being instantiated
* @return If successful the message contains the VM Instance ID.
*/
public OneResponse instantiate(String name, boolean onHold, String template)
{
return instantiate(client, id, name, onHold, template);
}
/**
* Creates a VM instance from a Template
*
@@ -376,7 +408,7 @@ public class Template extends PoolElement
*/
public OneResponse instantiate(String name)
{
return instantiate(client, id, name);
return instantiate(client, id, name, false, "");
}
/**
@@ -386,7 +418,7 @@ public class Template extends PoolElement
*/
public OneResponse instantiate()
{
return instantiate(client, id, "");
return instantiate(client, id, "", false, "");
}
/**
@@ -400,6 +432,17 @@ public class Template extends PoolElement
return clone(client, id, name);
}
/**
* Renames this Template
*
* @param name New name for the Template.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse rename(String name)
{
return rename(client, id, name);
}
// =================================
// Helpers
// =================================
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -26,21 +26,22 @@ import org.w3c.dom.Node;
* It also offers static XML-RPC call wrappers.
*/
public class VirtualMachine extends PoolElement{
private static final String METHOD_PREFIX = "vm.";
private static final String ALLOCATE = METHOD_PREFIX + "allocate";
private static final String INFO = METHOD_PREFIX + "info";
private static final String DEPLOY = METHOD_PREFIX + "deploy";
private static final String ACTION = METHOD_PREFIX + "action";
private static final String MIGRATE = METHOD_PREFIX + "migrate";
private static final String SAVEDISK = METHOD_PREFIX + "savedisk";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String MONITORING = METHOD_PREFIX + "monitoring";
private static final String ATTACH = METHOD_PREFIX + "attach";
private static final String DETACH = METHOD_PREFIX + "detach";
private static final String ATTACHNIC = METHOD_PREFIX + "attachnic";
private static final String DETACHNIC = METHOD_PREFIX + "detachnic";
private static final String ALLOCATE = METHOD_PREFIX + "allocate";
private static final String INFO = METHOD_PREFIX + "info";
private static final String DEPLOY = METHOD_PREFIX + "deploy";
private static final String ACTION = METHOD_PREFIX + "action";
private static final String MIGRATE = METHOD_PREFIX + "migrate";
private static final String SAVEDISK = METHOD_PREFIX + "savedisk";
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String MONITORING = METHOD_PREFIX + "monitoring";
private static final String ATTACH = METHOD_PREFIX + "attach";
private static final String DETACH = METHOD_PREFIX + "detach";
private static final String RENAME = METHOD_PREFIX + "rename";
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String RESIZE = METHOD_PREFIX + "resize";
private static final String ATTACHNIC = METHOD_PREFIX + "attachnic";
private static final String DETACHNIC = METHOD_PREFIX + "detachnic";
private static final String[] VM_STATES =
{
@@ -83,14 +84,16 @@ public class VirtualMachine extends PoolElement{
"SHUTDOWN",
"CANCEL",
"FAILURE",
"CLEANUP",
"CLEANUP_RESUBMIT",
"UNKNOWN",
"HOTPLUG",
"SHUTDOWN_POWEROFF",
"BOOT_UNKNOWN",
"BOOT_POWEROFF",
"BOOT_SUSPENDED",
"BOOT_STOPPED" };
"BOOT_STOPPED",
"CLEANUP_DELETE",
"HOTPLUG_SNAPSHOT" };
private static final String[] SHORT_LCM_STATES =
{
@@ -116,7 +119,9 @@ public class VirtualMachine extends PoolElement{
"boot",
"boot",
"boot",
"boot" };
"boot",
"clea",
"snap" };
/**
* Creates a new VM representation.
@@ -151,7 +156,54 @@ public class VirtualMachine extends PoolElement{
*/
public static OneResponse allocate(Client client, String description)
{
return client.call(ALLOCATE, description);
return allocate(client, description, false);
}
/**
* Allocates a new VM in OpenNebula.
*
* @param client XML-RPC Client.
* @param description A string containing the template of the vm.
* @param onHold False to create this VM in pending state, true on hold
* @return If successful the message contains the associated
* id generated for this VM.
*/
public static OneResponse allocate(Client client, String description,
boolean onHold)
{
return client.call(ALLOCATE, description, onHold);
}
/**
* Replaces the user template contents for the given VM.
*
* @param client XML-RPC Client.
* @param id The id of the target vm.
* @param new_template New template contents
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse update(Client client, int id, String new_template)
{
return client.call(UPDATE, id, new_template);
}
/**
* Resizes the VM capacity
*
* @param client XML-RPC Client.
* @param id The id of the target vm.
* @param cpu the new CPU value
* @param memory the new MEMORY value
* @param vcpu the new VCPU value
* @param enforce If it is set to true, the host capacity
* will be checked. This will only affect oneadmin requests, regular users
* resize requests will always be enforced
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse resize(Client client, int id,
double cpu, int memory, int vcpu, boolean enforce)
{
return client.call(RESIZE, id, cpu, memory, vcpu, enforce);
}
/**
@@ -303,6 +355,19 @@ public class VirtualMachine extends PoolElement{
return client.call(DETACHNIC, id, nicId);
}
/**
* Renames this VM
*
* @param client XML-RPC Client.
* @param id The VM id of the target VM.
* @param name New name for the VM.
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse rename(Client client, int id, String name)
{
return client.call(RENAME, id, name);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@@ -320,6 +385,21 @@ public class VirtualMachine extends PoolElement{
return response;
}
/**
* Initiates the instance of the VM on the target host.
*
* @param hostId The host id (hid) of the target host where
* the VM will be instantiated.
* @param enforce If it is set to true, the host capacity
* will be checked, and the deployment will fail if the host is
* overcommited. Defaults to false
* @return If an error occurs the error message contains the reason.
*/
public OneResponse deploy(int hostId, boolean enforce)
{
return client.call(DEPLOY, id, hostId, enforce);
}
/**
* Initiates the instance of the VM on the target host.
*
@@ -329,7 +409,7 @@ public class VirtualMachine extends PoolElement{
*/
public OneResponse deploy(int hostId)
{
return client.call(DEPLOY, id, hostId);
return deploy(hostId, false);
}
/**
@@ -367,11 +447,14 @@ public class VirtualMachine extends PoolElement{
* the vm.
* @param live If true we are indicating that we want livemigration,
* otherwise false.
* @param enforce If it is set to true, the host capacity
* will be checked, and the deployment will fail if the host is
* overcommited. Defaults to false
* @return If an error occurs the error message contains the reason.
*/
public OneResponse migrate(int hostId, boolean live)
public OneResponse migrate(int hostId, boolean live, boolean enforce)
{
return client.call(MIGRATE, id, hostId, live);
return client.call(MIGRATE, id, hostId, live, enforce);
}
/**
@@ -538,6 +621,44 @@ public class VirtualMachine extends PoolElement{
return detachnic(client, id, nicId);
}
/**
* Renames this VM
*
* @param name New name for the VM.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse rename(String name)
{
return rename(client, id, name);
}
/**
* Replaces this VM's user template contents.
*
* @param new_template New template contents
* @return If an error occurs the error message contains the reason.
*/
public OneResponse update(String new_template)
{
return client.call(UPDATE, id, new_template);
}
/**
* Resizes this VM's capacity
*
* @param cpu the new CPU value
* @param memory the new MEMORY value
* @param vcpu the new VCPU value
* @param enforce If it is set to true, the host capacity
* will be checked. This will only affect oneadmin requests, regular users
* resize requests will always be enforced
* @return If an error occurs the error message contains the reason.
*/
public OneResponse resize(double cpu, int memory, int vcpu, boolean enforce)
{
return client.call(RESIZE, id, cpu, memory, vcpu, enforce);
}
// =================================
// Helpers
// =================================
@@ -680,6 +801,24 @@ public class VirtualMachine extends PoolElement{
return action("unresched");
}
/**
* Migrates the virtual machine to the target host (hid).
* <br/>
* It does the same as {@link VirtualMachine#migrate(int, boolean)}
* with live set to false.
*
* @param hostId The target host id (hid) where we want to migrate
* the vm.
* @param enforce If it is set to true, the host capacity
* will be checked, and the deployment will fail if the host is
* overcommited. Defaults to false
* @return If an error occurs the error message contains the reason.
*/
public OneResponse migrate(int hostId, boolean enforce)
{
return migrate(hostId, false, enforce);
}
/**
* Migrates the virtual machine to the target host (hid).
* <br/>
@@ -695,6 +834,25 @@ public class VirtualMachine extends PoolElement{
return migrate(hostId, false);
}
/**
* Performs a live migration of the virtual machine to the
* target host (hid).
* <br/>
* It does the same as {@link VirtualMachine#migrate(int, boolean)}
* with live set to true.
*
* @param hostId The target host id (hid) where we want to migrate
* the vm.
* @param enforce If it is set to true, the host capacity
* will be checked, and the deployment will fail if the host is
* overcommited. Defaults to false
* @return If an error occurs the error message contains the reason.
*/
public OneResponse liveMigrate(int hostId, boolean enforce)
{
return migrate(hostId, true, enforce);
}
/**
* Performs a live migration of the virtual machine to the
* target host (hid).
@@ -708,7 +866,7 @@ public class VirtualMachine extends PoolElement{
*/
public OneResponse liveMigrate(int hostId)
{
return migrate(hostId, true);
return liveMigrate(hostId, false);
}
public int state()
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -38,6 +38,7 @@ public class VirtualNetwork extends PoolElement{
private static final String UPDATE = METHOD_PREFIX + "update";
private static final String HOLD = METHOD_PREFIX + "hold";
private static final String RELEASE = METHOD_PREFIX + "release";
private static final String RENAME = METHOD_PREFIX + "rename";
/**
* Creates a new virtual network representation.
@@ -263,7 +264,7 @@ public class VirtualNetwork extends PoolElement{
* Replaces the VirtualNetwork template contents.
*
* @param client XML-RPC Client.
* @param id The user id of the target vnet we want to modify.
* @param id The vnet id of the target vnet we want to modify.
* @param new_template New template contents.
* @return If successful the message contains the vnet id.
*/
@@ -272,6 +273,19 @@ public class VirtualNetwork extends PoolElement{
return client.call(UPDATE, id, new_template);
}
/**
* Renames this VirtualNetwork
*
* @param client XML-RPC Client.
* @param id The VirtualNetwork id of the target VirtualNetwork.
* @param name New name for the VirtualNetwork.
* @return If an error occurs the error message contains the reason.
*/
public static OneResponse rename(Client client, int id, String name)
{
return client.call(RENAME, id, name);
}
// =================================
// Instanced object XML-RPC methods
// =================================
@@ -491,6 +505,17 @@ public class VirtualNetwork extends PoolElement{
return update(client, id, new_template);
}
/**
* Renames this VirtualNetwork
*
* @param name New name for the VirtualNetwork.
* @return If an error occurs the error message contains the reason.
*/
public OneResponse rename(String name)
{
return rename(client, id, name);
}
// =================================
// Helpers
// =================================
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+13 -4
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -157,6 +157,8 @@ public class AclTest
"* 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 = {
@@ -165,7 +167,9 @@ public class AclTest
0x20000006bL,
0x400000000L,
0x100000929L,
0x200000007L
0x200000007L,
0x400000000L,
0x20000006bL
};
long[] resources = {
@@ -174,7 +178,9 @@ public class AclTest
0x28200000064L,
0x29200000064L,
0x29400000000L,
0x2200000064L
0x2200000064L,
0x102800000064L,
0x4800000064L
};
long[] rights = {
@@ -183,7 +189,9 @@ public class AclTest
0x1L,
0x9L,
0x9L,
0x3L
0x3L,
0x3L,
0x1L
};
for( int i = 0; i < rules.length; i++ )
@@ -254,6 +262,7 @@ public class AclTest
"#3 TEMPLATE+HOS/#0 USE",
"#3 /#0 USE",
"#3 TEMPLATE/# USE",
"#3 TEMPLATE/% USE",
"#3 TEMPLATE/#5 USE CREATE",
"#3 TEMPLATE/#5",
"#3 ",
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+21 -7
View File
@@ -1,12 +1,12 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
*
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* 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.
@@ -17,6 +17,7 @@ import static org.junit.Assert.*;
import org.junit.Test;
import org.opennebula.client.*;
import org.w3c.dom.Node;
public class SessionTest {
@@ -51,7 +52,7 @@ public class SessionTest {
}
assertNull("Client should complain about misspelled url", oneClient);
}
}
@Test
public void version()
@@ -63,11 +64,24 @@ public class SessionTest {
}
catch (Exception e)
{
System.out.println(e.getMessage());
assertTrue( e.getMessage(), false );
}
OneResponse res = oneClient.get_version();
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 );
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+11 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -341,4 +341,14 @@ public class VirtualMachineTest
res = vm.info();
assertTrue( res.getErrorMessage(), !res.isError() );
}
@Test
public void resize()
{
res = vm.resize(2.5, 512, 0, true);
assertTrue( res.getErrorMessage(), !res.isError() );
res = vm.resize(1, 128, 2, false);
assertTrue( res.getErrorMessage(), !res.isError() );
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org)
* Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# 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 #
+1 -1
View File
@@ -1,7 +1,7 @@
#!/bin/bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs #
# #
# 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 #