Previous page

Next page

Locate page in Contents

Print this page

Retrieving Host Configuration Info

The Parallels Python API provides a set of functions to retrieve detailed information about a host machine. This includes:

This information can be used when modifying Parallels Service preferences, setting up devices inside virtual machines, or whenever you need to know what resources are available on the physical host.

"""

    The following function demonstrates how to obtain the

    host configuration information.

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

"""

def host_configuration_info(server):

    

    # Obtain an object of type prlsdkapi.SrvConfig.

    srv_config = server.server_config

    try:

        srv_config.wait()

    except prlsdkapi.PrlSDKAsyncError, e:

        print "Unable to obtain host configuration: %s" % e

  

    # Get CPU count.

    print "CPU count: " + str(srv_config.cpu_count)

  

    # Get OS information.

    print "OS version: " + srv_config.os_version['full']

  

    # Get RAM size.

    print "RAM size: " + str(srv_config.ram_size)

  

    # Get the network adapter info.

    # The type of the netd object is prlsdkapi.SrvCfgNet.

    adapter_type = ""

    status = ""

    ctr = 0

    print "Network adapters: "

    for netd in srv_config.net_adapters:

        ctr = ctr + 1

        if netd.net_adapter_type == prlsdk.consts.PHI_REAL_NET_ADAPTER:

            adapter_type = "Physical adapter"

        elif netd.net_adapter_type == prlsdk.consts.PHI_VIRTUAL_NET_ADAPTER:

            adapter_type = "Virtual adapter"

  

        if netd.enabled == 1:

            status = "enabled"

        else:

            status = "disabled"

            

        print " " + str(ctr) + ". " + adapter_type + ", " + status + ", " + str(netd.sys_index)

Please send us your feedback on this help page