diff --git a/.directory b/.directory new file mode 100644 index 0000000..872318b --- /dev/null +++ b/.directory @@ -0,0 +1,4 @@ +[Dolphin] +Timestamp=2017,7,24,3,34,58 +Version=4 +ViewMode=1 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md new file mode 100644 index 0000000..216f4f5 --- /dev/null +++ b/CODE_OF_CONDUCT.md @@ -0,0 +1,46 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to making participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, nationality, personal appearance, race, religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at sergiojvg92@gmail.com. The project team will review and investigate all complaints, and will respond in a way that it deems appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, available at [http://contributor-covenant.org/version/1/4][version] + +[homepage]: http://contributor-covenant.org +[version]: http://contributor-covenant.org/version/1/4/ diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 0040eaf..4b69d47 100755 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -1,6 +1,6 @@ # Pull requests -When contributing make pull requests to the feature branch for the next release, don't commit to master branch +When contributing make pull requests to the *feature branch* named after next release, don't commit to master branch. If you want to contribute feel free to request new features, check first TODO. # Help @@ -13,4 +13,4 @@ By default, any contribution to this project is made under the Apache 2.0 license. The author of a change remains the copyright holder of their code -(no copyright assignment). \ No newline at end of file +(no copyright assignment). diff --git a/Image.md b/Image.md index 2f30530..0a17538 100644 --- a/Image.md +++ b/Image.md @@ -1,222 +1,187 @@ # Virtual Appliance Creation -
-Table of Contents - +LXD native images are basically compressed files. OpenNebula uses block based images in its default operation mode. The default LXD images will NOT work with **LXDoNe**. This guide is meant for converting a LXD image into a OpenNebula-ready LXD image. -- [Block Device creation](#block-device-creation) - - [Selected method procedure](#selected-method-procedure) -- [Standard Base Image](#standard-base-image) -- [Bootstrap](#bootstrap) -- [LXCoNe and LXC](#lxcone-and-lxc) - - [LXCoNe](#lxcone) - - [LXC](#lxc) -- [Custom container](#custom-container) - - [Creation](#creation) - - [Networking \(optional\)](#networking-optional) - - [Shell spawn](#shell-spawn) - - [Dump container into raw image](#dump-container-into-raw-image) - - - -
- -This is the structure of a **LXDoNe** image, the same as a unified **LXD** tarball: - -![](picts/image.png) - -templates directory contains some start hooks that populates files such as **/etc/hosts** and **/etc/hostname**, metadata.yaml contains some required metadata and rootfs is a basic linux filesystem. **LXDoNe** uses modified metadata. This structure can be accomplished by several ways. LXDoNe 1702-1 features a script for automatic Virtual Appliance creation, just run as root **image-handling/build-img.sh** you will be asked for size, release and repository, example values are *600M*, *xenial* and *http://archive.ubuntu.com/ubuntu*, those are the default ones if you just press Enter key. The script will result in a raw image called **lxdone.img** ready for OpenNebula, you can ignore the rest of this text unless this script has failed more than once for you or you have containers you want to use: - -- **Standard base image(_Simple_)**: use a standard image from https://linuxcontainers.org/images, and dump it into a raw block device -- **Bootstrap(_Quick_)**: generate a rootfs using debootstrap. This is the recommended choice if you have a lack of bandwidth, as previous one will download an 85M tarball, so you only need a repository, although it may take a while due to every package needs to be configured by debootstrap. -- **LXCoNe and LXC**: if you have used **LXCoNe** or you just switched from **LXC** to **LXD** and already have a container you want for OpenNebula. -- **Custom container(_Thorough_)**: create a lxd container and tweak it in order to have your custom virtual appliance. In this option you'll use lxd directly, so if it is the first time you use **LXD** it is the recommended choice, also if you already have used **LXD** and have a container you want for OpenNebula. -- **MarketPlace(_Easy_)**: Download lxdone virtual appliance to your datastore. (Coming soon) - - -## Block Device creation -At the end of every one of the previous methods you'll have to save your work in a raw image that will be uploaded to a Datastore. So regardless the method you choose you'll have to do this before beginning the method, except for **LXCoNe**: +## Create a default container ```bash -truncate -s G /var/tmp/lxdone.img -loop=$(sudo losetup --find --show /var/tmp/lxdone.img) -mkfs.ext4 $loop -mount $loop /mnt/ +lxc launch images:16.04 lxdone ``` - -### Selected method procedure - -And this after ending the method. This is valid for **LXCoNe** +Now you should have a container named **lxdone** running. To check the container state: +```bash +lxc list ``` -# cp -rpa addon-lxdone-master/metadata/* /mnt/ -# umount $loop -# losetup -d $loop -``` - - -#### Warning: -Standard containers fit into 400M images, at the end of each method you'll have to dump something into the raw image, so check there are no errors in the shell output regarding the image ran out of space. - -#### Note: -To enable contextualization you'll need to modifiy **/etc/one-context.d/10-network** after [installing one-context package](https://docs.opennebula.org/5.2/operation/vm_setup/kvm.html). Replace get_interface_mac() function with this one: +The output should be like this: ``` -get_interface_mac() -{ - ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"\@")} /link\/ether/ { print dev[1] " " $2 }' -} ++---------+---------+---------------------+------+------------+-----------+ +| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | ++---------+---------+---------------------+------+------------+-----------+ +| lxdone | RUNNING | | | PERSISTENT | 0 | ++---------+---------+---------------------+------+------------+-----------+ ``` +LXD default profiles attaches a NIC to every new container. This behaviour must be removed for a lxd-node controlled by OpenNebula. If you did this in the [setup guide](Setup.md) then attach a NIC by: - -## Standard Base Image - -Fetch the image from the image repository - -``` -# lxc image export images:lxdone lxdone . +```bash +lxc config device add lxdone eth0 nic nictype=bridged parent=br0 ``` -Untar the image in the raw block device +Enter the container as root. +```bash +lxc exec lxdone bash +root@lxdone: ``` -# tar -xpf lxdone.tar.gz --one-top-level=/mnt/ -``` - - -## Bootstrap -Install debbootsrap +## Container tweaking: +Customize your container all you want -``` -# apt install debootstrap +```bash +root@lxdone: apt install one-context +root@lxdone: passwd +...... +...... +root@lxdone: exit ``` -Generate rootfs. It will take a while to complete. +### OpenNebula contextualization +Follow [KVM contextualization](https://docs.opennebula.org/5.2/operation/vm_setup/kvm.html). Then install curl and openssh-server for ssh contextualization. +```bash +root@lxdone: apt install openssh-server curl ``` -# debootstrap xenial /mnt/rootfs -``` - - - -## LXCoNe and LXC - -The goal is to reutilize the existing linux filesystem generated with **LXC** and transform your old **LXC** container into a new **LXD** container. - -### LXCoNe +In **/etc/one-context.d/10-network** replace _get_interface_mac_ function -Given a lxcone.img raw image containing a linux filesystem. - -Mount the old container - -``` -# losetup /dev/loop0 lxcone.img -# mount /dev/loop0 /mnt/ +```bash +get_interface_mac() +{ + ip link show | awk '/^[0-9]+: [A-Za-z0-9]+:/ { device=$2; gsub(/:/, "",device)} /link\/ether/ { print device " " $2 }' +} ``` -Structure as **LXDoNe** demands +by +```bash +get_interface_mac() +{ + ip link show | awk '/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"\@")} /link\/ether/ { print dev[1] " " $2 }' +} ``` -# mkdir /mnt/rootfs -# mv /mnt/* /mnt/rootfs -``` - - -### LXC -**LXC** containers rootfs are located by default in **/var/lib/lxc/container/rootfs**, if they were created as standard directories, if they were created as loop devices, the filesystem should be in the block **/var/lib/lxc/container/rootdev** - -#### Standard Directories -Follow **Block Device Creation** at the beginning of this Document. Then +and, in **/usr/sbin/one-contextd**, add +```bash + elif [ -f /mnt/context.sh ]; then + # for LXD. the deploy driver injects context files into container directly. + cp /mnt/context.sh ${CONTEXT_NEW} ``` -# rsync -av /var/lib/lxc/container/rootfs/ /mnt -``` - - -#### Loop device -Mount the loop device - -``` -# losetup /dev/loop0 /var/lib/lxc/container/rootdev -# mount /dev/loop0 /mnt/ +inside _get_new_context_ function, before ```elif vmware_context ; then```. Should look like this: +```bash + function get_new_context { + CONTEXT_DEV=`blkid -l -t LABEL="CONTEXT" -o device` + if [ -e "$CONTEXT_DEV" ]; then + mount -t iso9660 -L CONTEXT -o ro /mnt + if [ -f /mnt/context.sh ]; then + cp /mnt/context.sh ${CONTEXT_NEW} + fi + + echo "umount /mnt" > ${END_CONTEXT} + elif [ -f /mnt/context.sh ]; then + # for LXD. the deploy driver injects context files into container directly. + cp /mnt/context.sh ${CONTEXT_NEW} + elif vmware_context ; then + vmtoolsd --cmd 'info-get guestinfo.opennebula.context' | \ + openssl base64 -d > ${CONTEXT_NEW} + elif curl -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data ; then + echo -n "" + fi +} ``` -Structure as **LXDoNe** demands +### Tips +- When using *sudo* as a non-root user inside a container you will likely receive *sudo: no tty present and no askpass program specified*. When appending -S to sudo this gets fixed. It would be a good idea to create an alias. +- using *su* behaves abnormally too, but the fix for this is not that comfortable. Refer to [this lxd issue](https://github.com/lxc/lxd/issues/3218) +- This strange behaviour occurs when entering by *lxc exec*, when you log by ssh things work normal. +- When login occurs via svncterm (which is the same as *lxc exec*), entering backspace key prints *^H* instead of deleting the last character. Replace *ERASECHAR 0177* by *ERASECHAR 010* in **/etc/login.defs** to correct this. Ctrl+U keybinding deletes the whole line in the login prompt. -``` -# mkdir /mnt/rootfs -# mv /mnt/* /mnt/rootfs -``` +### Modify LXD-metadata +In order to populate **/etc/hosts** and **/etc/hostname** inside the container managed by OpenNebula. We'll need to modify container metadata. - -## Custom container -If you already have a custom container go to the end of the mehod to dump the container into the raw image. Your container is located in **/var/lib/lxd/containers/*your_container/*** +In **/var/lib/lxd/lxdone/metadata.yaml** replace - -### Creation ``` -# lxc launch images:16.04 lxdone + "/etc/hostname": { + "template": "hostname.tpl", + "when": [ + "create", + "copy" + ] + }, + "/etc/hosts": { + "template": "hosts.tpl", + "when": [ + "create", + "copy" + ] ``` - -#### Note: -The above command downloads a base image from [linuxcontainers.org](https://images.linuxcontainers.org). - -Now you should have a container named **lxdone** running and . To check the container state: +by ``` -# lxc list + "templates": { + "/etc/hostname": { + "template": "hostname.tpl", + "when": [ + "start" + ] + }, + "/etc/hosts": { + "template": "hosts.tpl", + "when": [ + "start" + ] ``` -The output should be like this: +Apply custom hooks -``` -+---------+---------+---------------------+------+------------+-----------+ -| NAME | STATE | IPV4 | IPV6 | TYPE | SNAPSHOTS | -+---------+---------+---------------------+------+------------+-----------+ -| lxdone | RUNNING | | | PERSISTENT | 0 | -+---------+---------+---------------------+------+------------+-----------+ +```bash +echo "{{ config_get("user.hostname", "lxdone")}}" > /var/lib/lxd/lxdone/templates/hostname.tpl +sudo sed -i 's/127.0.1.1 {{ container.name }}/127.0.1.1 {{ config_get("user.hostname", "lxdone")}}/' /var/lib/lxd/lxdone/templates/hosts.tpl ``` - -### Networking (optional) -If you want to enable networking the container, just add a nic. +## Dump container into raw image -``` -$ lxc config device add lxdone eth0 nic nictype=bridged parent=lxcbr0 -``` +Check how much space your container needs. - -### Shell spawn +```bash +sudo du -sh /var/lib/lxd/containers/lxdone/ +``` -By default all commands in a LXD container are executed by root +Push container into block device. You may change the 1G size. The minimum required is a little bigger than the previous output. -``` -# lxc exec lxdone bash -# root@lxdone: +```bash +lxc stop lxdone +truncate -s 1G /var/tmp/lxdone.img +loop=$(sudo losetup --find --show /var/tmp/lxdone.img) +sudo mkfs.ext4 $loop +sudo mount $loop /mnt/ +sudo cp -rpa sudo du -sh /var/lib/lxd/containers/lxdone/* /mnt/ ``` - -#### Container tweaking: -Customize your container all you want +Make sure there were no errors regarding space in the previous output. -``` -root@lxdone: apt install one-context -root@lxdone: passwd -...... -...... -root@lxdone: exit -# lxc stop lxdone +```bash +sudo umount $loop +sudo losetup -d $loop ``` - -### Dump container into raw image -``` -# rsync -av /var/lib/lxd/containers/lxdone/ /mnt/ -``` +Optionally compress your image. This is useful if you copy it to **/var/tmp/** in the frontend, extract it there and upload via "Path in OpenNebula server" in the image upload section in Sunstone. + +```bash +tar cvJpf lxdone-custom.tar.xz lxdone.img +``` \ No newline at end of file diff --git a/README.md b/README.md index 8b3db32..4bd89d2 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@
-[![LXDoNe](https://img.shields.io/badge/release-1707-3c97f3.svg?style=flat-square)](https://github.com/OpenNebula/addon-lxdone/releases) +[![LXDoNe](https://img.shields.io/badge/release-5.2--4.1-3c97f3.svg?style=flat-square)](https://github.com/OpenNebula/addon-lxdone/releases) [![Twitter](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=I%20want%20freedom.%20I%20want%20efficiency.%20Faster%20private%20clouds%20for%20everyone.%20%23LXDoNe%20%2B%20%40opennebula%20%3D%20performance%20⚡️%20https%3A%2F%2Fgithub.com/OpenNebula/addon-lxdone%2F&source=webclient) [![LXD](https://img.shields.io/badge/lxd-LTS-orange.svg?style=flat-square)](https://linuxcontainers.org/lxd/) @@ -38,7 +38,7 @@ The master branch is subject to changes. We recomend to use one of the stables [ - **Akihiko Ota** [@sw37th] # Compatibility -**LXDoNe** is not an update of **LXCoNe** so your old containers won't be manageable out of the box, but you can adapt them to the new image format, read [Virtual Appliance](Image.md). +**LXDoNe** is not an update of **LXCoNe** so your old containers won't be manageable out of the box. Default compressed LXD images won't work either. For more information read [Virtual Appliance](Image.md). ## Tested OpenNebula versions [![OpenNebula](https://img.shields.io/badge/one-5.2.1-blue.svg?style=flat-square)](https://opennebula.org) @@ -51,7 +51,7 @@ The master branch is subject to changes. We recomend to use one of the stables [ Check the [Setup Guide](Setup.md) to deploy a working scenario. # Features -## 1702 +## [5.2-1](https://github.com/OpenNebula/addon-lxdone/releases/tag/v5.2-1) - Life cycle control: - Start and Poweroff - Reboot and Reset @@ -76,17 +76,17 @@ Check the [Setup Guide](Setup.md) to deploy a working scenario. - Contextualization compatibility - 802.1Q network driver compatibility -## 1703 +## [5.2-2](https://github.com/OpenNebula/addon-lxdone/releases/tag/v5.2-2) - Virtual Appliance creation script -## 1705 +## [5.2-3.1](https://github.com/OpenNebula/addon-lxdone/releases/tag/v5.2-3.1) - NIC Hotplug -- Virtual Appliance uploaded to [google drive](https://drive.google.com/uc?export=download&confirm=FkpQ&id=0B97YSqohwcQ0bTFRUE5RMmphT1U) +- Virtual Appliance uploaded - Enhanced buildimg.sh, thanks @sw37th + Bugfixes + Included auto-contextualization -## 1707 +## [5.2-4](https://github.com/OpenNebula/addon-lxdone/releases/tag/v5.2-4) - [VNC fixed](https://github.com/OpenNebula/addon-lxdone/issues/6) - Context reworked - Logs reworked @@ -95,16 +95,22 @@ Check the [Setup Guide](Setup.md) to deploy a working scenario. - nesting - vmm scripts execution times reduced 40-60% +## [5.2-4.1](https://github.com/OpenNebula/addon-lxdone/releases/tag/v5.2-4.1) +- Base image updated with new context and dotfiles +- Virtual Appliance generation guide reworked +- Poll minor bug fixed + ## TODO -- Full live VM configurations - Use password in VNC -- Use updated svncterm 1.5-2 -- Create ubuntu package for lxdone releases -- Create ubuntu package for custom context -- Snapshots - Bandwidth limitation -- LVM storage backend +- Snapshots +- Code migration to Python 3 +- IO throttling +- Create ubuntu package for custom context +- Create ubuntu package for lxdone releases +- Use updated svncterm 1.5-2 +- Full live VM configurations - Migration +- LVM storage backend +- Use Ceph with LXD native support - HDD Hotplug -- Use Ceph with LXD future native support -- Code migration to Python 3 diff --git a/Setup.md b/Setup.md index 6693c27..bde397c 100644 --- a/Setup.md +++ b/Setup.md @@ -11,13 +11,10 @@ The purpose of this guide is to create a fully functional working environment. Y - [2 - Virtualization Node setup](#2---virtualization-node-setup) - [2.1 Install required packages](#21-install-required-packages) - [2.2 VNC server](#22-vnc-server) - - [2.3 LXD Bridge \(optional\)](#23-lxd-bridge-optional) - [2.4 oneadmin](#24-oneadmin) - [2.5 Loop devices](#25-loop-devices) - [2.6 LXD](#26-lxd) - [3 - Virtual Appliance](#3---virtual-appliance) - - [3.1 Copying from an image server](#31-copying-from-an-image-server) - - [3.2 Export](#32-export) - [4 - Usage](#4---usage) - [4.1 Image Upload](#41-image-upload) - [4.2 Virtualization node](#42-virtualization-node) @@ -34,48 +31,48 @@ The purpose of this guide is to create a fully functional working environment. Y ## 1.1 Installation -Follow [OpenNebula Deployment Guide](https://docs.opennebula.org/5.2/deployment/opennebula_installation/frontend_installation.html) to deploy a fully functional OpenNebula frontend. +Follow [frontend installation](https://docs.opennebula.org/5.2/deployment/opennebula_installation/frontend_installation.html) in OpenNebula deployment guide. ## 1.2 LXDoNe integration -**LXDoNe** is a set of scripts functioning as virtualization and monitorization drivers, so they have to be integrated to the ***frontend***. - +**LXDoNe** is a set of scripts operating as virtualization and monitorization drivers, so they have to be integrated to the ***frontend***. ### 1.2.1 Drivers -Download the addon: +Download the [latest release](https://github.com/OpenNebula/addon-lxdone/releases/) and untar it: ```bash -git clone https://github.com/OpenNebula/addon-lxdone.git -cd addon-lxdone +tar -xf .tar.gz ``` Copy scripts to oneadmin drivers directory: -``` +```bash +cd cp -rpa src/remotes/ /var/lib/one/ ``` Set the appropriate permissions -``` -sudo cd /var/lib/one/remotes/ +```bash +cd /var/lib/one/remotes/ sudo chown -R oneadmin:oneadmin vmm/lxd im/lxd* sudo chmod 755 -R vmm/lxd im/lxd* sudo chmod 644 im/lxd.d/collectd-client.rb +cd - ``` ### Optional. Add support for 802.1Q driver (VLANs). -Replace /var/lib/one/remotes/vnm.rb file. +Replace /var/lib/one/remotes/vnm.rb file for ur modified version. -``` +```bash cp -rpa src/one_wait/nic.rb /var/lib/one/remotes/vnm/nic.rb sudo chown oneadmin:oneadmin /var/lib/one/remotes/vnm/nic.rb sudo chmod 755 /var/lib/one/remotes/vnm/nic.rb ``` #### Note -> A pull request was made to add this functionality to OpenNebula's official Network Driver. +> A pull request was made to OpenNebula's official Network Driver to add this functionality by default. ### 1.2.2 Enable LXD @@ -113,82 +110,63 @@ IMPORTED_VMS_ACTIONS = "migrate, live-migrate, terminate, terminate-hard, undepl ``` +Restart OpenNebula + +```bash +sudo systemctl restart opennebula +``` + # 2 - Virtualization Node setup Follow [KVM Node Installation](https://docs.opennebula.org/5.2/deployment/node_installation/kvm_node_installation.html#), up to [step 6](https://docs.opennebula.org/5.2/deployment/node_installation/kvm_node_installation.html#step-6-storage-configuration). If you want to use Ceph to store Virtual Images, follow [Ceph Datastore Guide](https://docs.opennebula.org/5.2/deployment/open_cloud_storage_setup/ceph_ds.html) and configure it just as you would for KVM. +#### Note +> ***opennebula-node*** package installs kvm-required software. You may remove most of them and/or disable services like libvirt-bin as they aren't required by LXD. Don't remove libvirt package, it is required for ceph storage. + ## 2.1 Install required packages -``` -sudo apt install lxd lxd-tools criu bridge-utils python-pylxd python-ws4py python-pip +```bash +sudo apt install lxd lxd-tools python-pylxd/xenial-updates criu bridge-utils python-ws4py python-pip ``` #### Note -> Be sure to have **pylxd 2.0.5**, or the driver **won't work properly**. Check the last output of the command below. You can find it on xenial-updates repositories. - -``` -sudo apt show python-pylxd | grep 2.0.5 | grep 2.0.5 -``` +> Be sure to have **pylxd 2.0.5**, or the driver **won't work properly**. Install isoparser by pip -``` +```bash sudo pip install isoparser ``` ## 2.2 VNC server -**LXDoNe** uses **svncterm** by **dealfonso@github** as **VNC** server. This package enables the **VNC** option in the VM template definition. It's already compiled for Ubuntu 16.04. Install the required dependencies from repositories. - -``` -sudo dpkg -i svncterm_1.2-1ubuntu_amd64.deb -``` - - -## 2.3 LXD Bridge (optional) -**LXD** comes by default with an optional bridge called **lxdbr0**, it offers ease of use for containers networking and provides DHCP suport. We can use this bridge alternative configuration to standard OpenNebula networking: +**LXDoNe** uses **svncterm** by **dealfonso@github** as **VNC** server. This enables the **VNC** option in the VM template definition. We compiled and provided it for Ubuntu 16.04 in our releases. Download it from the [latest release](https://github.com/OpenNebula/addon-lxdone/releases/) and install the required dependencies from repositories. -``` -sudo echo -e " USE_LXD_BRIDGE="true" \n -LXD_BRIDGE="lxdbr0" \n -UPDATE_PROFILE="true" \n -LXD_CONFILE="" \n -LXD_DOMAIN="lxd" \n -LXD_IPV4_ADDR="192.168.1.1" \n -LXD_IPV4_NETMASK="255.255.255.0" \n -LXD_IPV4_NETWORK="192.168.1.1/24" \n -LXD_IPV4_DHCP_RANGE="192.168.1.2,192.168.1.254" \n -LXD_IPV4_DHCP_MAX="252" \n -LXD_IPV4_NAT="true" \n -LXD_IPV6_ADDR="" \n -LXD_IPV6_MASK="" \n -LXD_IPV6_NETWORK="" \n -LXD_IPV6_NAT="false" \n -LXD_IPV6_PROXY="false" " > /etc/default/lxd-bridge -# service lxd-bridge restart +```bash +sudo dpkg -i /svncterm_1.2-1ubuntu_amd64.deb ``` ## 2.4 oneadmin -Allow oneadmin to execute commands as root and add it to lxd group +Allow oneadmin to execute commands as root and add it to lxd group. Run as root: -``` -sudo echo "oneadmin ALL= NOPASSWD: ALL" >> /etc/sudoers -sudo adduser oneadmin lxd +```bash +echo "oneadmin ALL= NOPASSWD: ALL" >> /etc/sudoers +adduser oneadmin lxd ``` ## 2.5 Loop devices -Every file system image used by **LXDoNe** will require one ***loop device***. The default limit for ***loop devices*** is 8, so it needs to be increased. +Every file system image used by **LXDoNe** will require one ***loop device***. The default limit for ***loop devices*** is 8, so it needs to be increased. Run as root: -``` -sudo echo "options loop max_loop=128" >> /etc/modprobe.d/local-loop.conf -sudo echo "loop" >> /etc/modules -sudo depmod +```bash +echo "options loop max_loop=128" >> /etc/modprobe.d/local-loop.conf +echo "loop" >> /etc/modules-load.d/modules.conf +depmod ``` @@ -198,7 +176,7 @@ sudo depmod ### 2.6.1 Daemon This is the daemon configuration we'll use -``` +```bash sudo lxd init --auto \ --storage-backend dir \ --network-address 0.0.0.0 \ @@ -211,113 +189,38 @@ sudo lxd init --auto \ Containers inherit properties from a profile. #### Network -The default profile contains a network device, we'll remove this one as it's not managed by OpenNebula. +The default profile contains a network device, we'll remove this one as isn't managed by OpenNebula. -``` -sudo lxc profile device remove default eth0 +```bash +lxc profile device remove default eth0 ``` #### Security & Nesting: -We moved from privileged containers to unprivileged containers by default and supported nesting since LXDoNe 1707. More of this [here](http://linuxcontainers.org/lxc/security/#privileged-containers) and [here](https://insights.ubuntu.com/2016/04/15/lxd-2-0-lxd-in-lxd-812/). It is no longer required the use of a default profile with ***security.privileged: true***. - - -# 3 - Virtual Appliance -A virtual appliance is available at the [marketplace](https://marketplace.opennebula.systems/appliance/7dd50db7-33c4-4b39-940c-f6a55432622f). Also, we've uploaded a base container to [google drive](http://https://drive.google.com/uc?export=download&confirm=FkpQ&id=0B97YSqohwcQ0bTFRUE5RMmphT1U). The image creation tweaks are covered in depth [here](Image.md), but we wont update it anymore, for simplicity we show just a method in this guide. You can SKIP to [step 4](Setup.md#4---usage) if google drive or marketplace works for you, we STRONGLY recommend it. Also there is a script [build-img.sh](image-handling/build-img.sh) that automates the process. - - -## 3.1 Copying from an image server -Copy an image into local image store. +We moved from privileged containers to unprivileged containers by default and supported nesting since LXDoNe 5.2-4. More about this [here](http://linuxcontainers.org/lxc/security/#privileged-containers) and [here](https://insights.ubuntu.com/2016/04/15/lxd-2-0-lxd-in-lxd-812/). It is no longer required the use of a default profile with ***security.privileged: true***. Remove it if you had it: +```bash +lxc profile unset default security.privileged ``` -lxc image copy ubuntu: local: --alias ubuntu1604 -``` - - -## 3.2 Export -Export the image from LXD local image store to current directory. Maybe will create two tarballs. - -``` -lxc image export ubuntu1604 -ls -l --rw------- 1 oneadmin oneadmin 126715472 May 30 15:29 8fa08537ae51c880966626561987153e72d073cbe19dfe5abc062713d929254d.tar.xz --rw------- 1 oneadmin oneadmin 840 May 30 15:29 meta-8fa08537ae51c880966626561987153e72d073cbe19dfe5abc062713d929254d.tar.xz -``` - -### 3.3 Extract tarballs -``` -sudo mkdir -p image/rootfs -cd image -sudo tar xvpf ../8fa08537ae51c880966626561987153e72d073cbe19dfe5abc062713d929254d.tar.xz -C rootfs -sudo tar xvpf ../meta-8fa08537ae51c880966626561987153e72d073cbe19dfe5abc062713d929254d.tar.xz -ls -l image --rw-r--r-- 1 root root 1566 May 16 15:26 metadata.yaml -drwxr-xr-x 22 root root 4096 May 31 14:29 rootfs -drwxr-xr-x 2 root root 4096 May 16 15:26 templates -``` - -### 3.4 Install one-context package (optional) -Download one-context_*.deb package if you use OpenNebula CONTEXT scripts instead of cloud-init - -``` -wget https://github.com/OpenNebula/addon-context-linux/releases/download/v5.0.3/one-context_5.0.3.deb -sudo mv one-context_5.0.3.deb rootfs/ -``` - -Chroot to rootfs/ - -``` -sudo chroot rootfs/ /bin/bash -``` - -Install one-context and disable cloud-init - -``` -sudo dpkg -i ./one-context_5.0.3.deb -sudo systemctl disable cloud-init.service cloud-init-local.service cloud-final.service cloud-config.service -exit -``` - -Overwrite modified context - -``` -sudo cp -p /path/to/addon-lxdone/src/one-wait/10-network rootfs/etc/one-context.d -sudo cp -p /path/to/addon-lxdone/src/one-wait/one-contextd rootfs/usr/sbin -``` -Set the appropriate permissions -``` -sudo chown root:root rootfs/usr/sbin/one-contextd rootfs/etc/one-context.d/10-network -sudo chmod 755 rootfs/usr/sbin/one-contextd rootfs/etc/one-context.d/10-network -``` +### 2.6.3 User IDs -### 3.5 Block Device creation -At the end of every one of the previous methods you'll have to save your work in a raw image that will be uploaded to a Datastore. So regardless the method you choose you'll have to do this before beginning the method, except for **LXCoNe**: +Check your ***/etc/subuid*** and ***/etc/subgid*** files has the following entries for lxd and root. ```bash -truncate -s G /var/tmp/lxdone.img -loop=$(sudo losetup --find --show /var/tmp/lxdone.img) -mkfs.ext4 $loop -mount $loop /mnt/ +lxd:100000:65536 +root:100000:65536 ``` -Check you are in the image root folder cheking the output of ***ls -lh*** : - -```bash -total 16K --r-------- 1 root root 1.5K Jan 31 00:38 backup.yaml --rw-r--r-- 1 root root 1.4K Jan 26 16:36 metadata.yaml -drwxr-xr-x 21 root root 4.0K May 15 15:49 rootfs -drwxr-xr-x 2 root root 4.0K Nov 2 2016 templates -``` + +# 3 - Virtual Appliance +A virtual appliance is available at the [marketplace](https://marketplace.opennebula.systems/appliance/7dd50db7-33c4-4b39-940c-f6a55432622f). Also, we've uploaded a base container to online storage service providers. This is a compressed raw block tarball, just extract it before uploading to OpenNebula. You'll have a 1GB image, if you require more space, just copy the contents (keeping the same file permissions and ownership) to a bigger block device. The team user has *team* password: -And copy cotents to block device +- [google drive](https://drive.google.com/open?id=0B6vgzbpLofKjbXFzTjI1QmZ4X1U) +- [mega](https://mega.nz/#!U8pXxBpI!2UjFmQO8Fr8hz5oHt7z6QeIqYR3ziZ74OcNP1HByO4c) +- [dropbox](https://www.dropbox.com/s/p9s1tzc47tpgxqg/lxdone-5.2-4.1.img.tar.xz?dl=0) -``` -sudo cp -rpa * /mnt/ -sudo umount $loop -sudo losetup -d $loop -``` +You can generate your custom image following [Image.md](Image.md) but we encourage you to use the ones we've uploaded, since it can get a bit tricky. # 4 - Usage @@ -384,6 +287,8 @@ Upload the Virtual Appliance to OpenNebula. > VCPU stands for the amount of cores the container can use, if the container if you leave it blank, the container will use all the cores up to a fraction defined by CPU. > ex. for a host with 8 CPUs, if the VM template states 2 VCPU, then the container has 2/8 CPUs allocated. +![](picts/template.png) + ### Optional data: * Network: * Select one or many network interfaces. They will appear inside the container configured. @@ -395,9 +300,8 @@ Upload the Virtual Appliance to OpenNebula. * LXD_SECURITY_PRIVILEGED = '**true**' for make the container privileged. -![](picts/template.png) -![Alt text](/home/dann1/Projects/addon-lxdone/picts/lxd-security.png "Optional title") +![](picts/lxd-security.png) ## 4.6 Deploy diff --git a/image-handling/bash-enhancements/.bash-functions.sh b/image-handling/bash-enhancements/.bash-functions.sh deleted file mode 100755 index e0cbd55..0000000 --- a/image-handling/bash-enhancements/.bash-functions.sh +++ /dev/null @@ -1,50 +0,0 @@ -#!/bin/bash - -extract() { - local c e i - - (($#)) || return - - for i; do - c='' - e=1 - - if [[ ! -r $i ]]; then - echo "$0: file is unreadable: \`$i'" >&2 - continue - fi - - case $i in - *.t@(gz|lz|xz|b@(2|z?(2))|a@(z|r?(.@(Z|bz?(2)|gz|lzma|xz))))) - c=(tar xvf);; - *.7z) c=(7z x);; - *.Z) c=(uncompress);; - *.bz2) c=(bunzip2);; - *.exe) c=(cabextract);; - *.gz) c=(gunzip);; - *.rar) c=(unrar x);; - *.xz) c=(unxz);; - *.zip) c=(unzip);; - *) echo "$0: unrecognized file extension: \`$i'" >&2 - continue;; - esac - - command "${c[@]}" "$i" - ((e = e || $?)) - done - return "$e" -} - -cl() { - local dir="$1" - local dir="${dir:=$HOME}" - if [[ -d "$dir" ]]; then - cd "$dir" >/dev/null; ls -hall - else - echo "bash: cl: $dir: Directory not found" - fi -} - -calc() { - echo "scale=3;$@" | bc -l -} \ No newline at end of file diff --git a/image-handling/bash-enhancements/.bashrc b/image-handling/bash-enhancements/.bashrc deleted file mode 100755 index 9bf87da..0000000 --- a/image-handling/bash-enhancements/.bashrc +++ /dev/null @@ -1,131 +0,0 @@ -# ~/.bashrc: executed by bash(1) for non-login shells. -# see /usr/share/doc/bash/examples/startup-files (in the package bash-doc) -# for examples - -# If not running interactively, don't do anything -[ -z "$PS1" ] && return - -# don't put duplicate lines in the history. See bash(1) for more options -# ... or force ignoredups and ignorespace -HISTCONTROL=ignoredups:ignorespace - -# append to the history file, don't overwrite it -shopt -s histappend - -# for setting history length see HISTSIZE and HISTFILESIZE in bash(1) -HISTSIZE=1000 -HISTFILESIZE=2000 - -# check the window size after each command and, if necessary, -# update the values of LINES and COLUMNS. -shopt -s checkwinsize - -# make less more friendly for non-text input files, see lesspipe(1) -[ -x /usr/bin/lesspipe ] && eval "$(SHELL=/bin/sh lesspipe)" - -# set variable identifying the chroot you work in (used in the prompt below) -if [ -z "$debian_chroot" ] && [ -r /etc/debian_chroot ]; then - debian_chroot=$(cat /etc/debian_chroot) -fi - -# set a fancy prompt (non-color, unless we know we "want" color) -case "$TERM" in - xterm-color) color_prompt=yes;; -esac - -# uncomment for a colored prompt, if the terminal has the capability; turned -# off by default to not distract the user: the focus in a terminal window -# should be on the output of commands, not on the prompt -#force_color_prompt=yes - -if [ -n "$force_color_prompt" ]; then - if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then - # We have color support; assume it's compliant with Ecma-48 - # (ISO/IEC-6429). (Lack of such support is extremely rare, and such - # a case would tend to support setf rather than setaf.) - color_prompt=yes - else - color_prompt= - fi -fi - -if [ "$color_prompt" = yes ]; then - PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' -else - PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w\$ ' -fi -unset color_prompt force_color_prompt - -# If this is an xterm set the title to user@host:dir -case "$TERM" in -xterm*|rxvt*) - PS1="\[\e]0;${debian_chroot:+($debian_chroot)}\u@\h: \w\a\]$PS1" - ;; -*) - ;; -esac - -# enable color support of ls and also add handy aliases -if [ -x /usr/bin/dircolors ]; then - test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)" - alias ls='ls --color=auto' - #alias dir='dir --color=auto' - #alias vdir='vdir --color=auto' - - alias grep='grep --color=auto' - alias fgrep='fgrep --color=auto' - alias egrep='egrep --color=auto' -fi - -# some more ls aliases -alias ll='ls -alF' -alias la='ls -A' -alias l='ls -CF' - -# Alias definitions. -# You may want to put all your additions into a separate file like -# ~/.bash_aliases, instead of adding them here directly. -# See /usr/share/doc/bash-doc/examples in the bash-doc package. - -if [ -f ~/.bash_aliases ]; then - . ~/.bash_aliases -fi - -# enable programmable completion features (you don't need to enable -# this, if it's already enabled in /etc/bash.bashrc and /etc/profile -# sources /etc/bash.bashrc). -#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then -# . /etc/bash_completion -#fi - -#. ~/.bash_ps - -shopt -s autocd -shopt -s extglob -export HISTCONTROL=ignoredups -alias ls='ls --color=auto' -alias ll='ls -lah' - -GREEN="\[$(tput setaf 46)\]" -BLUE="\[$(tput setaf 26)\]" -RED="\[$(tput setaf 196)\]" -RESET="\[$(tput sgr0)\]" - -exitstatus() -{ - if [[ $? == 0 ]]; then - echo -en '\033[1;32m'":)"'\E(B\E[m' - else - echo -en '\033[1;31m'":("'\E(B\E[m' - fi -} -if [[ $USER == 'root' ]]; then - color=${RED} -else - color=${BLUE} -fi - -export PS1='$(exitstatus) '"${color}\u${BLUE}@\h:\W\$${RESET} " - -source $HOME/.bash-functions.sh - diff --git a/image-handling/bash-enhancements/.directory b/image-handling/bash-enhancements/.directory deleted file mode 100644 index 97afbc3..0000000 --- a/image-handling/bash-enhancements/.directory +++ /dev/null @@ -1,4 +0,0 @@ -[Dolphin] -Timestamp=2017,3,6,15,12,24 -Version=3 -ViewMode=1 diff --git a/image-handling/bash-enhancements/.inputrc b/image-handling/bash-enhancements/.inputrc deleted file mode 100644 index 5a53eaf..0000000 --- a/image-handling/bash-enhancements/.inputrc +++ /dev/null @@ -1 +0,0 @@ -set show-all-if-ambiguous on diff --git a/image-handling/build-img.sh b/image-handling/build-img.sh deleted file mode 100755 index 9e8d97c..0000000 --- a/image-handling/build-img.sh +++ /dev/null @@ -1,141 +0,0 @@ -#!/usr/bin/env bash - -dpkg --listfiles debootstrap > /dev/null 2>&1 - -if [[ $? -ne 0 ]]; then - echo "debootstrap is required in order to crete container, press ENTER to continue" - read - apt install -y debootstrap - if [[ $? -ne 0 ]]; then - echo "failed to install debootstrap check your mirror configuration" - exit -1 - fi - echo -fi - - -for i in "size (default=600MB)" "release (default=xenial)" "repository (default=http://archive.ubuntu.com/ubuntu/)" "contexturl (default=https://github.com/OpenNebula/addon-context-linux/releases/download/v5.0.3/one-context_5.0.3.deb)"; do - echo "Enter "$i - var=$(echo $i | awk '{print $1}') - read $var -done - -if [[ -z $release ]]; then - release='xenial' -fi - -if [[ -z $repository ]]; then - repository='http://archive.ubuntu.com/ubuntu/' -fi - -if [[ -z $size ]]; then - size=600M -fi - -if [[ -z $contexturl ]]; then - contexturl=https://github.com/OpenNebula/addon-context-linux/releases/download/v5.0.3/one-context_5.0.3.deb -fi - -truncate -s $size lxdone.img -img=$(losetup --find --show lxdone.img) -mkfs.ext4 $img -mkdir -p ./lxdone -mount $img ./lxdone - -echo "creating $release linux filesystem from $repository this may take a while" -mkdir -p ./lxdone/rootfs -debootstrap $release ./lxdone/rootfs $repository - -if [[ $? -ne 0 ]]; then - umount $img - losetup -d $img - exit -1 -fi - -moment=$(date +%s) -arch=$(uname --machine) - -cat << EOT > ./lxdone/metadata.yaml - -{ - "architecture": "$arch", - "creation_date": $moment, - "templates": { - "/etc/hostname": { - "template": "hostname.tpl", - "when": [ - "start" - ] - }, - "/etc/hosts": { - "template": "hosts.tpl", - "when": [ - "start" - ] - }, - "/etc/init/console.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty1.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty2.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty3.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty4.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - } - } -} - -EOT - -mkdir -p ./lxdone/templates -cat << EOT > ./lxdone/templates/hosts.tpl -127.0.0.1 localhost -127.0.1.1 {{ config_get("user.hostname", "lxdone")}} - -# The following lines are desirable for IPv6 capable hosts -::1 ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters - -EOT - -echo "{{ config_get("user.hostname", "lxdone")}}" > ./lxdone/templates/hostname.tpl -echo "manual" > ./lxdone/templates/upstart-override.tpl - -cp -p $(dirname $0)/bash-enhancements/.[a-zA-Z]* ./lxdone/rootfs/root -chown root:root ./lxdone/rootfs/root/.[a-zA-Z]* - -wget -P ./lxdone/rootfs/root $contexturl -if [[ $? -eq 0 ]]; then - contextdeb=./lxdone/rootfs/root/$(basename $contexturl) - if [[ -f $contextdeb ]]; then - dpkg -i --root=./lxdone/rootfs/ --instdir=./lxdone/rootfs/ --admindir=./lxdone/rootfs/var/lib/dpkg ./$contextdeb - sed -i 's%\(^[ \t]*ip link show | \).*$%\1awk '\''/^[0-9]+: [A-Za-z0-9@]+:/ { device=$2; gsub(/:/, "",device); split(device,dev,"\\@")} /link\\/ether/ { print dev[1] " " $2 }'\''%' ./lxdone/rootfs/etc/one-context.d/10-network - fi -fi - -umount $img -losetup -d $img diff --git a/metadata/metadata.yaml b/metadata/metadata.yaml deleted file mode 100644 index 3171931..0000000 --- a/metadata/metadata.yaml +++ /dev/null @@ -1,56 +0,0 @@ -{ - "architecture": "x86_64", - "creation_date": 1478058540, - "properties": { - "architecture": "x86_64", - "description": "ubuntu xenial x86_64 (default) (20161102_03:49)", - "name": "ubuntu-xenial-x86_64-default-20161102_03:49", - "os": "ubuntu", - "release": "xenial", - "variant": "default" - }, - "templates": { - "/etc/hostname": { - "template": "hostname.tpl", - "when": [ - "start" - ] - }, - "/etc/hosts": { - "template": "hosts.tpl", - "when": [ - "start" - ] - }, - "/etc/init/console.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty1.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty2.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty3.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - }, - "/etc/init/tty4.override": { - "template": "upstart-override.tpl", - "when": [ - "create" - ] - } - } -} diff --git a/metadata/templates/hostname.tpl b/metadata/templates/hostname.tpl deleted file mode 100644 index a587797..0000000 --- a/metadata/templates/hostname.tpl +++ /dev/null @@ -1 +0,0 @@ -{{ config_get("user.hostname", "lxdone")}} diff --git a/metadata/templates/hosts.tpl b/metadata/templates/hosts.tpl deleted file mode 100644 index b3cbfec..0000000 --- a/metadata/templates/hosts.tpl +++ /dev/null @@ -1,9 +0,0 @@ -127.0.0.1 localhost -127.0.1.1 {{ config_get("user.hostname", "lxdone")}} - -# The following lines are desirable for IPv6 capable hosts -::1 ip6-localhost ip6-loopback -fe00::0 ip6-localnet -ff00::0 ip6-mcastprefix -ff02::1 ip6-allnodes -ff02::2 ip6-allrouters diff --git a/metadata/templates/upstart-override.tpl b/metadata/templates/upstart-override.tpl deleted file mode 100644 index 2905494..0000000 --- a/metadata/templates/upstart-override.tpl +++ /dev/null @@ -1 +0,0 @@ -manual diff --git a/picts/containers.png b/picts/containers.png deleted file mode 100644 index e344c1d..0000000 Binary files a/picts/containers.png and /dev/null differ diff --git a/picts/image.png b/picts/image.png deleted file mode 100644 index 029e4fb..0000000 Binary files a/picts/image.png and /dev/null differ diff --git a/picts/template1.png b/picts/template1.png deleted file mode 100644 index 27739e8..0000000 Binary files a/picts/template1.png and /dev/null differ diff --git a/src/context/10-network b/src/context/10-network deleted file mode 100644 index 2ad5d1c..0000000 --- a/src/context/10-network +++ /dev/null @@ -1,205 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2010-2016, 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. # -#--------------------------------------------------------------------------- # - -# Gets IP address from a given MAC -mac2ip() { - mac=$1 - - let ip_a=0x`echo $mac | cut -d: -f 3` - let ip_b=0x`echo $mac | cut -d: -f 4` - let ip_c=0x`echo $mac | cut -d: -f 5` - let ip_d=0x`echo $mac | cut -d: -f 6` - - ip="$ip_a.$ip_b.$ip_c.$ip_d" - - echo $ip -} - -# Gets the network part of an IP -get_network() { - network=$(get_iface_var "NETWORK") - - if [ -z "$network" ]; then - network="$(echo $IP | cut -d'.' -f1,2,3).0" - fi - - echo $network -} - -# Gets the network mask -get_mask() { - mask=$(get_iface_var "MASK") - - if [ -z "$mask" ]; then - mask="255.255.255.0" - fi - - echo $mask -} - -# Gets device MTU -get_mtu() { - mtu=$(get_iface_var "MTU") - - echo $mtu -} - -is_gateway() { - if [ -z "$GATEWAY_IFACE_NUM" ]; then - true - else - [ "$IFACE_NUM" = "$GATEWAY_IFACE_NUM" ] - fi -} - -# Gets the network gateway -get_gateway() { - if is_gateway; then - gateway=$(get_iface_var "GATEWAY") - - echo $gateway - fi -} - -# Gets the network gateway6 -get_gateway6() { - if is_gateway; then - get_iface_var "GATEWAY6" - fi -} - -get_ip() { - ip=$(get_iface_var "IP") - - echo $ip -} - -get_iface_var() { - var_name="${UPCASE_DEV}_$1" - var=$(eval "echo \"\${$var_name}\"") - - echo $var -} - -gen_iface_conf() { - cat < /etc/sysconfig/network-scripts/ifcfg-${DEV} - - ifup ${DEV} - - done -} - -configure_network() -{ - gen_network_configuration - - service network restart - - sleep 2 -} - -[ -z "$(env | cut -d= -f1 | grep -E '^ETH[0-9]+_IPV*6*')" ] && exit 0 - -configure_network \ No newline at end of file diff --git a/src/context/one-contextd b/src/context/one-contextd deleted file mode 100644 index c6bffc3..0000000 --- a/src/context/one-contextd +++ /dev/null @@ -1,123 +0,0 @@ -#!/bin/bash -# -# -------------------------------------------------------------------------- # -# Copyright 2010-2016, 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. # -#--------------------------------------------------------------------------- # - -LOCK_FILE="/var/run/one-context.lock" -CONTEXT_FILE="/tmp/context.sh" -CONTEXT_NEW="${CONTEXT_FILE}.new" -END_CONTEXT="/tmp/context.end" - -function export_rc_vars -{ - if [ -f $1 ] ; then - ONE_VARS=`cat $1 | egrep -e '^[a-zA-Z\-\_0-9]*=' | sed 's/=.*$//'` - - . $1 - - for v in $ONE_VARS; do - export $v - done - fi -} - -function execute_scripts { - SCRIPTS_DIR="/etc/one-context.d" - for script in $SCRIPTS_DIR/*; do - "$script" "$1" - done -} - -function vmware_context { - if type vmtoolsd ; then - if vmtoolsd --cmd 'info-get guestinfo.opennebula.context' >/dev/null 2>&1 ; then - return 0 - fi - fi - - return 1 -} - -function get_new_context { - CONTEXT_DEV=`blkid -l -t LABEL="CONTEXT" -o device` - if [ -e "$CONTEXT_DEV" ]; then - mount -t iso9660 -L CONTEXT -o ro /mnt - if [ -f /mnt/context.sh ]; then - cp /mnt/context.sh ${CONTEXT_NEW} - fi - - echo "umount /mnt" > ${END_CONTEXT} - elif [ -f /mnt/context.sh ]; then - # for LXD. the deploy driver injects context files into container directly. - cp /mnt/context.sh ${CONTEXT_NEW} - elif vmware_context ; then - vmtoolsd --cmd 'info-get guestinfo.opennebula.context' | \ - openssl base64 -d > ${CONTEXT_NEW} - elif curl -o ${CONTEXT_NEW} http://169.254.169.254/latest/user-data ; then - echo -n "" - fi -} - -function check_context { - if [ -s "${CONTEXT_NEW}" ]; then - diff ${CONTEXT_FILE} ${CONTEXT_NEW} >/dev/null 2>&1 && return 1 - return 0 - else - return 1 - fi -} - -function run_context { - cp ${CONTEXT_NEW} ${CONTEXT_FILE} - - export_rc_vars ${CONTEXT_FILE} - execute_scripts "$1" -} - -function end_context { - if [ -e "${END_CONTEXT}" ]; then - sh "${END_CONTEXT}" - rm "${END_CONTEXT}" - fi - [ -e "${CONTEXT_NEW}" ] && rm "${CONTEXT_NEW}" -} - -function acquire_lock { - while true; do - if mkdir "${LOCK_FILE}" 2>/dev/null; then - trap 'cleanup' EXIT - break - fi - - sleep 1 - done -} - -function release_lock { - rm -rf "${LOCK_FILE}" -} - -function cleanup { - end_context - release_lock -} - -COMMAND="$1" - -acquire_lock - -get_new_context -check_context && run_context "$COMMAND" \ No newline at end of file diff --git a/src/remotes/vmm/lxd/deploy.py b/src/remotes/vmm/lxd/deploy.py index a3a066f..d79bc08 100755 --- a/src/remotes/vmm/lxd/deploy.py +++ b/src/remotes/vmm/lxd/deploy.py @@ -93,7 +93,7 @@ def create_profile(xml): def apply_profile(profile, container): """ - apply config and devices and quota to container + apply config and devices to container """ # STORAGE_CONFIG VM_ID = profile['VM_ID'] @@ -118,21 +118,17 @@ def apply_profile(profile, container): try: container.config.update(i) container.save(wait=True) - # lc.log_function('INFO', 'container: ' + i.keys()[0] + ': ' + i[i.keys()[0]]) except LXDAPIException as lxdapie: lc.log_function('ERROR', 'container: ' + i.keys()[0] + ': ' + str(lxdapie)) lc.sys.exit(1) - # del container.config[i.keys()[0]] for i in profile['devices']: try: container.devices.update(i) container.save(wait=True) - # lc.log_function('INFO', 'container: ' + i.keys()[0] + ': added') except LXDAPIException as lxdapie: lc.log_function('ERROR', 'container: ' + i.keys()[0] + ': ' + str(lxdapie)) lc.sys.exit(1) - # del container.config[i.keys()[0]] # READ_XML @@ -159,7 +155,6 @@ def apply_profile(profile, container): try: container.start(wait=True) container.config['user.xml'] # validate config - # lc.log_function('INFO', 'container: ' + VM_NAME + ' running') except LXDAPIException as lxdapie: if container.status == 'Running': container.stop(wait=True) diff --git a/src/remotes/vmm/lxd/lxd_common.py b/src/remotes/vmm/lxd/lxd_common.py index 8b75f37..a844fbc 100755 --- a/src/remotes/vmm/lxd/lxd_common.py +++ b/src/remotes/vmm/lxd/lxd_common.py @@ -186,10 +186,6 @@ def storage_context(container, contextiso): continue container.files.put('/mnt/' + i.name, i.content) -# def storage_context_map(container, CONTEXT_DISK_ID, DISK_SOURCE, DS_ID, VM_ID): - # context_disk = storage_sysmap(CONTEXT_DISK_ID, 'FILE', DISK_SOURCE, VM_ID, DS_ID, None) - # context_disk = {'CONTEXT': {'path': context_disk, 'type': 'unix-block'}} - # container.devices.update(context_disk) # LXD CONFIG MAPPING diff --git a/src/remotes/vmm/lxd/poll_common.py b/src/remotes/vmm/lxd/poll_common.py index 9523f65..5626edc 100755 --- a/src/remotes/vmm/lxd/poll_common.py +++ b/src/remotes/vmm/lxd/poll_common.py @@ -57,7 +57,6 @@ def print_all_vm_template(hypervisor): print string - # vnc_babysiter(info) except: return None diff --git a/svncterm_1.2-1ubuntu_amd64.deb b/svncterm_1.2-1ubuntu_amd64.deb deleted file mode 100644 index 72d54d9..0000000 Binary files a/svncterm_1.2-1ubuntu_amd64.deb and /dev/null differ