Article ID: 120594, created on Mar 18, 2014, last review on May 10, 2014

  • Applies to:
  • Virtuozzo
  • Virtuozzo hypervisor
  • Virtual Automation

Resolution

To change VM settings, first you need to get the current settings. It can be done with the following packet:

<packet>
    <target>vzpenvm</target>
    <dst>
        <host>91296ce5-ef45-dc4e-b062-96bcad1e9545</host>
    </dst>
    <data>
        <vzpenvm>
            <get_info>
                <eid>324285ff-a268-4ed6-94de-19718b973761</eid>
                <config/>
            </get_info>
        </vzpenvm>
    </data>
</packet>

where:

<host>91296ce5-ef45-dc4e-b062-96bcad1e9545</host> -- is the EID of the hardware node, stored in /var/opt/pva/agent/etc/eid
<eid>324285ff-a268-4ed6-94de-19718b973761</eid> -- is the UUID of the VM, as listed with prlctl list

You get a very detailed response, where you should capture the part with the network device.

Example:

<packet version="4.5.0" priority="0" type="0" time="2014-03-06T20:21:50+0000">
    <origin>91296ce5-ef45-dc4e-b062-96bcad1e9545</origin>
    <dst>
        <director>gend</director>
        <target>vzclient31-ebaa00cd-eda4-7140-a1cf-41993fe018bc</target>
    </dst>
        <data>
        <vzpenvm>
            <env>
            <parent_eid>91296ce5-ef45-dc4e-b062-96bcad1e9545</parent_eid>
            <eid>324285ff-a268-4ed6-94de-19718b973761</eid>
            <status>
                <state>3</state>
            </status>
            <alert>0</alert>
            <config/>
                <virtual_config>
                <type>parallels</type>
                ...
                <device>
                <connected>1</connected>
                <enabled>1</enabled>
                <emulation_type>5</emulation_type>
                <remote>0</remote>
                <sys_name></sys_name>
                <friendly_name>eth0</friendly_name>
                <description></description>
                <summary_info>Routed</summary_info>
                <is_bootable/>
                <is_boot_in_use/>
                <boot_sequence_index>2</boot_sequence_index>
                <device_index>0</device_index>
                <bound_adapter_name></bound_adapter_name>
                <bound_adapter_index>-1</bound_adapter_index>
                <virtual_network_id>Bridged</virtual_network_id>
                <pktfilterpreventmacspoof>0</pktfilterpreventmacspoof>
                <pktfilterpreventipspoof>0</pktfilterpreventipspoof>
                <pktfilterpreventpromisc>0</pktfilterpreventpromisc>
                <mac_address>00:1C:42:EA:B0:E5</mac_address>
                <adapter_type>2</adapter_type>
                <auto_apply>1</auto_apply>
                <default_gateway>10.39.1.1</default_gateway>
                <ip_address>
                    <netmask>255.255.0.0</netmask>
                    <ip>10.39.81.69</ip>
                </ip_address>
                <ip_address>
                    <netmask>255.255.0.0</netmask>
                    <ip>10.39.81.220</ip>
                </ip_address>
                <ip_address>
                    <netmask>255.255.0.0</netmask>
                    <ip>10.39.81.221</ip>
                </ip_address>
                <nameserver>10.39.1.1</nameserver>
                </device>
                <device>
                <connected>1</connected>
                <enabled>1</enabled>
                <emulation_type>2</emulation_type>
                <remote>0</remote>
                <sys_name></sys_name>
                <friendly_name>eth1</friendly_name>
                <description></description>
                <summary_info>Bridged Ethernet</summary_info>
                <is_bootable/>
                <is_boot_in_use/>
                <boot_sequence_index>3</boot_sequence_index>
                <device_index>1</device_index>
                <bound_adapter_name></bound_adapter_name>
                <bound_adapter_index>-1</bound_adapter_index>
                <virtual_network_id>Bridged</virtual_network_id>
                <pktfilterpreventmacspoof>1</pktfilterpreventmacspoof>
                <pktfilterpreventipspoof>1</pktfilterpreventipspoof>
                <pktfilterpreventpromisc>1</pktfilterpreventpromisc>
                <mac_address>00:1C:42:2B:AF:F5</mac_address>
                <adapter_type>2</adapter_type>
                <auto_apply>0</auto_apply>
                </device>
                ...
                </virtual_config>
            </env>
        </vzpenvm>
    </data>
    <src>
        <director>gend</director>
        <target>vzpenvm</target>
    </src>
    <target>vzclient31-ebaa00cd-eda4-7140-a1cf-41993fe018bc</target>
