Previous page

Next page

Locate page in Contents

Retrieving Host Configuration Info

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

  • CPU(s) -- number of, mode, model, speed.
  • Memory (RAM) size.
  • Operating system -- type, version, etc.
  • Devices -- disk drives, network interfaces, ports, sound.

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 information is obtained using the get_srv_config method of the prlsdkapi.Server class. This is an asynchronous method, so the information is returned via the Job and Result objects (see the Asynchronous  Methods section for more information). The name of the class containing the host configuration information is prlsdkapi.ServerConfig.

Example

"""

    This function demonstrates how to obtain the

    host computer configuration information.

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

                   Parallels Service.

"""

def get_host_configuration_info(server):

  

    print ""

    print "Host Configuration Information"

    print "====================================="

  

    # Obtain an instance of prlsdkapi.ServerConfig containing the

    # host configuration information.

    try:

        result = server.get_srv_config().wait()

    except prlsdkapi.PrlSDKError, e:

        print "Error: %s" % e

  

    srv_config = result.get_param()

  

    # Get CPU count and model.

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

    print "CPU model: " + srv_config.get_cpu_model()

    print "VT-d support: " + str(int(srv_config.is_vtd_supported()))

    

    # Get RAM size.

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

  

    # Get the network adapter info.

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

    print ""

    print "Network adapters"

    print ""

    print "No.  Type             Status   System Index"

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

  

    for i in range(srv_config.get_net_adapters_count()):

        hw_net_adapter = srv_config.get_net_adapter(i)

        adapter_type = hw_net_adapter.get_net_adapter_type()

        

        if adapter_type == consts.PHI_REAL_NET_ADAPTER:

            adapter_type = "Physical adapter"

        elif adapter_type == consts.PHI_VIRTUAL_NET_ADAPTER:

            adapter_type = "Virtual adapter"

        elif adapter_type == consts.PHY_WIFI_REAL_NET_ADAPTER:

            adapter_type = "Wi-Fi adapter"            

  

        if hw_net_adapter.is_enabled():

            status = "enabled"

        else:

            status = "disabled"

            

        print " " + str(i+1) + ". " + adapter_type + "  " + \

                  status + "  " + str(hw_net_adapter.get_sys_index())