Seed CloudStack Templates Offline

Not all clouds require or have Internet access. As a security policy, the guest instances could have public Internet access but the CloudStack management network itself has no access. Having basic Internet access would make it a lot easier to populate the built-in SSVM and CentOS templates during the build phase but its not an absolute must.

To seed the System VM templates manually:

  1. Download the appropriate templates for Xen, KVM or VMWare from download.cloud.com from a host which has Internet access. See Prepare the System VM Template section from the CloudStack Install guide for the download URLs
  2. scp the templates over to the CloudStack management server under the /tmp/ folder
  3. Ensure that all secondary storage shares are mounted on the management server
  4. Install the template by running the /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt along with the -f option as below:
    /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt \
    -m /mnt/cs-sec1 -f /tmp/acton-systemvm-02062012.vhd.bz2 -h xenserver -F
    

To seed the default CentOS templates:

  1. Download the appropriate CentOS templates from download.cloud.com make it available on a local HTTP server. The local HTTP server has to be reachable from the SSVM instances. The download URLs can be extracted from the the management database cloud using the following SQL query:
    mysql> select url from vm_template;
    +------------------------------------------------------------------------------------------+
    | url                                                                                      |
    +------------------------------------------------------------------------------------------+
    | http://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2                |
    | http://download.cloud.com/templates/builtin/f59f18fb-ae94-4f97-afd2-f84755767aca.vhd.bz2 |
    | http://download.cloud.com/templates/acton/acton-systemvm-02062012.qcow2.bz2              |
    | http://download.cloud.com/releases/2.2.0/eec2209b-9875-3c8d-92be-c001bd8a0faf.qcow2.bz2  |
    | http://download.cloud.com/templates/centos56-x86_64.vhd.bz2                              |
    | http://download.cloud.com/releases/2.2.0/CentOS5.3-x86_64.ova                            |
    | http://download.cloud.com/templates/burbank/burbank-systemvm-08012012.ova                |
    | http://download.cloud.com/templates/acton/acton-systemvm-02062012.vhd.bz2                |
    | NULL                                                                                     |
    | NULL                                                                                     |
    +------------------------------------------------------------------------------------------+
    10 rows in set (0.00 sec)
    
  2. Ensure that the network subnet for the local HTTP server is white listed via the CloudStack global setting secstorage.allowed.internal.sites
    cloudmonkey api updateConfiguration name=secstorage.allowed.internal.sites value=192.168.44.0/24
    
  3. Update the url column in the vm_template table to point to the local HTTP server. Preferably, use IP addresses in case you dont have local DNS resolution.
    mysql> UPDATE vm_template SET url='http://192.168.44.5/templates/centos56-x86_64.vhd.bz2' where id=5;
    Query OK, 0 rows affected (0.01 sec)
    Rows matched: 1  Changed: 0  Warnings: 0
    mysql> select url from vm_template where id=5;
    +-------------------------------------------------------+
    | url                                                   |
    +-------------------------------------------------------+
    | http://192.168.44.5/templates/centos56-x86_64.vhd.bz2 |
    +-------------------------------------------------------+
    1 row in set (0.00 sec)
    
    mysql> 
    
    
  4. Reboot SSVM instances and tail the management server logs for progress. The template should start downloading shortly
    2013-09-01 15:37:57,095 DEBUG [agent.transport.Request] (AgentConnectTaskPool-6:null)
    Seq 3-1176502277: Sending  { Cmd , MgmtId: 178527198316230, via: 3, Ver: v1, Flags: 100011,
    [{"storage.DownloadProgressCommand":{"jobId":"15e5e4a0-7edf-445b-be75-9b26774dd75b",
    "request":"GET_OR_RESTART","hvm":false,"description":"CentOS 5.6(64-bit) no GUI
    (XenServer)","checksum":"905cec879afd9c9d22ecc8036131a180","maxDownloadSizeInBytes":
    53687091200,"id":5,"resourceType":"TEMPLATE","url":"http://192.168.44.5/templates/
    centos56-x86_64.vhd.bz2","format":"VHD","accountId":1,"name":
    "centos56-x86_64-xen","secUrl":"nfs://192.168.44.5/volume1/cs-sec1","wait":0}}] }
    
  5. Ensure all management servers are bounced after updating global settings. Reboot the running SSVMs after bouncing the management servers

Things to watch out for:

  1. First update vm_template table and then the global settings. Ensure management servers are bounced. Reboot SSVM after bouncing the management servers
  2. Ensure the SSVM instances can indeed reach the local HTTP server hosting the templates
  3. Do a manual HTTP fetch of the template from the local HTTP server to verify download
  4. /usr/share/cloudstack-common/scripts/storage/secondary/cloud-install-sys-tmplt seems to be sensitive to the order in which the options are passed.

CentOS 5.6(64-bit) no GUI (XenServer)

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.

Leave a Reply