</packet>

Take the whole configuration that is enclosed in <device></device> for the appropriate network adapter.

Then, in order to add an IP address, <update_device> call can be used.

Here is an example of a packet that adds a second IP address for a VM with one network adapter.

<packet xmlns:ns1="http://www.swsoft.com/webservices/vzp/4.0.0/vzptypes" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <target>vzpenvm</target>
  <dst>
    <host>87c825d2-4785-db4b-bf2f-dd08ed7a9e4d</host>
  </dst>
  <data>
    <vzpenvm>
      <update_device>
        <eid>a71b347c-d7d7-7d47-ac4d-c9ce7da9444b</eid>
        <sys_name/>
        <device xsi:type="ns1:vm_network_device">          
          <connected>1</connected>
          <enabled>1</enabled>
          <emulation_type>5</emulation_type>
          <remote>0</remote>
          <friendly_name>Routed</friendly_name>
          <description/>
          <summary_info>Routed</summary_info>
          <is_bootable/>
          <boot_sequence_index>3</boot_sequence_index>
          <device_index>0</device_index>
          <bound_adapter_name>Default Adapter</bound_adapter_name>
          <bound_adapter_index>-1</bound_adapter_index>
          <virtual_network_id>Bridged</virtual_network_id>
          <pktfilterpreventmacspoof>0</pktfilterpreventmacspoof>
          <pktfilterpreventipspoof>0</pktfilterpreventipspoof>
          <pktfilterpreventpromisc>1</pktfilterpreventpromisc>
          <mac_address>00:1C:42:ED:53:2B</mac_address>
          <adapter_type>2</adapter_type>
          <auto_apply>1</auto_apply>
          <default_gateway>10.39.1.1</default_gateway>
          <ip_address>
            <netmask>255.255.0.0</netmask>
            <ip>10.39.82.51</ip>
          </ip_address>
          <ip_address>
            <netmask>255.255.0.0</netmask>
            <ip>10.39.81.15</ip>
          </ip_address>
          <nameserver>192.168.55.1</nameserver>
        </device>
      </update_device>
    </vzpenvm>
  </data>
</packet>

Few notes to the example above:

  1. The additions to the <packet> tag are important.
  2. We indicate the device type explicitly: <device xsi:type="ns1:vm_network_device">, it is a mandatory tag.
  3. Specify exactly the same <emulation_type> that is queried from get_info for this device.

To add an IP address, just add another <ip_address> section:

Before:

<ip_address>
    <ip>10.39.81.223</ip>
    <netmask>255.255.0.0</netmask>
</ip_address>

After:

<ip_address>
    <ip>10.39.81.223</ip>
    <netmask>255.255.0.0</netmask>
</ip_address>
<ip_address>
    <ip>10.39.81.224</ip>
    <netmask>255.255.0.0</netmask>
</ip_address>

If you need to remove an IP address, simply remove the corresponding section.

Search Words

get_info

packet

update_device

vzpenvm

XML API setting interface

virtual machine

a26b38f94253cdfbf1028d72cf3a498b 2897d76d56d2010f4e3a28f864d69223 319940068c5fa20655215d590b7be29b 0dd5b9380c7d4884d77587f3eb0fa8ef

Email subscription for changes to this article
Save as PDF