You can migrate an existing Container from one Hardware Node to another. The resulting Container is created as an exact copy of the source Container. To migrate a Container, the target Hardware Node must have Virtuozzo Containers software and Agent installed on it.
The following V2V (virtual-to-virtual) migration types are supported:
On successful migration, the original Container will no longer exist on the source node. This is done in order to avoid possible conflicts that may occur if both Containers -- the original and the copy -- are running at the same time. Although the original Container will no longer show up in the Container list on the source node, the Container data will not be deleted. By default, the data is kept in its original location (the Container private area) but the private area directory itself will be renamed. If you wish, you can completely remove the original Container data from the source node by including the options/remove
parameter in the request.
The name of the C# class that provides the migration functionality is relocatorBinding
. The XML API equivalent is the relocator
interface.
The following sample shows how to perform a V2V migration.
Sample Function Parameters:
Name |
Description |
|
The Server ID of the source Container. |
|
Migration type:
|
|
This and the rest of the parameters are the connection and login information that will be used to log in to the target Hardware Node. The target Hardware Node IP address. |
|
Port number. |
|
Communication protocol to use:
|
|
User name. The user must have sufficient rights to connect to the target Hardware Node. |
|
Realm ID. The ID of the authentication database against which to authenticate the specified user. In this example, we will be using the |
|
User password. |
Sample Function:
/// <summary>
/// Sample function Migrate.
/// Migrates a Container to a different Hardware Node.
/// </summary>
/// <param name="eid">The Server ID of the source Container.</param>
/// <param name="mn_type">Migration type.</param>
/// <param name="ip_address">Target HN IP address.</param>
/// <param name="port">Target HN port number.</param>
/// <param name="protocol">Communication protocol.</param>
/// <param name="username">
/// User name with which to login to the
/// target HN.
/// </param>
/// <param name="realm">
/// Realm ID on the target HN against which to authenticate the user.
/// </param>
/// <param name="password">User password.</param>
/// <returns>"OK" or error information.</returns>
///
public string Migrate(string eid, int migration_type, string ip_address, uint port, string protocol, string username, string realm, string password)
{
try {
relocatorBinding relocator = (relocatorBinding)binder.InitBinding(typeof(relocatorBinding));
migrate_v2v v2v_input = new migrate_v2v();
// Set Server ID of the source Container.
v2v_input.eid_list = new string[1];
v2v_input.eid_list[0] = eid;
/* Set migration type.
* The "options" member allows you to set other
* migration options. See Agent XML Reference
* for more info.
*/
v2v_input.options = new v2v_migrate_optionsType();
v2v_input.options.type = migration_type;
// Set the target Nardware Node connection info.
v2v_input.dst = new connection_infoType();
connection_infoType connection_parm = (connection_infoType)v2v_input.dst;
// Set the target Node IP address.
v2v_input.dst.address = ip_address;
// Set the port number.
v2v_input.dst.portSpecified = true;
v2v_input.dst.port = port;
// Set protocol.
v2v_input.dst.protocol = protocol;
// Set login parameters.
v2v_input.dst.login = new auth_nameType();
v2v_input.dst.login.name = System.Text.ASCIIEncoding.ASCII.GetBytes(username);
v2v_input.dst.login.realm = realm;
// Set user password.
v2v_input.dst.password = System.Text.ASCIIEncoding.ASCII.GetBytes(password);
// Set infinite timeout for the request.
relocator.Timeout = -1;
relocator.migrate_v2v(v2v_input);
return "OK";
}
catch (Exception e) {
return "Exception: " + e.Message;
}
}