Previous page

Next page

Locate page in Contents

Print this page

Cloning a Virtuozzo Container

Cloning refers to a process of creating an exact copy (or multiple copies) of a Virtuozzo Container on the same Hardware Node. The new Container will have its own private area and root directories but the rest of the configuration parameters will be exactly the same. This means that even the parameters that should be unique for each individual Container (IP addresses, hostname, name) will be copied unchanged. You don't have an option to specify new values during the cloning operation. Instead, you will have to clone the Container first and then update the configuration of the new Container(s) in a separate procedure. There are a few exceptions to this rule. You can optionally specify custom private area and root directories for the new Container, but only if you are creating a single copy of the source Container. You also have an option to specify custom Container ID for each clone. If you don't want to set these options manually, their values will be selected automatically.

You can clone both running and stopped Containers. There are a few differences when cloning Containers on Windows and Linux platforms:

Linux On Linux, running source Container will be suspended momentarily during the cloning operation. This is done in order to eliminate possible changes to the Container state and status. Once all the data is read from the source Container, the Container is resumed and the cloning operation proceeds normally.

WindowsOn Windows, a snapshot of the source Container is taken on the fly, so the Container operation is never interrupted during cloning.

The following sample illustrates how to clone an existing Container. The name of the C# class that provides the cloning functionality is relocatorBinding (stepping ahead, this class also provides the Container migration functionality that we'll discuss in the following section). The XML API equivalent of the class is the relocator interface.

Sample Function Parameters:

Name

Description

eid

The Server ID of the Container to clone.

count

The number of clones to create.

Sample Function:

/// <summary>

/// Sample function CloneCT.

/// Create an exact copy of the specified Container.

/// </summary>

/// <param name="eid">The Server ID of the source Container.</param>

/// <param name="count">Number of copies to create.</param>

/// <returns>Server IDs of the new Virtuozzo Containers.</returns>

///

public string[] CloneCT(string eid, int count)

{

    cloneResponse response;

    

    try {

        // Instantiate the proxy class

        relocatorBinding relocator = (relocatorBinding)binder.InitBinding(typeof(relocatorBinding));

    

        // The main input parameter.

        clone clone_input = new clone();

    

        // Set Server ID of the source Countainer.

        clone_input.eid = eid;

    

        // Number of copies to create.

        clone_input.count = 1;

    

        // Clone the Container(s).

        response = relocator.clone(clone_input);

    }

    catch (Exception e) {

        response = new cloneResponse();

        response.eid_list[0] = "Exception: " + e.Message;

        return response.eid_list;

    }

    return response.eid_list;

}

Please send us your feedback on this help page