Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
titleUpload image to glance
glanceopenstack image-create --name <image_name> create --file <image_location> --disk-format raw --container-format bare --visibility public --progress 
openstack image create --file <image_location> --disk-format raw --container-format bare [--public|--private][--public|--private] <image_name>
# There is a bug where in some/most/many circumstances you will not be able to use --protected with the "image create" command. Workaround: Just set the protected flag after the image has been uploaded
openstack image set --protected <image_name>

For example, the following command would upload an ubuntu image:

Code Block
titleUpload image to glance
glanceopenstack image-create --name "Ubuntu Server 16.04 (Xenial) amd64" create --file xenial-server-cloudimg-amd64-disk1.img.raw --disk-format raw --container-format bare --is-public True --progress
openstack image create --file xenial-server-cloudimg-amd64-disk1.img.raw --disk-format raw --container-format bare --public"Ubuntu Server 16.04 (Xenial) amd64"
openstack image set --protected "Ubuntu Server 16.04 (Xenial) amd64"

The "–visibility public–publicflag is used to indicate that all projects should have access to this image, and the upload would then require admin credentials. In the case of an image upload which should only be accessible to the project uploading it, that flag can be omitted.

...

Code Block
titleguestfish
# Mounting the filesystem
:~$ sudo guestfish

Welcome to guestfish, the guest filesystem shell for
editing virtual machine filesystems and disk images.

Type: 'help' for help on commands
      'man' to read the manual
      'quit' to quit the shell

><fs> add ubuntu-16.04-server-cloudimg-amd64-disk1-bjarne.raw <path to image>
><fs> run
><fs> list-filesystems 
/dev/sda1: ext4
><fs> mount /dev/sda1 /

# Editing a file
><fs> vi /etc/fstab

#Copying in a file from outside the image
><fs> copy-in <file outside the image> <pat to where to put it inside it>image>

# Commiting and exiting guestfish. Exit does both
><fs> exit

 


Change existing images

 

Creating Windows Images

Cloudbase.it provides tools for creating OpenStack-ready cloud images. They've created a Windows Server 2012R2 images, which is ready for use (download and instructions here). This image is already imported into our environment.

If you need an another Windows Version, you must build the image yourself, with good help from the automated cloudbase-scripts. It is recommended to create the image on a Windows 10 host or VM. The following examples is a list of what we did to create a cloud ready Windows 10 image.

...

  1. UnattendTemplate.xml: Change InputLocale and UserLocale from en-US to nb-NO

  2. Added ntnu_wallpaper.png to the UnattendResources-folder
  3. UnattendResources\Specialize.ps1:
    1. Change the line with Wallpaper.png to ntnu_wallpaper.png (do not change the destination filename in the copy-command, as the wallpaper is set through an imported local GPO)
  4. UnattendResources\Logon.ps1:
    1. Add the following to commands: netsh advfirewall firewall add rule name="All ICMP V4" protocol=icmpv4:any,any dir=in action=allow and netsh advfirewall firewall add rule name="All ICMP V6" protocol=icmpv6:any,any dir=in action=allow

...

Code Block
languagepowershell
titleCreateOpenStackImage.ps1
linenumberstrue
Import-Module .\windows-openstack-imaging-tools-master\WinImageBuilder.psm1
$virtualDiskPath = "C:\path\to\diskfile.raw"
$wimFilePath     = "<windowsiso-mountpoint>\sources\install.wim>"
$virtIOISOPath   = "C:\path\to\virtio-win-x.x.xxx.iso"
$images = Get-WimFileImagesInfo -WimFilePath $wimFilePath
$image = $images[0]
New-WindowsCloudImage -WimFilePath $wimFilePath -ImageName $image.ImageName -VirtualDiskFormat RAW -VirtualDiskPath $virtualDiskPath -SizeBytes 18GB -VirtIOISOPath $virtIOISOPath -InstallUpdates

You now have a .raw diskfile, which contains a Windows 10-installation that will automatically run sysprep once booted. Now you have to choices:

...

images

...

When you spawn a Windows instance, be sure to attach a keypair. Cloudbase-init will generate a random password for the user Admin, which can be retrieved with:

Code Block
titleRetrieve admin-password
nova get-password <instance-id> <private-key-file>

NOTE: There is a known issue with Windows 10 - the hostname will not be set to wahtever you chose for instance name. This might be fixed in the future... (Link)

...