-
Notifications
You must be signed in to change notification settings - Fork 9
linux_log
A VM instance with contextualization enabled will have an ISO appearing as a CD-ROM device on the Guest OS. This device holds information established by OpenNebula regarding how the VM Guest OS should be configured according to the VM end user. This configuration is established in the VM instance template CONTEXT section and then stored inside that ISO in the form of a bash script context.sh
.
root@one-apps-11114:~# mount /dev/sr0 /mnt/
mount: /mnt: WARNING: source write-protected, mounted read-only.
root@one-apps-11114:~# cat /mnt/context.sh
# Context variables generated by OpenNebula
DISK_ID='1'
ETH0_DNS='172.20.0.1'
ETH0_EXTERNAL=''
ETH0_GATEWAY='172.20.0.1'
ETH0_IP='172.20.0.19'
ETH0_IP6=''
ETH0_IP6_GATEWAY=''
ETH0_IP6_METHOD='static'
ETH0_IP6_METRIC=''
ETH0_IP6_PREFIX_LENGTH=''
ETH0_IP6_ULA=''
ETH0_MAC='02:00:ac:14:00:13'
ETH0_MASK='255.255.0.0'
ETH0_METHOD='static'
ETH0_METRIC=''
ETH0_MTU=''
ETH0_NETWORK='172.20.0.0'
ETH0_SEARCH_DOMAIN=''
ETH0_VLAN_ID=''
ETH0_VROUTER_IP=''
ETH0_VROUTER_IP6=''
ETH0_VROUTER_MANAGEMENT=''
NETWORK='YES'
REPORT_READY='NO'
SET_HOSTNAME='"one-apps-11114"'
SSH_PUBLIC_KEY='ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDugXwwA/iDAQof3+vYnRA4VUpZxpqwRWXs8g0RENk5AS1ONt01NmxDg4mr7dSQBjx/w6JFDtydfLul/bj96uw8peuAQNP5k2lu2rWV9BBI5ysKMK4MlzEgwfSuztCWMHJZNF4q8JjR/0SF0eTOyumMWsBWS2JKakdyf/YZU+O5S6RcavpiX2bJ0yEaLYXpugLecp73hKoW3B4MpZLpBQwSjk+M668MTAb/SAFd6UALhMorXSTBRmSDByk4JL4OMvLOotyfcFF9va2CCOifqUa6LmOjZvuYi5p/JfT2x/aGOBIXibv9EtjkxkBoqNpkfITvWHm4Gx/91m/5eSYRtxYZ dann1@rocket'
TARGET='hda'
TOKEN='NO'
These values are then processed by the one-context
service, which is managed by systemd or rcinit depending on the distro
root@one-apps-11114:~# systemctl status one-context
● one-context.service - OpenNebula contextualization
Loaded: loaded (/lib/systemd/system/one-context.service; enabled; vendor preset: enabled)
Active: active (exited) since Mon 2024-05-13 16:39:55 UTC; 56s ago
Process: 1384 ExecStart=/usr/sbin/one-contextd network (code=exited, status=0/SUCCESS)
Main PID: 1384 (code=exited, status=0/SUCCESS)
CPU: 497ms
May 13 16:39:54 one-apps-11114 one-contextd[1459]: Script net-15-hostname: Finished with exit code 0
May 13 16:39:54 one-apps-11114 one-contextd[1461]: Script net-97-start-script: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1468]: Script net-97-start-script: Finished with exit code 0
May 13 16:39:55 one-apps-11114 one-contextd[1470]: Script net-98-execute-scripts: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1477]: Script net-98-execute-scripts: Finished with exit code 0
May 13 16:39:55 one-apps-11114 one-contextd[1479]: Script net-99-report-ready: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1484]: Finished scripts processing
May 13 16:39:55 one-apps-11114 one-contextd[1485]: Done
May 13 16:39:55 one-apps-11114 one-contextd[1490]: Releasing lock /var/run/one-context/one-context.lock
May 13 16:39:55 one-apps-11114 systemd[1]: Finished OpenNebula contextualization.
You can inspect the execution of the process by issuing journalctl -u one-context
root@one-apps-11114:~# journalctl -u one-context
Apr 15 09:59:45 localhost.localdomain systemd[1]: Starting OpenNebula contextualization...
Apr 15 09:59:45 localhost.localdomain one-contextd[1395]: Started for type network
Apr 15 09:59:45 localhost.localdomain one-contextd[1396]: Acquiring lock /var/run/one-context/one-context.lock
Apr 15 09:59:45 localhost.localdomain one-contextd[1398]: Acquired lock /var/run/one-context/one-context.lock
Apr 15 09:59:45 localhost.localdomain one-contextd[1412]: Found context /var/run/one-context/mount.hliCVI/context.sh
Apr 15 09:59:45 localhost.localdomain one-contextd[1415]: Comparing /var/run/one-context/context.sh.3Q1NmS and /var/run/one-context/context.sh.network for changes
Apr 15 09:59:45 localhost.localdomain one-contextd[1417]: New context with changes
Apr 15 09:59:45 localhost.localdomain one-contextd[1426]: Processing network scripts
Apr 15 09:59:45 localhost.localdomain one-contextd[1428]: Script net-11-fix-loopback: Starting ...
Apr 15 09:59:45 one-apps-11114 one-contextd[1481]: Script net-97-start-script: Starting ...
Apr 15 09:59:45 one-apps-11114 one-contextd[1503]: Script net-99-report-ready: Finished with exit code 0
Apr 15 09:59:45 one-apps-11114 systemd[1]: Finished OpenNebula contextualization.
-- Boot ac84eb98f0e54a89acaa3d5819f71fbc --
May 03 14:19:30 one-apps-11114 systemd[1]: Starting OpenNebula contextualization...
May 03 14:19:30 one-apps-11114 one-contextd[1384]: Acquiring lock /var/run/one-context/one-context.lock
May 03 14:19:31 one-apps-11114 one-contextd[1400]: Found context /var/run/one-context/mount.dyVy4m/context.sh
May 03 14:19:31 one-apps-11114 one-contextd[1414]: Processing network scripts
May 03 14:19:31 one-apps-11114 one-contextd[1452]: Script net-15-hostname: Finished with exit code 0
May 03 14:19:31 one-apps-11114 one-contextd[1454]: Script net-97-start-script: Starting ...
May 03 14:19:31 one-apps-11114 one-contextd[1461]: Script net-97-start-script: Finished with exit code 0
May 03 14:19:31 one-apps-11114 one-contextd[1470]: Script net-98-execute-scripts: Finished with exit code 0
May 03 14:19:31 one-apps-11114 one-contextd[1472]: Script net-99-report-ready: Starting ...
May 03 14:19:31 one-apps-11114 one-contextd[1476]: Script net-99-report-ready: Finished with exit code 0
May 03 14:19:31 one-apps-11114 systemd[1]: Finished OpenNebula contextualization.
-- Boot 170f2f452a904dc1b41bf3d0d218af68 --
May 13 16:39:54 one-apps-11114 systemd[1]: Starting OpenNebula contextualization...
May 13 16:39:54 one-apps-11114 one-contextd[1393]: Acquired lock /var/run/one-context/one-context.lock
May 13 16:39:54 one-apps-11114 one-contextd[1407]: Found context /var/run/one-context/mount.sPcbNu/context.sh
May 13 16:39:54 one-apps-11114 one-contextd[1410]: Comparing /var/run/one-context/context.sh.bQ9G1m and /var/run/one-context/context.sh.network for changes
May 13 16:39:54 one-apps-11114 one-contextd[1412]: New context with changes
May 13 16:39:54 one-apps-11114 one-contextd[1421]: Processing network scripts
May 13 16:39:54 one-apps-11114 one-contextd[1423]: Script net-11-fix-loopback: Starting ...
May 13 16:39:54 one-apps-11114 one-contextd[1428]: Script net-11-fix-loopback: Finished with exit code 0
May 13 16:39:54 one-apps-11114 one-contextd[1430]: Script net-15-hostname: Starting ...
May 13 16:39:54 one-apps-11114 one-contextd[1459]: Script net-15-hostname: Finished with exit code 0
May 13 16:39:54 one-apps-11114 one-contextd[1461]: Script net-97-start-script: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1468]: Script net-97-start-script: Finished with exit code 0
May 13 16:39:55 one-apps-11114 one-contextd[1470]: Script net-98-execute-scripts: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1477]: Script net-98-execute-scripts: Finished with exit code 0
May 13 16:39:55 one-apps-11114 one-contextd[1479]: Script net-99-report-ready: Starting ...
May 13 16:39:55 one-apps-11114 one-contextd[1484]: Finished scripts processing
May 13 16:39:55 one-apps-11114 one-contextd[1485]: Done
May 13 16:39:55 one-apps-11114 one-contextd[1490]: Releasing lock /var/run/one-context/one-context.lock
May 13 16:39:55 one-apps-11114 systemd[1]: Finished OpenNebula contextualization.
The context logic can be located inside a Contextualized VM at /etc/one-context.d
.
Every time the Virtual Machine boots, or there is an NIC/DISK hotplug operation, these scripts are run one by one and use the information stored in the CONTEXT section mentioned previously. In case of failing you might see a message in the booting screen, but sometimes it does not fail at all, so it does not show any error. However, it might be possible that it did not work as intended, for example, the VM lacks an IP address.
To debug it, you can run the contextualization scripts manually with debug output activated:
DEBUG=1 /usr/sbin/one-contextd all force
Started for type all to force
Acquiring lock /var/run/one-context/one-context.lock
Acquired lock /var/run/one-context/one-context.lock
Mounting CD-ROM /dev/sr0 on /var/run/one-context/mount.HehnpF
Found context /var/run/one-context/mount.HehnpF/context.sh
Processing local scripts
Script loc-05-grow-rootfs: Starting ...
Script loc-05-grow-rootfs output: DEVICE: /dev/vda1
FSTYPE: ext4
DISK: /dev/vda
PARTITION: 1
NOCHANGE: partition 1 could only be grown by -33 [fudge=2048]
resize2fs 1.45.4 (23-Sep-2019)
The filesystem is already 261120 (1k) blocks long. Nothing to do!
Script loc-05-grow-rootfs: Finished with exit code 0
Script loc-09-timezone: Starting ...
Script loc-09-timezone: Finished with exit code 0
Script loc-10-network: Starting ...
Script loc-10-network: Finished with exit code 1
Script loc-10-network-pci: Starting ...
Script loc-10-network-pci: Finished with exit code 0
...
Done
Unmounting /var/run/one-context/mount.HehnpF
Releasing lock /var/run/one-context/one-context.lock
As you can see, it shows the exit codes of each script, so you can see what script is failing and what not. You can also run a script individually by manually loading the config variables and then running the script
source /mnt/context.sh
bash -xv /etc/one-context.d/net-99-report-ready
#!/usr/bin/env bash
# -------------------------------------------------------------------------- #
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
# #
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
# not use this file except in compliance with the License. You may obtain #
# a copy of the License at #
# #
# http://www.apache.org/licenses/LICENSE-2.0 #
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS, #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
# See the License for the specific language governing permissions and #
# limitations under the License. #
#--------------------------------------------------------------------------- #
ENV_FILE=${ENV_FILE:-/var/run/one-context/one_env}
+ ENV_FILE=/var/run/one-context/one_env
RETRY_COUNT="${RETRY_COUNT:-3}"
+ RETRY_COUNT=3
RETRY_WAIT_PERIOD="${RETRY_WAIT_PERIOD:-10}"
+ RETRY_WAIT_PERIOD=10
if [ "$REPORT_READY" != "YES" ]; then
exit 0
fi
+ '[' '' '!=' YES ']'
+ exit 0
- Build Instructions
- Linux Contextualization Packages
- Windows Contextualization Packages
- OpenNebula Apps Overview
- OS Appliances update policy
- OneKE (OpenNebula Kubernetes Edition)
- Virtual Router
- Release Notes
- Overview
- Quick Start
- OpenRC Services
- Virtual Router Modules
- Glossary
- WordPress
- Harbor Container Registry
- MinIO
- Development