Changing XenServer Host Passwords In CloudStack

Most of us have a business requirement to change system passwords regularly and when we do, it usually ends up in a mess. Thankfully, Apache CloudStack has an API that allows you to modify XenServer host passwords without mucking around the database and encryption.

The API to change XenServer host password is updateHostPassword which you can use via CloudMonkey CLI tool. The steps to change the XenServer password would roughly be as below:

  1. Login to XenCentre and change the pool passwordScreen Shot 2014-06-20 at 11.16.47 am
  2. Via the CloudMonkey CLI tool, update host password by specifying the clusterid and hostid of all the hosts in the pool.
    $ cloudmonkey update hostpassword hostid=efc7f959-d20f-4946-b187-9ba048145c45 clusterid=e8121b66-7de2-4518-a753-5b5decefb841 username=root password=change_this
    
  3. Restart all CloudStack management servers

Below is a little script get_host_uuid.sh to fetch cluster ids and host ids of all XenServer hosts in CloudStack using the CloudMonkey CLI tool.

[root@csman11 ~]# cat get_host_uuid.sh 
#!/bin/bash

cli=`which cloudmonkey`

password=change_this

hosts=`$cli list hosts hypervisor=XenServer|awk -F' = ' '/^name/{print $2}'`

for aa in ${hosts}; do
  clusterid=`$cli list hosts name=${aa} | awk -F" = " '/^clusterid/{print $2}'`
  hostid=`$cli list hosts name=${aa} | awk -F" = " '/^id/{print $2}'`
  echo $cli update hostpassword hostid=${hostid} clusterid=${clusterid} username=root password=${password}
done
[root@csman11 ~]# 

Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract. Please use the Contact Form for any enquiry.

More Posts - Website

Follow Me:
TwitterLinkedIn

Published by

Shanker Balan

Shanker Balan is a devops and infrastructure freelancer with over 14 years of industry experience in large scale Internet systems. He is available for both short term and long term projects on contract. Please use the Contact Form for any enquiry.

One thought on “Changing XenServer Host Passwords In CloudStack”

  1. I have a issue on Cloudstack with advanced networking on xenserver.
    Upon confiuration of Adv networking in cloudstack, it created a VLAN tag in xenserver, that can be seen through xencenter (snapshot attached). Now which ever the VMs as this network, VM can not contact dhcp or anything on network.

    I have a vlan that is configured on Switch, say VLAN 140, and the same is configured on Xenserver.

    # brctl show
    xapi1 8000.f8bc124c1e07 no eth3.140
    vif6.0
    vif7.0
    vif8.0
    xenbr3 8000.f8bc124c1e07 no eth3
    vif1.0
    vif2.1

    My issue is, whenever a VM have xapi1 network, VM can not reach gateway.
    But when i am using xenbr3, vm can get IP address and can ping internet as well.

    Please provide your valuable feedback.

    NOTE: Screen shots in links.
    https://goo.gl/photos/8Vf7GZRBm7rjsDdY8
    https://goo.gl/photos/bSHfuFBhTRZZ6uzj8
    https://goo.gl/photos/Ukf3gXKH98d9pdvH7
    https://goo.gl/photos/HA5EhubHeDmcQ2is9

Leave a Reply