Previous page

Next page

Locate page in Contents

Managing Parallels Service Preferences

Parallels Service preferences is a set of configuration parameters that control its behavior. The most important parameters are:

  • Parallels Service memory limits.
  • Virtual machine memory limits and recommended values.
  • Virtual network adapter information.
  • Default virtual machine directory (the directory where all new virtual machines are created by default).
  • Minimum allowed communication security level.

To obtain the preferences information use the prlsdkapi.Server.get_common_prefs method. This is an asynchronous method. The preferences information is obtained from the Result object and is returned as an instance of the prlsdkapi.DispConfig class. Once you obtain the instance, you can use its methods to view and modify individual settings. Parallels Service preferences modifications are performed in a transactional manner. First you have to invoke the Server.common_prefs_begin_edit method to mark the beginning of the modification operation (i.e "begin a transaction"). This will timestamp the operation to prevent a conflict with other programs trying to make modifications to the same data at the same time. When you are done making the changes, invoke the Server.common_prefs_commit method to commit the changes to the Parallels Service. If there's a conflict, the method will throw an exception and your commit will be aborted. In such a case, you will have to re-evaluate the data and repeat the steps from the beginning. On success, the changes will be saved on the Parallels Service side.

Example

"""

    This function shows how to view and modify Parallels Service preferences.

    @param server: An instance of prlsdkapi.Server identifying the

                   Parallels Service.

"""

def srv_preferences_management(server):

  

    print ""

    print "Parallels Service Preferences Management"

    print "------------------------------------------"

  

    # The preferences info is obtained as a prlsdkapi.DispConfig object.

    try:

        result = server.get_common_prefs().wait()

    except prlsdkapi.PrlSDKError, e:

        print "Error: %s" % e

        return

  

    disp_config = result.get_param()

    

    # Obtain the default virtual machine directory.

    print "Default virtual machine directory: " + \

           disp_config.get_default_vm_dir()

  

    # The minimum allowed security level.

    # This setting ensures that the communication security level

    # specified at login satisfies the necessary requirements.

    security_level = disp_config.get_min_security_level()

    

    if security_level == consts.PSL_LOW_SECURITY:

        security_level = "Low"

    elif security_level == consts.PSL_NORMAL_SECURITY:

        security_level = "Normal"

    elif security_level == consts.PSL_HIGH_SECURITY:

        security_level = "High"

        

    print "Currently set minimum security level: " + security_level

        

    # Modify the minimum security level.

    # First, mark the beginning of the editing operation (required step).

    try:

        server.common_prefs_begin_edit().wait()

    except prlsdkapi.PrlSDKError, e:

        print "Error: %s" % e

        return

  

    # Set the new security level value.

    new_level = consts.PSL_HIGH_SECURITY

    disp_config.set_min_security_level(new_level)

  

    # Commit the changes.

    try:

        server.common_prefs_commit(disp_config).wait()

    except prlsdkapi.PrlSDKError, e:

        print "Error: %s" % e

        return

    

    print "Minimum security was set to High."