MetaCloud management via command line

Z MetaCentrum
Skočit na navigaci Skočit na vyhledávání

THIS PART OF WIKI IS OUTDATED AND UNDER CONSTRUCTION. PLEASE BE PATIENT.

(Czech version)

VM instantiation

List of all templates and images available to you.

$ oneimage list
 ID USER       GROUP      NAME            DATASTORE     SIZE TYPE PER STAT RVMS
  8 oneadmin   users      debian6         default         8G OS    No rdy     0
 41 oneadmin   users      scilinux5       default        10G OS    No rdy     0
 42 oneadmin   users      scilinux6       default        10G OS    No rdy     0
$ onetemplate list
  ID USER            GROUP       NAME                    REGTIME
  5 oneadmin         users       debianvm         02/15 18:27:09
 55 oneadmin         users       scilinux5vm      04/24 13:04:17
 56 oneadmin         users       scilinux6vm      04/24 13:05:04

Now you can instantiate a VM.

$ onetemplate instantiate 5
 VM ID: 1977

This VM will show up in the list of running VMs. Important is the STAT column, where you can find the information about the state of the VM.

$ onevm list
 ID   USER           GROUP    NAME         STAT    UCPU    UMEM   HOST         TIME
 1977 <YOUR_LOGIN>   users    one-1977     pend    0       0K                  0d 00h00
$ onevm list
 ID   USER           GROUP    NAME         STAT    UCPU    UMEM   HOST         TIME
 1977 <YOUR_LOGIN>   users    one-1977     runn    0       0K     dukan3.ics   0d 00h00

List additional information about running VM ("runn" in STAT column).

$ onevm show 1977
 VIRTUAL MACHINE 1977 INFORMATION 
 -----------------------------
 ...
 NIC=[
   BRIDGE=xenbr0,
   CLUSTER_ID="100",
   IP=<IP_ADRESA_VM>,               # address for ssh connection to VM
   MAC=02:00:c0:a8:fe:03,
   NETWORK=public,
   NETWORK_ID="1",
   VLAN="NO",
   WHITE_PORTS_TCP="22",
   WHITE_PORTS_UDP="67,68" ]
 ...

Metacloud management

Here is the list of all programs which implement ONE API. Each command can be reviewed more closely by using -h switch. Next there are some important commands for work in MetaCloud via command line (ONE utils). Theyr meaning is intuitive.

  • oneacl: access control management
  • oneuser: add, remove and monitor users
  • onegroup: group access control management
  • onehost: add, remove and monitor computing hosts
  • oneimage: add, remove and manage images
  • onetemplate: add, remove and manage templates of VMs
  • onevm: create, control and monitor VM
  • onevnet: add, remove and monitor virtual networks
  • onezone: zone management
  • onevdc: data center management

VM templates management:

List of available templates

$ onetemplate list
 ID USER            GROUP       NAME                                REGTIME
  5 oneadmin        users       debianvm                     02/15 18:27:09
 55 oneadmin        users       scilinux5vm                  04/24 13:04:17
 56 oneadmin        users       scilinux6vm                  04/24 13:05:04

Initiation of VM

$ onetemplate instantiate debianvm --name DebianVM
 VM ID: 1977

You can create your own template and uploud it to MetaCloud database.

$ cat DebianVM.one
 #---------------------------------------
 # VM definition example
 #--------------------------------------- 

 NAME = DebianVM 

 CPU    = 1
 MEMORY = 1024

 # --- boot options --- 

 OS=[
   BOOTLOADER=pygrub ]
 RAW=[
   TYPE=xen ] 

 # --- 3 disks ---
 # TARGET xvdb is reserved for contextualization of your VM
 DISK = [ 
    IMAGE_ID  = <IMAGE_ID>,
    DRIVER    = "tap2:tapdisk:aio:",
    TARGET    = "xvda"  ] 

 DISK = [
   TYPE     = swap,
   SIZE     = 1024,
   READONLY = "no",
   TARGET   = "xvdc" ]

 DISK = [ TYPE   = fs,
         SIZE   = 4096,
         FORMAT = ext3,
         SAVE   = no,
         TARGET = xvdd ]

 # --- 1 NIC ---
 # Own network creation is forbidden,
 # use the default network created by us.
 NIC = [ NETWORK_ID = 1,
         WHITE_PORTS_TCP="22",
         WHITE_PORTS_UDP="67,68" ]

 # --- Placement options ---

 REQUIREMENTS = "CPUSPEED > 1000"
 RANK         = FREECPU

 # --- Contextualization ---
 # Only in case you need contextualization
 CONTEXT = [
  FILES     = "http://is.muni.cz/www/256254/init.sh",
  SSH_KEY   = "$USER[SSH_KEY]",
  HOSTNAME  = "MyVM",      # bude prepsano nslookup $PUBLIC_IP
  PUBLIC_IP = "$NIC[IP]"                              
 ]
