Automated Android OS deployment with openQRM IaaS Cloud

From openQRM
Revision as of 10:11, 2 November 2020 by Stvsyf (talk | contribs)

This HowTo is about how to provide Android system "on demand" with a private openQRM Cloud.

Requirements

  • One physical Server - at least 1 GB of Memory
  • at least 100 GB of Diskspace
  • VT (Virtualization Technology) enabled in the Systems BIOS so that the openQRM Server can run Virtual Machines later
Please notice!

The Android OS support in openQRM is only available in the openQRM Enterprise Edition >= 5.1.4!

If you are interested in this feature please contact us for a free openQRM Enterprise evaluation edition!

Install openQRM

A detailed Howto about the above initial starting point is available at 'Install openQRM on Debian', and 'Cloud Computing with openQRM on Debian.

For this howto we assume you have successfully made it through Cloud Computing with openQRM on Debian.

Please notice!

For this Howto we have used an additional physical System as a KVM Virtualization host, simply integrated in openQRM via the "local-server" plugin. The setup is also possible If you have just one system and use the openQRM server itself as the KVM Host.

Here the fully installed openQRM server

As install prepartion please login to your KVM Host as "root" and execute the following commands to download the android-x86-4.4-RC2.iso installation iso file for the Android installation in a VM.

mkdir /iso
cd /iso
wget -O android-x86-4.4-RC2.iso sourceforge.net/projects/android-x86/files/Release%204.4/android-x86-4.4-RC2.iso/download


We now start by creating a new server for the Android OS installation. The image of this server is later used as a "master-image" for the openQRM Cloud. Please go to:

Datacenter -> Server

and click on "Add new server". Provide a name (here "android44) and a description.

In the second server wizard step please select "New resource"

Select the type of Virtual Machine you would like to create. Here we choose "KVM VM (localboot).

Now select your KVM Host. In the VM overview please click on "Add local VM".

In the create VM form please select at least 2 GB memory. Also make sure you set the "Disk interface" for the virtual disk image to "IDE" (virtio support in Android is still experimental).

You can leave the "Network card type" to "virtio". This will work fine even without the virtio support in the Android OS.

Further down in the VM create form select to boot from an ISO image and use the file-picker to pick the ISO file to boot from on the KVM Host. Also provide a VNC password and adjust the vnc-keymapping to your needs. Then click on "submit".

The next step will continue with the server wizard. Simply select the newly created VM resource.

When configuring the image for the server please click on "new image".

In the image type selection choose "LVM deployment for KVM".

Now please select the KVM storage from the type "KVM LVM Storage".

This presents an overview about all the existing LVM volume groups on this storage. Please select one volume group to create the new image on. Here we choose the "lvols" LVM volume group.

If you haven't setup LVM on your KVM storage Host yet click on "add volume group" which will open up the device-manger plugin to setup and manage the attached storage devices with LVM.

In the LVM volume overview please click on "add new logical volume".

In the "create volume" form please provide the volume size (in MB). Here we go with 2000 MB which is sufficiant to install the Android OS.

The volume size is fully adjustable and provides an automated LVM-resize and filesytem resize for the first partition of the volume. This functionality is also available for "snap" and "clone" actions. Please notice that due to the technical implementation of LVM, snapshots can only be resized smaller or equal to the "master volume" while the LVM clone action allows resizing to a bigger size than the "master".

For Cloud deployment the preferred deployment action (snap or clone) can be configured in the KVM plugins configuration options in the plugin manager.

Creating the new volume and its image object in openQRM continues with the server wizard. Please click on submit on the pre-selected just created image.

In the "image edit" section you can set a custom password for the image console- and ssh login. Please notice that for Windows OS installation on an image the image type should be set to "windows" instead of "linux".

The previous action finalizes the server wizard and forwards to the server list. Click on the "start" button of the new created server.

Just for info:

Starting a server will "combine" the "resource" with the "image" configured in the "server". Stopping a "server" will automatically "separate" the "image" from the "resource". That way each of the objects in openQRM become completely indepent from each other and e.g. can be re-combined with diffrent or updated sub-objects. Also this makes it very straight forward to e.g. restart an "image" with a diffrent "resource" (even with a different resource type in case of P2V/V2P) in case of a automatic high-availability fail-over event.

Please confirm starting the server.

When the server is started please click on the "NoVNC" in the server action tab. This will open up a VNC console in the web-browser and allows to install the Android OS.

Here the VNC console of the VM. In the Grub menu of the starting VM booting from the Android installation iso please select the last option "Installation - install Androidx86 to harddisk" and press return.

When the installer starts please select "create/modify partitions"

Select "new" to create a new partition.

Select "primary".

Make sure to set the "bootable" flag.

Now select "write" and confirm to setup the partition.

Back in the Android installer select the just created new partition sda1.

Please select "ext3" as the filesystem type for this partition.

Confirm with "Yes" to create the filesystem.

Also select "Yes" when the installer asks if to install the grub boot-manager.

In the following dialog also select "Yes" for making the system partition of the Android OS read+writeable. This is usefull (and needed) to adjust the Android image later.

When the Android installation is finished please select "reboot".

Please remember that the VM configuration is still set to boot from the installation iso!

Therefore it is now recommended to stop the automated boot of the Android installation iso since this will boot into a live-system from the iso but not from the disk.

We are going to update the VM configuration to boot from local disk in the next step.

In the server list please stop the server.

Confirm stopping the server.

Now please go to

Plugins -> Virtualization -> KVM -> VMs

select the KVM Host and click on "edit"

In the VM overview please click on "update" of the server's VM.

Now set the boot sequence to boot from "local" and click on submit. After that please go back to the server list and start the server. When the server is started click again on the "NoVNC" action button of the server.

Here the first boot screen of the Android OS running in the KVM VM.

In the Wifi selection please click on "skip".

In the "Got Google" dialog please click on "No" and "remind me later".

In the next "Google location" dialog use the right arrow to go on.

Set date and time.

And create a user.

The Android OS will now further boot up.

Here the Android startup screen. Go to the application by the middle button in the Android UI.

Click on the "terminal emulator" app icon to start a terminal session.

In the terminal you can use "su" to get root access.

Please follow the next steps to configure SSH access and install the "openQRM client for Android" in the image.

Enable sshd

To get access the the Android OS filesystem use "kpartx" to mount the first partition of the logical volume. This should be only done when the image is not in use by an active VM, so the first thing is to stop the server.

Please go to the server list and stop the "android44" server.

Then please run on your KVM host in a root terminal:

kpartx -av /dev/lvols/android44
mount /dev/mapper/lvols-android44p1 /mnt/
ssh-keygen -b 2048 -C android44 -t rsa -f ssh_host_rsa_key 

(when it asks for a passphrase just press return)

ssh-keygen -b 1024 -C android44 -t dsa -f ssh_host_dsa_key

(when it asks for a passphrase just press return)

Now copy all generated file to /mnt/android-4.4-RC2/data/ssh/

cp ssh_host* /mnt/android-4.4-RC2/data/ssh/

Also download the "sshd_config" file for the Android OS from the Android plugin's usage page and copy it to /mnt/android-4.4-RC2/data/ssh/

cp sshd_config /mnt/android-4.4-RC2/data/ssh/

Finally add your personal public key to /mnt/android-4.4-RC2/data/.authorized_keys

cat /root/.ssh/id_rsa.pub > /mnt/android-4.4-RC2/data/.authorized_keys

The sshd service on the Android OS will be automatically started by the openQRM Client for Android which is explained as the next step.

Install the openQRM Client for Android OS

Download the openQRM Client for Android OS from the Android plugin's usage page.

Copy it to /mnt/android-4.4-RC2/data/openqrm-client-android.sh

cp openqrm-client-android.sh /mnt/android-4.4-RC2/data/

To automatically start the openQRM Client for Android follow the steps below:

1) Create a directory /mnt/android-4.4-RC2/system/vendor/etc

