With this external provider, the machines
plugin in Cockpit can redirect actions to oVirt REST API instead of default Libvirt.
Please refer to cockpit-machines README.md for external plugin description and API which is implemented by this project.
The entry point for the provider API implementation is src/provider.js
.
It's fine to implement the API using VanillaJS
, as far as the simple API contract is met.
For more complex scenarios ES6, Babel, Webpack and React
can be leveraged as shown in this project.
Actual installation is as simple as copying 2 files.
Anyway, the project requires oVirt and Cockpit running.
No matter you are going to build from sources or install from RPM, following must be met:
-
the oVirt is installed (means engine with at least one host)
-
the Cockpit is installed in version 133 or higher on the oVirt host
yum install cockpit cockpit-machines
or check http://cockpit-project.org/running.html for more details
-
Please note, latest project features might be available only with latest Cockpit:
https://copr.fedorainfracloud.org/coprs/g/cockpit/cockpit-preview/
-
When logged as the
root
user on the oVirt engine machine:engine-config -s CORSSupport=true # To turn on the CORS support for the REST API engine-config -s CORSAllowDefaultOrigins=true # To allow CORS for all configured hosts systemct restart ovirt-engine
The RPM builds are released on Copr repository. To enable it, use:
dnf copr enable mlibra/cockpit-machines-ovirt-provider
To install:
dnf install cockpit-machines-ovirt-provider
If RPM installation is not enough and you are willing to build from sources, this section is for you.
All JavaScript dependencies can be installed via npm i
(see package.json file).
Anyway, it is recommended to use yarn
and offline cache maintained by the ovirt-engine-nodejs-modules project since the project is tested against such "fixed" versions of 3rd party libraries.
To do so, enable the tested
repository from
http://resources.ovirt.org/repos/ovirt/tested/master/rpm
Until BZ 1427045 is finished, this step has to be done manually.
To install all dependencies:
git clone https://github.com/oVirt/cockpit-machines-ovirt-provider.git
cd cockpit-machines-ovirt-provider
./autogen.sh
yum-builddep cockpit-machines-ovirt-provider.spec # to install ovirt-engine-yarn and other dependencies of correct versions
source /usr/share/ovirt-engine-nodejs-modules/setup-env.sh # to create ./node_modules dir from yarn offline cache
make [rpm]
The result can be found under dist
or tmp.repos
directories.
If the project is built from sources, it's enough to just copy dist/
content under [COCKPIT_INSTALL_DIR]/machines/provider
.
On an oVirt host machine:
cd [COCKPIT_INSTALL_DIR]/machines
mkdir -p ./provider
cp [PROVIDER_SRC @ BUILD_MACHINE]/dist/* ./provider/
# and just refresh the cockpit:machines page (press F5) to take effect
The COCKPIT_INSTALL_DIR
usually refers to /usr/share/cockpit
.
The PROVIDER_SRC
refers to directory where you built the project (probably remote machine).
Once either the RPM or from sources installation is finished, the plugin needs to do some additional configuration, like setting the URL of your oVirt engine.
To do so:
- login into Cockpit as
root
user - enter the
machines
plugin, installation dialog pops-up - submit URL of your running oVirt engine
- Example:
https://my.domain.com/ovirt-engine
- following config files will be updated:
- cockpit/machines/override.json
- cockpit/machines/provider/machines-ovirt.config
- in case of failure, please follow instructions by the
install.sh
- Example:
- as instructed on the screen, re-login into Cockpit
Cockpit does not need to be restarted to take effect, just log out/log in is enough.
If installed and configured properly, the oVirt will be used as datasource after next reload of the machines
plugin page in Cockpit (re-login to Cockpit).
The provider supports oVirt SSO (see [2]), it means the user will be optionally redirected to oVirt login page and back to the Cockpit.
Data retrieval (means list of VMs and their properties) is intentionally handled still via Libvirt leading to host-local view on the system.
Active operations (start, shutdown, restart)
are redirected to oVirt REST API to be performed.
- [1] Cockpit-machines external provider support
- cockpit-project/cockpit#5759
- and multiple follow-up patches
- [2] oVirt CORS support
- [3] The rest is tracked on oVirt Trello
- [1] ovirt-engine/web-ui/authorizedRedirect.jsp (part of ovirt-engine 4.1 from ovirt-web-ui.0.1.1-2.rpm) is used to handle SSO redirect. Recently considering moving this JSP under enginesso.war
Please send author(s) any feedback on the project.
- Marek Libra ([email protected])