KVM を Ovirt (Web UI) で管理

## What's this?

KVM 管理を「コマンドラインの virsh」や「Linux X Application の VirtManager」ではなく、普通にブラウザで管理したい。
RHEV(RedHat Enterprise Virtuaalizaiton) の Upstream の Ovirt で、KVM Host を Ovirt 管理化に設定するまでのメモ

* Install/Setup oVirt Engine (Ovirt Server)
* Install/Setup Vdsm-Node (KVM node)
* Connect Vdsm-Node (KVM node) to oVirt Engine (Ovirt Server)

## Install/Setup oVirt Engine (Ovirt Server)

oVirt Engine is the control center of the oVirt environment.

#### Add repository

    # yum install http://resources.ovirt.org/pub/yum-repo/ovirt-release35.rpm

#### Install pkg

    # yum install ovirt-engine

    =======================================================================
     Package                Arch      Version    Repository           Size
    =======================================================================
    Installing:
     ovirt-release35        noarch    005-1      /ovirt-release35    7.3 k

    Transaction Summary
    =======================================================================
    Install  1 Package


#### Configuration

    # export LANG=en_US.UTF-8

    # engine-setup
    [ INFO  ] Stage: Initializing
    [ INFO  ] Stage: Environment setup
              Configuration files: ['/etc/ovirt-engine-setup.conf.d/10-packaging-jboss.conf', '/etc/ovirt-engine-setup.conf.d/10-packaging.conf']
              Log file: /var/log/ovirt-engine/setup/ovirt-engine-setup-20150723174824-g0sl3w.log
              Version: otopi-1.3.2 (otopi-1.3.2-1.el7.centos)
    [ INFO  ] Stage: Environment packages setup
    [ INFO  ] Stage: Programs detection
    [ INFO  ] Stage: Environment setup
    [ INFO  ] Stage: Environment customization

              --== PRODUCT OPTIONS ==--

              Configure Engine on this host (Yes, No) [Yes]:
              Configure WebSocket Proxy on this host (Yes, No) [Yes]: No

              --== PACKAGES ==--

    [ INFO  ] Checking for product updates...
    [ INFO  ] No product updates found

              --== ALL IN ONE CONFIGURATION ==--


              --== NETWORK CONFIGURATION ==--

              Setup can automatically configure the firewall on this system.
              Note: automatic configuration of the firewall may overwrite current settings.
              Do you want Setup to configure the firewall? (Yes, No) [Yes]:
    [ INFO  ] firewalld will be configured as firewall manager.
              Host fully qualified DNS name of this server [<HOSTNAME>]:
    [WARNING] Host name <HOSTNAME> has no domain suffix
    [WARNING] Failed to resolve <HOSTNAME> using DNS, it can be resolved only locally

              --== DATABASE CONFIGURATION ==--

              Where is the Engine database located? (Local, Remote) [Local]:
              Setup can configure the local postgresql server automatically for the engine to run. This may conflict with existing applications.
              Would you like Setup to automatically configure postgresql and create Engine database, or prefer to perform that manually? (Automatic, Manual) [Automatic]:

              --== OVIRT ENGINE CONFIGURATION ==--

              Engine admin password:
              Confirm engine admin password:
    [WARNING] Passwords do not match
              Engine admin password:
              Confirm engine admin password:
    [WARNING] Password is weak: it is based on a dictionary word
              Use weak password? (Yes, No) [No]: Yes
              Application mode (Virt, Gluster, Both) [Both]:

              --== PKI CONFIGURATION ==--

              Organization name for certificate [Test]: <ORGANIZATION>

              --== APACHE CONFIGURATION ==--

              Setup can configure the default page of the web server to present the application home page. This may conflict with existing applications.
              Do you wish to set the application as the default page of the web server? (Yes, No) [Yes]:
              Setup can configure apache to use SSL using a certificate issued from the internal CA.
              Do you wish Setup to configure that, or prefer to perform that manually? (Automatic, Manual) [Automatic]:

              --== SYSTEM CONFIGURATION ==--

              Configure an NFS share on this server to be used as an ISO Domain? (Yes, No) [Yes]:
              Local ISO domain path [/var/lib/exports/iso]:
              Local ISO domain ACL - note that the default will restrict access to <HOSTNAME> only, for security reasons [<HOSTNAME>(rw)]: x.x.x.x/24(rw)
              Local ISO domain name [ISO_DOMAIN]:

              --== MISC CONFIGURATION ==--


              --== END OF CONFIGURATION ==--

    [ INFO  ] Stage: Setup validation
    [WARNING] Less than 16384MB of memory is available

              --== CONFIGURATION PREVIEW ==--

              Application mode                        : both
              Firewall manager                        : firewalld
              Update Firewall                         : True
              Host FQDN                               : <HOSTNAME>
              Engine database name                    : engine
              Engine database secured connection      : False
              Engine database host                    : localhost
              Engine database user name               : engine
              Engine database host name validation    : False
              Engine database port                    : 5432
              Engine installation                     : True
              NFS setup                               : True
              PKI organization                        : <ORGANIZATION>
              NFS mount point                         : /var/lib/exports/iso
              NFS export ACL                          : <HOSTNAME>(rw)
              Configure local Engine database         : True
              Set application as default page         : True
              Configure Apache SSL                    : True
              Configure WebSocket Proxy               : False
              Engine Host FQDN                        : <HOSTNAME>

              Please confirm installation settings (OK, Cancel) [OK]:
    [ INFO  ] Stage: Transaction setup
    [ INFO  ] Stopping engine service
    [ INFO  ] Stopping ovirt-fence-kdump-listener service
    [ INFO  ] Stopping websocket-proxy service
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Stage: Package installation
    [ INFO  ] Stage: Misc configuration
    [ INFO  ] Initializing PostgreSQL
    [ INFO  ] Creating PostgreSQL 'engine' database
    [ INFO  ] Configuring PostgreSQL
    [ INFO  ] Creating/refreshing Engine database schema
    [ INFO  ] Creating CA
    [ INFO  ] Generating post install configuration file '/etc/ovirt-engine-setup.conf.d/20-setup-ovirt-post.conf'
    [ INFO  ] Stage: Transaction commit
    [ INFO  ] Stage: Closing up
    [ INFO  ] Restarting nfs services

              --== SUMMARY ==--

    [WARNING] Less than 16384MB of memory is available
              SSH fingerprint: xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
              Internal CA xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx
              Web access is enabled at:
                  http://<HOSTNAME>:80/ovirt-engine
                  https://<HOSTNAME>:443/ovirt-engine
              Please use the user "admin" and password specified in order to login

              --== END OF SUMMARY ==--

    [ INFO  ] Starting engine service
    [ INFO  ] Restarting httpd
    [ INFO  ] Stage: Clean up
              Log file is located at /var/log/ovirt-engine/setup/ovirt-engine-setup-20150723174824-g0sl3w.log
    [ INFO  ] Generating answer file '/var/lib/ovirt-engine/setup/answers/20150723180146-setup.conf'
    [ INFO  ] Stage: Pre-termination
    [ INFO  ] Stage: Termination
    [ INFO  ] Execution of setup completed successfully