mkdir -p /mnt/android-4.4-RC2/system/vendor/etc

2) Create a file "init.sh" in this directory with the following command:

echo "sh -x /data/openqrm-client-android.sh" > /mnt/android-4.4-RC2/system/vendor/etc/init.sh

Now please umount the Android filesystem and release kpartx with the following commands:

umount /mnt
kpartx -dv /dev/lvols/android44 

Now please start the server again.

After the above configuration we can now passwordless login to the Android system by ssh.

The Android "master image" for Cloud deployment is now configured and ready to use. Please go the the server list again and stop the server.

Then go to

Plugins -> Cloud -> Configuration -> Private Images

And set the Android "master image" to be used by "Everybody".

Go to the openQRM Cloud login page

Plugins -> Cloud -> Portal

and login to the Cloud.

Please notice that enabling the Cloud automatically creates an "admin" project with the "openqrm" user and the same password as set for the openQRM adminstration UI.

In the Cloud user dashboard please click on "new instance".

In the "instance create" form please select the "android44" image and adjust cpu, disk, memory and network according to your needs.

The instance is now going to start. While starting it goes through the following phases:

  • approve
  • create
  • start
  • active

Here the permission and limits overview while the instance is still starting.

Here the permissions and limits overview when the instance is fully up and running.

In the Instance overview in the Cloud portal please click on "NoVNC" to gain console access to the Android OS.

Here again the Android UI after fully started up in the openQRM Cloud, requested and cloned from the "master image" on demand.

Please open up the "terminal emulator" app again.

In the terminal run

su

to get root access

Here the network configuration of the Android OS started in the openQRM Cloud. Please notice the correctly configured external IP address to be accessible by the Cloud users "remotely".

Congratulations!!

You have successfully made it through this openQRM-Android Cloud Howto.

We hope you enjoy openQRM's "magic potion".

Please notice again!

The Android OS support in openQRM is only available in the openQRM Enterprise Edition >= 5.1.4!

If you are interested in this feature please contact us for a free openQRM Enterprise evaluation edition!