$ onetemplate create DebianVM.one
 ID: 583

Or you can copy some of available tempolates and modify it.

$ onetemplate clone debianvm MyTemplate
 ID: 584
$ onetemplate update 584

VM images management:

List of available images

$ oneimage list
 ID USER       GROUP      NAME        DATASTORE     SIZE TYPE PER STAT RVMS
  8 oneadmin   users  debian6         default         8G OS    No rdy     0
 41 oneadmin   users  scilinux5       default        10G OS    No rdy     0
 42 oneadmin   users  scilinux6       default        10G OS    No rdy     0

You can upload your own images to MetaCloud or copy one of the available images.

$ oneimage clone debian6 MyImage
 ID: 371

You can change the persistence of your image.

$ oneimage persistent 371
$ oneimage nonpersistent 371

Data stored on persistent image won't be deleted after the shutdown and you can initiate only one VM with persistent image. On the other hand non-persistent image won't store data aftre the shutdown but you can initiate more then one VMs with this image. For better understanding see Cloud workflow example.

VM management:

$ onevm list
 ID   USER            GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        pend      0      0K                          00 00:00:03
$ onevm list
 ID   USER            GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        runn      0      0K    dukan1.ics.muni.cz    00 00:02:40
$ onevm suspend 0
$ onevm list
 ID          USER     GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        susp      0    512K    dukan1.ics.muni.cz    00 00:11:13
$ onevm resume 0
$ onevm list
 ID          USER     GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        runn      0    512K    dukan1.ics.muni.cz    00 00:15:13
$ onevm stop 0
$ onevm list
 ID          USER     GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        stop      0    512K    dukan1.ics.muni.cz    00 00:32:13
$ onevm resume 0
$ onevm list
 ID          USER     GROUP    NAME            STAT    CPU     MEM              HOSTNAME           TIME
  0   <YOUR_LOGIN>    users    DebianVM        pend      0    512K    dukan1.ics.muni.cz    00 00:34:13

The complete list of possible VMs' states (described in detail in documentation)

*Pending (pend): Waiting for resources and deployment.
*Hold (hold): The owner has held the VM and it will not be scheduled until it is released. It can be, however, deployed manually.
*Prolog (prol): The system is transferring the VM files (disk images and the recovery file) to the host in which the virtual machine will be running.
*Running (runn): The VM is running. In this state, the virtualization driver will periodically monitor it.
*Migrate (migr): The VM is migrating from one resource to another.
*Epilog (epil): In this phase the system cleans up the Host used to virtualize the VM, and additionally disk images to be saved are copied back to the front-end.
*Stopped (stop): The VM is stopped. VM state has been saved and it has been transferred back along with the disk images to the front-end.
*Suspended (susp): Same as stopped, but the files are left in the host to later restart the VM there.
*Failed (fail): The VM failed.
*Unknown (unknown): The VM couldn't be reached, it is in an unknown state.
*Done (done): The VM is done. VMs in this state won't be shown with “onevm list” but are kept in the database for accounting purposes.

Firewall

Warning: Users are responsible for the security of their virtual machines. Please pay attention to correct firewall setup.

All VMs have firewall turned on by default. The only opened ports are TCP 22 and UDP 67, 68. Other opened ports can be defined in template in NIC section:

• Different ports divided by comma, without spaces, eg. "68,67,69"
• Range of ports using colon, eg. "6000:6500"
• Or combination of both, eg. "68,69,6000:6500"

eg.:
NIC=[
 NETWORK_ID=1,
 WHITE_PORTS_TCP="22,443,8443,8080,8180",
 WHITE_PORTS_UDP="67,68" ]

Disk management

New disks can be hot-plugged to running VMs with the onevm attachdisk and detachdisk commands. For example, to attach to a running VM the Image named “storage”:

$ onevm attachdisk one-5 --image storage

To detach a disk from a running VM, find the disk ID of the Image you want to detach using the onevm show command, and then simply execute onevm detach vm_id disk_id:

$ onevm show one-5
...
DISK=[
  DISK_ID="1",
...
  ]
...

$ onevm detachdisk one-5 1