#### Check running services

    # systemctl list-units | grep ovirt
    ovirt-engine.service                   loaded active running   oVirt Engine
    ovirt-fence-kdump-listener.service     loaded active running   oVirt Engine fence_kdump listener

    # systemctl list-unit-files | grep ovirt
    ovirt-engine-notifier.service              disabled
    ovirt-engine.service                       enabled
    ovirt-fence-kdump-listener.service         enabled
    ovirt-websocket-proxy.service              disabled

    # ps -aef | grep java
    ovirt     1558  1500  1  2015 ?        3-01:33:59 java -server -XX:+TieredCompilation -Xms1024M -Xmx1024M -XX:PermSize=256m -XX:MaxPermSize=256m -Djava.awt.headless=true -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -Djsse.enableSNIExtension=false -Djava.security.krb5.conf=/etc/ovirt-engine/krb5.conf -XX:+HeapDumpOnOutOfMemoryError -XX:HeapDumpPath=/var/log/ovirt-engine/dump -Djava.util.logging.manager=org.jboss.logmanager -Dlogging.configuration=file:///var/lib/ovirt-engine/jboss_runtime/config/ovirt-engine-logging.properties -Dorg.jboss.resolver.warning=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djboss.modules.write-indexes=false -Djboss.server.default.config=ovirt-engine -Djboss.home.dir=/usr/share/ovirt-engine-jboss-as -Djboss.server.base.dir=/usr/share/ovirt-engine -Djboss.server.data.dir=/var/lib/ovirt-engine -Djboss.server.log.dir=/var/log/ovirt-engine -Djboss.server.config.dir=/var/lib/ovirt-engine/jboss_runtime/config -Djboss.server.temp.dir=/var/lib/ovirt-engine/jboss_runtime/tmp -Djboss.controller.temp.dir=/var/lib/ovirt-engine/jboss_runtime/tmp -jar /usr/share/ovirt-engine-jboss-as/jboss-modules.jar -mp /var/lib/ovirt-engine/jboss_runtime/modules/00-ovirt-engine-modules:/var/lib/ovirt-engine/jboss_runtime/modules/01-ovirt-engine-jboss-as-modules -jaxpmodule javax.xml.jaxp-provider org.jboss.as.standalone -c ovirt-engine.xml



