Chaining Together XAPI Commands

Home Forums Miscellaneous Tutorials Working With UUID’s Chaining Together XAPI Commands

Viewing 0 reply threads
  • Author
    Posts
    • #705
      Eric Pretorious
      Keymaster

      While I was working out the answer to a question in the Citrix XenServer forums (i.e., the exact steps required to bond a second PIF to the PIF that function as the hosts’s Primary Management Interface), I realized that this sequence of steps is an ideal opportunity to illustrate the technique of chaining together commands to create a pipeline as I’d demonstrated in the tutorial. To begin…

      First: We’ll inspect the PIF’s (i.e., NIC’s) installed on the host…

      [root@xs-1 ~]# xe pif-list params=uuid,device
      uuid ( RO) : 71cedeec-b567-c4a3-bf2d-db4c4c7ac31e
      device ( RO): eth1

      uuid ( RO) : 90813c90-c3de-8608-8812-e29bb60defb7
      device ( RO): eth4

      uuid ( RO) : 5616cfb5-98d1-1048-62d4-b96f6c9b17c6
      device ( RO): eth3

      uuid ( RO) : 6cdc6fc7-c622-67f3-1fde-2712e61ba963
      device ( RO): eth5

      uuid ( RO) : 44ef64b8-ea74-02d2-702e-821945919ef1
      device ( RO): eth2

      uuid ( RO) : 3bc3b502-104a-39ef-13e1-b73bda1d7046
      device ( RO): eth0

      Then: We’ll inspect the networks established on the host…

      [root@xs-1 ~]# xe network-list params=uuid,name-label
      uuid ( RO) : 92f924ae-cb1e-be8e-e8bb-6cabfeca96d4
      name-label ( RW): Pool-wide network associated with eth1

      uuid ( RO) : 3df639c9-9558-078b-b693-44fd42991683
      name-label ( RW): Pool-wide network associated with eth0

      uuid ( RO) : ba8d899a-ec90-9cae-bc5a-c6db107bb06a
      name-label ( RW): Host internal management network

      uuid ( RO) : cd049c97-f0e7-3bea-4710-42627e52eaeb
      name-label ( RW): Pool-wide network associated with eth4

      uuid ( RO) : 7ec5297b-b632-43d0-20a2-26e0008588da
      name-label ( RW): Pool-wide network associated with eth2

      uuid ( RO) : 496a92ea-6bf8-90fe-6382-844116567253
      name-label ( RW): Pool-wide network associated with eth3

      uuid ( RO) : 9b8bf61e-ecfc-6af1-4113-eed8a050ef2a
      name-label ( RW): Pool-wide network associated with eth5

      Finally: We’ll begin the sequence of steps to bond the PIF “eth3” together with the PIF that is currently serving as the Primary Management Interface (PMI), “eth0″…

      Legend: GET | SEE | USE

      [root@xs-1 ~]# IP_ADDR=$(xe host-param-get param-name=address uuid=$INSTALLATION_UUID)
      [root@xs-1 ~]# echo $IP_ADDR
      172.16.0.10

      [root@xs-1 ~]# PMI_DEV_NAME=$(xe pif-list IP=$IP_ADDR params=device | awk ‘{ print $5 }’)
      [root@xs-1 ~]# echo $PMI_DEV_NAME
      eth0

      [root@xs-1 ~]# PMI_DEV_UUID=$(xe pif-list IP=$IP_ADDR params=uuid | awk ‘{ print $5 }’)
      [root@xs-1 ~]# echo $PMI_DEV_UUID
      3bc3b502-104a-39ef-13e1-b73bda1d7046

      [root@xs-1 ~]# OTHER_DEV_NAME=$(xe pif-list device=eth3 params=device | awk ‘{ print $5 }’)
      [root@xs-1 ~]# echo $OTHER_DEV_NAME
      eth3

      [root@xs-1 ~]# OTHER_DEV_UUID=$(xe pif-list device=eth3 params=uuid | awk ‘{ print $5 }’)
      [root@xs-1 ~]# echo $OTHER_DEV_UUID
      5616cfb5-98d1-1048-62d4-b96f6c9b17c6

      [root@xs-1 ~]# MGT_NET_UUID=$(xe network-create name-label=MGT)
      [root@xs-1 ~]# echo $MGT_NET_UUID
      cfe77583-f04b-5cf9-2f95-31683ca900d0

      [root@xs-1 ~]# xe bond-create network-uuid=$MGT_NET_UUID pif-uuids=$PMI_DEV_UUID,$OTHER_DEV_UUID mode=active-backup
      40f900d4-81a9-3f53-a154-8f0fa33ba7c7

      Afterwards: We can inspect the bond and the IP configuration of the bond…

      Legend: GET | SEE | USE

      [root@xs-1 ~]# xe bond-list params=
      uuid ( RO) : 40f900d4-81a9-3f53-a154-8f0fa33ba7c7
      master ( RO): b79fa99a-c416-8852-8ca9-58b7bf9875aa
      slaves ( RO): 5616cfb5-98d1-1048-62d4-b96f6c9b17c6; 3bc3b502-104a-39ef-13e1-b73bda1d7046
      mode ( RO): active-backup
      properties (MRO):
      primary-slave ( RO): 3bc3b502-104a-39ef-13e1-b73bda1d7046
      links-up ( RO): 2

      [root@xs-1 ~]# ip address
      1: lo: mtu 65536 qdisc noqueue state UNKNOWN
      link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
      inet 127.0.0.1/8 scope host lo
      valid_lft forever preferred_lft forever
      15: xenbr2: mtu 1500 qdisc noqueue state UNKNOWN
      link/ether 00:26:55:d1:e8:cc brd ff:ff:ff:ff:ff:ff
      inet 172.16.0.35/28 brd 172.16.0.47 scope global xenbr2
      valid_lft forever preferred_lft forever
      16: xapi4: mtu 1500 qdisc noqueue state UNKNOWN
      link/ether 00:1f:29:c4:9f:5c brd ff:ff:ff:ff:ff:ff
      inet 172.16.0.10/27 brd 172.16.0.31 scope global xapi4
      valid_lft forever preferred_lft forever

      In the end: The extra effort required to tease-out the exact information that will be needed for the change operations and store the information in meaningfully-named variables…

      • increases your ability to make configurations to XenServer (XS) quickly,
      • reduces the number of typographical errors, and
      • reduces brain-fatigue.

      I hope that you find these techniques useful and that you’ll be able to incorporate them into your XS administration skills to effectively and efficiently manage XS from the command-line.

Viewing 0 reply threads
  • You must be logged in to reply to this topic.