## Install/Setup Vdsm-Node (KVM node)

#### Add repository

    # yum install http://resources.ovirt.org/pub/yum-repo/ovirt-release35.rpm

#### Install pkg

    # yum install vdsm

#### Check running services

    # systemctl list-unit-files | grep vdsm
    supervdsmd.service                         static
    vdsm-network.service                       enabled
    vdsmd.service                              enabled


#### Network configuration

主要なパラメータのみ記載、"ovirtmgmt" という名前の Bridge を作成しておく

* ifcfg-*

```
# cat /etc/sysconfig/network-scripts/ifcfg-enp3s0f0
DEVICE=enp3s0f0
BRIDGE=ovirtmgmt
ONBOOT=yes
NM_CONTROLLED=no

# cat /etc/sysconfig/network-scripts/ifcfg-ovirtmgmt
DEVICE=ovirtmgmt
TYPE=Bridge
ONBOOT=yes
IPADDR=x.x.x.x
NETMASK=x.x.x.x
BOOTPROTO=static
NM_CONTROLLED=no
```

* Bridge

```
# brctl show
bridge name     bridge id               STP enabled     interfaces
;vdsmdummy;             8000.000000000000       no
ovirtmgmt               8000.441ea159d1d8       no              enp3s0f0
```



## Connect Vdsm-Node (KVM node) to oVirt Engine (Ovirt Server)

oVirt Engine (Ovirt Server) に Vdsm-Node (KVM node) を登録し、管理出来るように設定する。

#### Log in to the Administration Portal

http://x.x.x.x/ovirt-engine/

* id : admin
* pw : 上記で設定したパスワード


#### Vdsm-Node (KVM node) 新規追加

[Host] -> "New"

![ovirt01.png](https://qiita-image-store.s3.amazonaws.com/0/39751/d0bea1e0-f5d4-5d79-c6e6-965e69445466.png)

KVM Host name, Address, Password 入力

![ovirt02.png](https://qiita-image-store.s3.amazonaws.com/0/39751/d4324747-eae3-fefa-9edb-74973d77a470.png)

追加されるが、この時点ではまだ Active になっていない。

![ovirt03.png](https://qiita-image-store.s3.amazonaws.com/0/39751/e93f3a4f-f458-db93-3b86-95cdabeb891f.png)

#### 追加した Vdsm-Node (KVM node) の Network Configuration を修正

[Network Interfaces] -> "Setup Host Networks"

![ovirt04.png](https://qiita-image-store.s3.amazonaws.com/0/39751/45c8d18e-00a0-47fe-76be-ed598b8a5fb2.png)

logical network interface [ovirtmgmt] を physical interface [enp3s0f0] に対応させる為、矢印のようにドラッグする。

![ovirt05.png](https://qiita-image-store.s3.amazonaws.com/0/39751/089c04e5-32b0-a65a-25e5-e3d326d1657e.png)

logical network interface [ovirtmgmt] を physical interface [enp3s0f0] がマッピングされた。

![ovirt06.png](https://qiita-image-store.s3.amazonaws.com/0/39751/83721ac7-0f4a-aa5f-d548-ddfdd238eb5d.png)

#### Vdsm-Node (KVM node) を Activate

Vdsm-Node (KVM node) が oVirt Engine (Ovirt Server) に登録され、操作可能となる。

![ovirt07.png](https://qiita-image-store.s3.amazonaws.com/0/39751/1ede5d14-e7e9-7402-07d0-f1c809b72781.png)

## Environment

###### ovirt-engine

    # rpm -q ovirt-engine
    ovirt-engine-3.5.3.1-1.el7.centos.noarch

###### vdsm

    # rpm -q vdsm
    vdsm-4.16.20-0.el7.centos.x86_64

###### libvirt

    # libvirtd --version
    libvirtd (libvirt) 1.2.8

## Reference

* How to install
[http://www.ovirt.org/Quick_Start_Guide#Install_oVirt][link-01]

* ovirt-shell
[http://www.ovirt.org/CLI][link-02]


[link-01]:http://www.ovirt.org/Quick_Start_Guide#Install_oVirt
[link-02]:http://www.ovirt.org/CLI