From baae300fb8b06e8d0300179c75bb8a697c6af87b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Mon, 2 Feb 2026 19:50:01 +0100 Subject: [PATCH] F #7460: Updates to oneform server - Lint - Add bash completion for oneform commands - Driver state is now stored in /var/lib/one/oneform - Improve rendering of descriptions in CLI (HTML/MD support) - Move cloud providers to oneform registry - Disable dummy driver by default - Qeury paths for driver/provider list co-authored-by: vickmp --- install.sh | 29 ++- .../aws/ansible/roles/iptables/README.md | 17 -- .../ansible/roles/iptables/defaults/main.yaml | 38 --- .../ansible/roles/iptables/tasks/Debian.yml | 14 - .../aws/ansible/roles/iptables/tasks/main.yml | 19 -- .../ansible/roles/iptables/tasks/rules.yml | 124 --------- .../roles/iptables/templates/rules.v4.j2 | 35 --- .../roles/iptables/templates/rules.v6.j2 | 25 -- share/providers/aws/ansible/site.yaml | 34 --- .../aws/ansible/templates/ssh_cluster.j2 | 93 ------- share/providers/aws/driver.conf | 25 -- share/providers/aws/elastic/aws_vnm.rb | 121 --------- share/providers/aws/ipam/allocate_address | 21 -- share/providers/aws/ipam/free_address | 21 -- share/providers/aws/ipam/get_address | 96 ------- .../providers/aws/ipam/register_address_range | 237 ----------------- .../aws/ipam/unregister_address_range | 128 ---------- share/providers/aws/terraform/cluster/main.tf | 80 ------ .../providers/aws/terraform/cluster/output.tf | 11 - .../aws/terraform/cluster/provider.tf | 8 - .../aws/terraform/cluster/variables.tf | 15 -- share/providers/aws/terraform/data.tf | 31 --- share/providers/aws/terraform/host/data.tf | 32 --- share/providers/aws/terraform/host/locals.tf | 6 - share/providers/aws/terraform/host/main.tf | 30 --- share/providers/aws/terraform/host/output.tf | 7 - .../providers/aws/terraform/host/provider.tf | 8 - .../providers/aws/terraform/host/variables.tf | 39 --- share/providers/aws/terraform/locals.tf | 10 - share/providers/aws/terraform/main.tf | 20 -- share/providers/aws/terraform/outputs.tf | 8 - share/providers/aws/terraform/provider.tf | 32 --- share/providers/aws/terraform/validators.tf | 35 --- share/providers/aws/terraform/variables.tf | 35 --- share/providers/dummy/ipam | 1 - share/providers/equinix/ansible/ansible.cfg | 27 -- .../providers/equinix/ansible/inventory.yaml | 1 - .../equinix/ansible/roles/iptables/README.md | 17 -- .../ansible/roles/iptables/defaults/main.yaml | 38 --- .../ansible/roles/iptables/tasks/Debian.yml | 14 - .../ansible/roles/iptables/tasks/main.yml | 19 -- .../ansible/roles/iptables/tasks/rules.yml | 124 --------- .../roles/iptables/templates/rules.v4.j2 | 35 --- .../roles/iptables/templates/rules.v6.j2 | 25 -- share/providers/equinix/ansible/site.yaml | 33 --- .../equinix/ansible/templates/ssh_cluster.j2 | 92 ------- share/providers/equinix/driver.conf | 28 -- share/providers/equinix/elastic/equinix.rb | 40 --- .../providers/equinix/elastic/equinix_vnm.rb | 134 ---------- share/providers/equinix/ipam/allocate_address | 21 -- share/providers/equinix/ipam/free_address | 21 -- share/providers/equinix/ipam/get_address | 94 ------- .../equinix/ipam/register_address_range | 239 ----------------- .../equinix/ipam/unregister_address_range | 122 --------- .../providers/equinix/terraform/host/main.tf | 16 -- .../equinix/terraform/host/outputs.tf | 7 - .../equinix/terraform/host/provider.tf | 7 - .../equinix/terraform/host/variables.tf | 34 --- share/providers/equinix/terraform/locals.tf | 10 - share/providers/equinix/terraform/main.tf | 14 - share/providers/equinix/terraform/outputs.tf | 8 - share/providers/equinix/terraform/provider.tf | 29 --- .../providers/equinix/terraform/validators.tf | 27 -- .../providers/equinix/terraform/variables.tf | 23 -- share/providers/i3dnet/ansible/ansible.cfg | 27 -- share/providers/i3dnet/ansible/inventory.yaml | 1 - share/providers/i3dnet/ansible/site.yaml | 35 --- .../i3dnet/ansible/templates/ssh_cluster.j2 | 63 ----- share/providers/i3dnet/driver.conf | 21 -- share/providers/i3dnet/terraform/host/main.tf | 10 - .../providers/i3dnet/terraform/host/output.tf | 7 - .../i3dnet/terraform/host/provider.tf | 7 - .../i3dnet/terraform/host/variables.tf | 28 -- share/providers/i3dnet/terraform/locals.tf | 10 - share/providers/i3dnet/terraform/main.tf | 10 - share/providers/i3dnet/terraform/outputs.tf | 8 - share/providers/i3dnet/terraform/provider.tf | 22 -- .../providers/i3dnet/terraform/validators.tf | 27 -- share/providers/i3dnet/terraform/variables.tf | 23 -- share/providers/onprem/ansible/ansible.cfg | 18 -- share/providers/onprem/ansible/inventory.yaml | 1 - share/providers/scaleway/ansible/ansible.cfg | 27 -- .../providers/scaleway/ansible/inventory.yaml | 1 - .../scaleway/ansible/roles/iptables/README.md | 17 -- .../ansible/roles/iptables/defaults/main.yaml | 38 --- .../ansible/roles/iptables/tasks/Debian.yml | 14 - .../ansible/roles/iptables/tasks/main.yml | 19 -- .../ansible/roles/iptables/tasks/rules.yml | 124 --------- .../roles/iptables/templates/rules.v4.j2 | 35 --- .../roles/iptables/templates/rules.v6.j2 | 25 -- share/providers/scaleway/ansible/site.yaml | 40 --- .../scaleway/ansible/templates/ssh_cluster.j2 | 92 ------- share/providers/scaleway/driver.conf | 23 -- share/providers/scaleway/elastic/scaleway.rb | 40 --- .../scaleway/elastic/scaleway_vnm.rb | 148 ----------- .../providers/scaleway/ipam/allocate_address | 21 -- share/providers/scaleway/ipam/free_address | 21 -- share/providers/scaleway/ipam/get_address | 97 ------- .../scaleway/ipam/register_address_range | 237 ----------------- .../scaleway/ipam/unregister_address_range | 119 --------- .../scaleway/terraform/cluster/main.tf | 31 --- .../scaleway/terraform/cluster/provider.tf | 8 - .../scaleway/terraform/cluster/variables.tf | 13 - .../providers/scaleway/terraform/host/data.tf | 13 - .../scaleway/terraform/host/locals.tf | 10 - .../providers/scaleway/terraform/host/main.tf | 26 -- .../scaleway/terraform/host/outputs.tf | 7 - .../scaleway/terraform/host/provider.tf | 8 - .../scaleway/terraform/host/variables.tf | 23 -- share/providers/scaleway/terraform/locals.tf | 10 - share/providers/scaleway/terraform/main.tf | 16 -- share/providers/scaleway/terraform/outputs.tf | 8 - .../providers/scaleway/terraform/provider.tf | 46 ---- .../scaleway/terraform/validators.tf | 37 --- .../providers/scaleway/terraform/variables.tf | 29 --- share/shell/bash_completion | 57 ++++- src/cli/cli_helper.rb | 152 +++++++++++ src/cli/one_helper/oneform_helper.rb | 35 ++- src/cli/one_helper/oneprovider_helper.rb | 13 +- src/cli/one_helper/oneprovision_helper.rb | 12 +- src/cli/oneform | 18 +- src/cli/oneprovider | 53 +++- src/cli/oneprovision | 41 ++- src/form/app/controllers/driver_controller.rb | 9 + .../app/controllers/provider_controller.rb | 34 ++- .../app/controllers/provision_controller.rb | 53 ++-- src/form/app/models/driver.rb | 241 +++++++++++------- src/form/app/models/provider.rb | 47 +++- src/form/app/models/provision.rb | 67 +++-- src/form/config/environment.rb | 2 - src/form/drivers/.states/dummy.state | 1 + src/form/drivers/.states/onprem.state | 1 + .../form/drivers/dummy}/ansible/ansible.cfg | 0 .../drivers}/dummy/ansible/inventory.yaml | 0 .../form/drivers}/dummy/ansible/site.yaml | 0 .../dummy/ansible/templates/dummy_cluster.j2 | 2 +- .../form/drivers}/dummy/driver.conf | 0 .../form/drivers}/dummy/elastic/dummy_vnm.rb | 2 - src/form/drivers/dummy/ipam | 1 + .../form/drivers}/dummy/terraform/locals.tf | 0 .../form/drivers}/dummy/terraform/main.tf | 0 .../form/drivers}/dummy/terraform/outputs.tf | 0 .../form/drivers}/dummy/terraform/provider.tf | 0 .../drivers}/dummy/terraform/validators.tf | 0 .../drivers}/dummy/terraform/variables.tf | 2 +- .../form/drivers/onprem}/ansible/ansible.cfg | 0 .../drivers/onprem}/ansible/inventory.yaml | 0 .../form/drivers}/onprem/ansible/site.yaml | 0 .../onprem/ansible/templates/nfs_cluster.j2 | 18 +- .../onprem/ansible/templates/ssh_cluster.j2 | 13 +- .../form/drivers}/onprem/driver.conf | 0 .../form/drivers}/onprem/terraform/main.tf | 0 .../form/drivers}/onprem/terraform/outputs.tf | 0 .../drivers}/onprem/terraform/provider.tf | 0 .../drivers}/onprem/terraform/variables.tf | 0 src/form/lib/helpers/response_helper.rb | 24 +- src/form/lib/tools/ansible.rb | 2 +- src/form/lib/tools/terraform.rb | 13 +- src/ipamm_mad/one_ipam.rb | 19 +- src/oca/ruby/opennebula/form/drivers.rb | 5 +- src/oca/ruby/opennebula/form/providers.rb | 8 +- src/oca/ruby/opennebula/form/provisions.rb | 4 +- src/vnm_mad/remotes/elastic/elastic.rb | 4 +- 163 files changed, 719 insertions(+), 4759 deletions(-) delete mode 100644 share/providers/aws/ansible/roles/iptables/README.md delete mode 100644 share/providers/aws/ansible/roles/iptables/defaults/main.yaml delete mode 100644 share/providers/aws/ansible/roles/iptables/tasks/Debian.yml delete mode 100644 share/providers/aws/ansible/roles/iptables/tasks/main.yml delete mode 100644 share/providers/aws/ansible/roles/iptables/tasks/rules.yml delete mode 100644 share/providers/aws/ansible/roles/iptables/templates/rules.v4.j2 delete mode 100644 share/providers/aws/ansible/roles/iptables/templates/rules.v6.j2 delete mode 100644 share/providers/aws/ansible/site.yaml delete mode 100644 share/providers/aws/ansible/templates/ssh_cluster.j2 delete mode 100644 share/providers/aws/driver.conf delete mode 100644 share/providers/aws/elastic/aws_vnm.rb delete mode 100755 share/providers/aws/ipam/allocate_address delete mode 100755 share/providers/aws/ipam/free_address delete mode 100755 share/providers/aws/ipam/get_address delete mode 100755 share/providers/aws/ipam/register_address_range delete mode 100755 share/providers/aws/ipam/unregister_address_range delete mode 100644 share/providers/aws/terraform/cluster/main.tf delete mode 100644 share/providers/aws/terraform/cluster/output.tf delete mode 100644 share/providers/aws/terraform/cluster/provider.tf delete mode 100644 share/providers/aws/terraform/cluster/variables.tf delete mode 100644 share/providers/aws/terraform/data.tf delete mode 100644 share/providers/aws/terraform/host/data.tf delete mode 100644 share/providers/aws/terraform/host/locals.tf delete mode 100644 share/providers/aws/terraform/host/main.tf delete mode 100644 share/providers/aws/terraform/host/output.tf delete mode 100644 share/providers/aws/terraform/host/provider.tf delete mode 100644 share/providers/aws/terraform/host/variables.tf delete mode 100644 share/providers/aws/terraform/locals.tf delete mode 100644 share/providers/aws/terraform/main.tf delete mode 100644 share/providers/aws/terraform/outputs.tf delete mode 100644 share/providers/aws/terraform/provider.tf delete mode 100644 share/providers/aws/terraform/validators.tf delete mode 100644 share/providers/aws/terraform/variables.tf delete mode 120000 share/providers/dummy/ipam delete mode 100644 share/providers/equinix/ansible/ansible.cfg delete mode 100644 share/providers/equinix/ansible/inventory.yaml delete mode 100644 share/providers/equinix/ansible/roles/iptables/README.md delete mode 100644 share/providers/equinix/ansible/roles/iptables/defaults/main.yaml delete mode 100644 share/providers/equinix/ansible/roles/iptables/tasks/Debian.yml delete mode 100644 share/providers/equinix/ansible/roles/iptables/tasks/main.yml delete mode 100644 share/providers/equinix/ansible/roles/iptables/tasks/rules.yml delete mode 100644 share/providers/equinix/ansible/roles/iptables/templates/rules.v4.j2 delete mode 100644 share/providers/equinix/ansible/roles/iptables/templates/rules.v6.j2 delete mode 100644 share/providers/equinix/ansible/site.yaml delete mode 100644 share/providers/equinix/ansible/templates/ssh_cluster.j2 delete mode 100644 share/providers/equinix/driver.conf delete mode 100644 share/providers/equinix/elastic/equinix.rb delete mode 100644 share/providers/equinix/elastic/equinix_vnm.rb delete mode 100755 share/providers/equinix/ipam/allocate_address delete mode 100755 share/providers/equinix/ipam/free_address delete mode 100755 share/providers/equinix/ipam/get_address delete mode 100755 share/providers/equinix/ipam/register_address_range delete mode 100755 share/providers/equinix/ipam/unregister_address_range delete mode 100644 share/providers/equinix/terraform/host/main.tf delete mode 100644 share/providers/equinix/terraform/host/outputs.tf delete mode 100644 share/providers/equinix/terraform/host/provider.tf delete mode 100644 share/providers/equinix/terraform/host/variables.tf delete mode 100644 share/providers/equinix/terraform/locals.tf delete mode 100644 share/providers/equinix/terraform/main.tf delete mode 100644 share/providers/equinix/terraform/outputs.tf delete mode 100644 share/providers/equinix/terraform/provider.tf delete mode 100644 share/providers/equinix/terraform/validators.tf delete mode 100644 share/providers/equinix/terraform/variables.tf delete mode 100644 share/providers/i3dnet/ansible/ansible.cfg delete mode 100644 share/providers/i3dnet/ansible/inventory.yaml delete mode 100644 share/providers/i3dnet/ansible/site.yaml delete mode 100644 share/providers/i3dnet/ansible/templates/ssh_cluster.j2 delete mode 100644 share/providers/i3dnet/driver.conf delete mode 100644 share/providers/i3dnet/terraform/host/main.tf delete mode 100644 share/providers/i3dnet/terraform/host/output.tf delete mode 100644 share/providers/i3dnet/terraform/host/provider.tf delete mode 100644 share/providers/i3dnet/terraform/host/variables.tf delete mode 100644 share/providers/i3dnet/terraform/locals.tf delete mode 100644 share/providers/i3dnet/terraform/main.tf delete mode 100644 share/providers/i3dnet/terraform/outputs.tf delete mode 100644 share/providers/i3dnet/terraform/provider.tf delete mode 100644 share/providers/i3dnet/terraform/validators.tf delete mode 100644 share/providers/i3dnet/terraform/variables.tf delete mode 100644 share/providers/onprem/ansible/ansible.cfg delete mode 100644 share/providers/onprem/ansible/inventory.yaml delete mode 100644 share/providers/scaleway/ansible/ansible.cfg delete mode 100644 share/providers/scaleway/ansible/inventory.yaml delete mode 100644 share/providers/scaleway/ansible/roles/iptables/README.md delete mode 100644 share/providers/scaleway/ansible/roles/iptables/defaults/main.yaml delete mode 100644 share/providers/scaleway/ansible/roles/iptables/tasks/Debian.yml delete mode 100644 share/providers/scaleway/ansible/roles/iptables/tasks/main.yml delete mode 100644 share/providers/scaleway/ansible/roles/iptables/tasks/rules.yml delete mode 100644 share/providers/scaleway/ansible/roles/iptables/templates/rules.v4.j2 delete mode 100644 share/providers/scaleway/ansible/roles/iptables/templates/rules.v6.j2 delete mode 100644 share/providers/scaleway/ansible/site.yaml delete mode 100644 share/providers/scaleway/ansible/templates/ssh_cluster.j2 delete mode 100644 share/providers/scaleway/driver.conf delete mode 100644 share/providers/scaleway/elastic/scaleway.rb delete mode 100644 share/providers/scaleway/elastic/scaleway_vnm.rb delete mode 100755 share/providers/scaleway/ipam/allocate_address delete mode 100755 share/providers/scaleway/ipam/free_address delete mode 100755 share/providers/scaleway/ipam/get_address delete mode 100755 share/providers/scaleway/ipam/register_address_range delete mode 100755 share/providers/scaleway/ipam/unregister_address_range delete mode 100644 share/providers/scaleway/terraform/cluster/main.tf delete mode 100644 share/providers/scaleway/terraform/cluster/provider.tf delete mode 100644 share/providers/scaleway/terraform/cluster/variables.tf delete mode 100644 share/providers/scaleway/terraform/host/data.tf delete mode 100644 share/providers/scaleway/terraform/host/locals.tf delete mode 100644 share/providers/scaleway/terraform/host/main.tf delete mode 100644 share/providers/scaleway/terraform/host/outputs.tf delete mode 100644 share/providers/scaleway/terraform/host/provider.tf delete mode 100644 share/providers/scaleway/terraform/host/variables.tf delete mode 100644 share/providers/scaleway/terraform/locals.tf delete mode 100644 share/providers/scaleway/terraform/main.tf delete mode 100644 share/providers/scaleway/terraform/outputs.tf delete mode 100644 share/providers/scaleway/terraform/provider.tf delete mode 100644 share/providers/scaleway/terraform/validators.tf delete mode 100644 share/providers/scaleway/terraform/variables.tf create mode 100644 src/form/drivers/.states/dummy.state create mode 100644 src/form/drivers/.states/onprem.state rename {share/providers/aws => src/form/drivers/dummy}/ansible/ansible.cfg (100%) rename {share/providers => src/form/drivers}/dummy/ansible/inventory.yaml (100%) rename {share/providers => src/form/drivers}/dummy/ansible/site.yaml (100%) rename {share/providers => src/form/drivers}/dummy/ansible/templates/dummy_cluster.j2 (96%) rename {share/providers => src/form/drivers}/dummy/driver.conf (100%) rename {share/providers => src/form/drivers}/dummy/elastic/dummy_vnm.rb (94%) create mode 120000 src/form/drivers/dummy/ipam rename {share/providers => src/form/drivers}/dummy/terraform/locals.tf (100%) rename {share/providers => src/form/drivers}/dummy/terraform/main.tf (100%) rename {share/providers => src/form/drivers}/dummy/terraform/outputs.tf (100%) rename {share/providers => src/form/drivers}/dummy/terraform/provider.tf (100%) rename {share/providers => src/form/drivers}/dummy/terraform/validators.tf (100%) rename {share/providers => src/form/drivers}/dummy/terraform/variables.tf (95%) rename {share/providers/dummy => src/form/drivers/onprem}/ansible/ansible.cfg (100%) rename {share/providers/aws => src/form/drivers/onprem}/ansible/inventory.yaml (100%) rename {share/providers => src/form/drivers}/onprem/ansible/site.yaml (100%) rename {share/providers => src/form/drivers}/onprem/ansible/templates/nfs_cluster.j2 (79%) rename {share/providers => src/form/drivers}/onprem/ansible/templates/ssh_cluster.j2 (84%) rename {share/providers => src/form/drivers}/onprem/driver.conf (100%) rename {share/providers => src/form/drivers}/onprem/terraform/main.tf (100%) rename {share/providers => src/form/drivers}/onprem/terraform/outputs.tf (100%) rename {share/providers => src/form/drivers}/onprem/terraform/provider.tf (100%) rename {share/providers => src/form/drivers}/onprem/terraform/variables.tf (100%) diff --git a/install.sh b/install.sh index 88fa19a8df..ea11f2490b 100755 --- a/install.sh +++ b/install.sh @@ -126,7 +126,9 @@ if [ -z "$ROOT" ] ; then DOCS_LOCATION="/usr/share/doc/one" ANS_LOCATION="$SHARE_LOCATION/ansible" - ONEFORM_PROVIDERS_LOCATION="$SHARE_LOCATION/oneform/drivers" + ONEFORM_PROVIDERS_LOCATION="$ONEFORM_LOCATION/drivers" + ONEFORM_PROVIDERS_STATES_LOCATION="$VAR_LOCATION/oneform/drivers/.states" + ONEFORM_EXTERNAL_PROVIDERS_LOCATION="$VAR_LOCATION/oneform/drivers" ONEPROMETHEUS_SYSTEMD_LOCATION="/lib/systemd/system" ONEPROMETHEUS_VAR_ALERTMANAGER_LOCATION="/var/lib/alertmanager" @@ -165,7 +167,8 @@ if [ -z "$ROOT" ] ; then CHOWN_DIRS="" elif [ "$ONEFORM" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $ONEFORM_LOCATION \ - $ETC_LOCATION $ONEFORM_PROVIDERS_LOCATION $ANS_LOCATION" + $ETC_LOCATION $ONEFORM_PROVIDERS_LOCATION $ONEFORM_EXTERNAL_PROVIDERS_LOCATION \ + $ONEFORM_PROVIDERS_STATES_LOCATION $ANS_LOCATION" DELETE_DIRS="$MAKE_DIRS" @@ -176,7 +179,8 @@ if [ -z "$ROOT" ] ; then $LOG_LOCATION $RUN_LOCATION $LOCK_LOCATION \ $SYSTEM_DS_LOCATION $DEFAULT_DS_LOCATION $MAN_LOCATION \ $VM_LOCATION $ONEGATE_LOCATION $ONEFLOW_LOCATION $ONEFORM_LOCATION \ - $ONEHEM_LOCATION $ONEPROMETHEUS_DIRS $ONEFORM_PROVIDERS_LOCATION $ANS_LOCATION" + $ONEHEM_LOCATION $ONEPROMETHEUS_DIRS $ONEFORM_PROVIDERS_LOCATION $ONEFORM_EXTERNAL_PROVIDERS_LOCATION \ + $ONEFORM_PROVIDERS_STATES_LOCATION $ANS_LOCATION" DELETE_DIRS="$LIB_LOCATION $ETC_LOCATION $LOG_LOCATION $VAR_LOCATION \ $RUN_LOCATION $SHARE_DIRS" @@ -206,7 +210,9 @@ else DOCS_LOCATION="$ROOT/share/doc" ANS_LOCATION="$SHARE_LOCATION/ansible" - ONEFORM_PROVIDERS_LOCATION="$SHARE_LOCATION/oneform/drivers" + ONEFORM_PROVIDERS_LOCATION="$LIB_LOCATION/oneform/drivers" + ONEFORM_PROVIDERS_STATES_LOCATION="$VAR_LOCATION/oneform/drivers/.states" + ONEFORM_EXTERNAL_PROVIDERS_LOCATION="$VAR_LOCATION/oneform/drivers" ONEPROMETHEUS_SYSTEMD_LOCATION="$LIB_LOCATION/systemd" ONEPROMETHEUS_VAR_ALERTMANAGER_LOCATION="$ROOT/var/alertmanager" @@ -237,7 +243,8 @@ else DELETE_DIRS="$MAKE_DIRS" elif [ "$ONEFORM" = "yes" ]; then MAKE_DIRS="$BIN_LOCATION $LIB_LOCATION $VAR_LOCATION $ONEFORM_LOCATION \ - $ETC_LOCATION $ONEFORM_PROVIDERS_LOCATION $ANS_LOCATION" + $ETC_LOCATION $ONEFORM_PROVIDERS_LOCATION $ONEFORM_EXTERNAL_PROVIDERS_LOCATION \ + $ONEFORM_PROVIDERS_STATES_LOCATION $ANS_LOCATION" DELETE_DIRS="$MAKE_DIRS" @@ -248,7 +255,8 @@ else $DEFAULT_DS_LOCATION $MAN_LOCATION $DOCS_LOCATION \ $VM_LOCATION $ONEGATE_LOCATION $ONEFLOW_LOCATION $ONEFORM_LOCATION \ $ONEHEM_LOCATION $LOCK_LOCATION $RUN_LOCATION \ - $ONEPROMETHEUS_DIRS $ONEFORM_PROVIDERS_LOCATION $ANS_LOCATION" + $ONEPROMETHEUS_DIRS $ONEFORM_PROVIDERS_LOCATION $ONEFORM_EXTERNAL_PROVIDERS_LOCATION \ + $ONEFORM_PROVIDERS_STATES_LOCATION $ANS_LOCATION" DELETE_DIRS="$MAKE_DIRS" @@ -795,6 +803,7 @@ INSTALL_ONEFORM_FILES=( ONEFORM_CONFIG_FILES:$ONEFORM_LOCATION/config ONEFORM_ANSIBLE_INVENTORY:$ANS_LOCATION/plugins/inventory ONEFORM_ANSIBLE_LIB:$ANS_LOCATION/plugins/lib + ONEFORM_PROVIDERS_STATES_FILES:$ONEFORM_PROVIDERS_STATES_LOCATION ONEFORM_PROVIDERS_FILES:$ONEFORM_PROVIDERS_LOCATION ) @@ -880,11 +889,6 @@ RUBY_LIB_FILES="src/mad/ruby/ActionManager.rb \ src/mad/ruby/ssh_stream.rb \ src/vnm_mad/one_vnm.rb \ src/oca/ruby/opennebula.rb \ - share/providers/aws/elastic/aws_vnm.rb \ - share/providers/equinix/elastic/equinix_vnm.rb \ - share/providers/equinix/elastic/equinix.rb \ - share/providers/scaleway/elastic/scaleway_vnm.rb \ - share/providers/scaleway/elastic/scaleway.rb \ share/misc/load_opennebula_paths.rb" #------------------------------------------------------------------------------- @@ -2389,7 +2393,8 @@ ONEFORM_LIB_TOOLS_FILES="src/form/lib/tools/ansible.rb \ src/form/lib/tools/terraform.rb \ src/form/lib/tools/log.rb" -ONEFORM_PROVIDERS_FILES="share/providers/*" +ONEFORM_PROVIDERS_FILES="src/form/drivers/*" +ONEFORM_PROVIDERS_STATES_FILES="src/form/drivers/.states/*" ONEFORM_ANSIBLE_INVENTORY="share/ansible/plugins/inventory/opennebula_form.py" diff --git a/share/providers/aws/ansible/roles/iptables/README.md b/share/providers/aws/ansible/roles/iptables/README.md deleted file mode 100644 index 869c8c611c..0000000000 --- a/share/providers/aws/ansible/roles/iptables/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# iptables - -## Description - -Creates the basic set of IPv4 and IPv6 packet filter rules to ensure only the specified traffic is allowed. Masqurade (NAT) with IP port forwarding can be enabled. - -## Requirements - -No special requirements. - -## Variables - -All of the variables in this role are documented in the [defaults](defaults/main.yaml) file. - -## Todo list - -None diff --git a/share/providers/aws/ansible/roles/iptables/defaults/main.yaml b/share/providers/aws/ansible/roles/iptables/defaults/main.yaml deleted file mode 100644 index 61aad114ae..0000000000 --- a/share/providers/aws/ansible/roles/iptables/defaults/main.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -################################################################################ -# Mandatory -################################################################################ - -# Enable IP forwarding -iptables_ip_forward_enabled: true - -# Manage persistent configuration -iptables_manage_persistent: true - -# Create set of base rules -iptables_base_rules_enabled: true - -# Particular network interface to limit the base rules -iptables_base_rules_interface: NULL - -# Include the rules to drop any other traffic -iptables_base_rules_strict: true - -# List of whitelisted services -iptables_base_rules_services: - - { protocol: 'tcp', port: 22, chain: INPUT } - - { protocol: 'tcp', port: 25, chain: OUTPUT } - - { protocol: 'tcp', port: 587, chain: OUTPUT } - -# List of whitelisted hosts -iptables_hosts: [] - -# List of whitelisted hosts -iptables_6_hosts: [] - -# Enable NAT -iptables_masquerade_enabled: false - -# NAT output interface -iptables_masquerade_interface: "{{ ansible_default_ipv4.interface }}" diff --git a/share/providers/aws/ansible/roles/iptables/tasks/Debian.yml b/share/providers/aws/ansible/roles/iptables/tasks/Debian.yml deleted file mode 100644 index 515a639b89..0000000000 --- a/share/providers/aws/ansible/roles/iptables/tasks/Debian.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: Install iptables persistent - package: - name: iptables-persistent - state: present - -- name: Create persistent rules configurations - template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'rules.v4.j2', dest: '/etc/iptables/rules.v4' } - - { src: 'rules.v6.j2', dest: '/etc/iptables/rules.v6' } diff --git a/share/providers/aws/ansible/roles/iptables/tasks/main.yml b/share/providers/aws/ansible/roles/iptables/tasks/main.yml deleted file mode 100644 index b7702f2b28..0000000000 --- a/share/providers/aws/ansible/roles/iptables/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: Set net.ipv4.ip_forward - sysctl: - name: net.ipv4.ip_forward - value: "{{ iptables_ip_forward_enabled | int }}" - state: present - sysctl_file: /etc/sysctl.d/ip_forward.conf - reload: yes - -- include_tasks: '{{ ansible_os_family }}.yml' - when: iptables_manage_persistent - -- include_tasks: rules.yml - -- name: Restart iptables service - service: - name: iptables - state: restarted diff --git a/share/providers/aws/ansible/roles/iptables/tasks/rules.yml b/share/providers/aws/ansible/roles/iptables/tasks/rules.yml deleted file mode 100644 index de32fa8c70..0000000000 --- a/share/providers/aws/ansible/roles/iptables/tasks/rules.yml +++ /dev/null @@ -1,124 +0,0 @@ ---- -- name: Manage live iptables rule - masquerade - iptables: - state: "{% if iptables_masquerade_enabled %}present{% else %}absent{% endif %}" - table: nat - chain: POSTROUTING - out_interface: "{{ iptables_masquerade_interface }}" - jump: MASQUERADE - -- block: - # default IPv4 rules - - name: Accept related/established - iptables: - action: insert - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept icmp - iptables: - action: insert - table: filter - chain: INPUT - protocol: icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template - iptables: - action: insert - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept VNC ports - iptables: - action: insert - table: filter - chain: INPUT - protocol: tcp - match: multiport - destination_port: 5900:5999 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - # default IPv6 rules - - name: Accept related/established - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept ipv6-icmp - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: ipv6-icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template [IPv6] - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept DHCPv6 - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: udp - match: state - ctstate: NEW - destination: fe80::/64 - destination_port: 546 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - - name: Save iptables rules - shell: | - iptables-save > /etc/iptables/rules.v4 - ip6tables-save > /etc/iptables/rules.v6 - when: iptables_base_rules_enabled diff --git a/share/providers/aws/ansible/roles/iptables/templates/rules.v4.j2 b/share/providers/aws/ansible/roles/iptables/templates/rules.v4.j2 deleted file mode 100644 index a3f9d8fe55..0000000000 --- a/share/providers/aws/ansible/roles/iptables/templates/rules.v4.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# {{ ansible_managed }} -*nat -:PREROUTING ACCEPT [0:0] -:INPUT ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -:POSTROUTING ACCEPT [0:0] -{% if iptables_masquerade_enabled %} --A POSTROUTING -o {{ iptables_masquerade_interface }} -j MASQUERADE -{% endif %} -COMMIT -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p icmp -j ACCEPT --A INPUT -i lo -j ACCEPT --A INPUT -d 172.20.0.1/32 -p tcp -m tcp --dport 53 -j ACCEPT --A INPUT -d 172.20.0.1/32 -p udp -m udp --dport 53 -j ACCEPT -{% for host in iptables_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp-host-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/aws/ansible/roles/iptables/templates/rules.v6.j2 b/share/providers/aws/ansible/roles/iptables/templates/rules.v6.j2 deleted file mode 100644 index 65a77e11c8..0000000000 --- a/share/providers/aws/ansible/roles/iptables/templates/rules.v6.j2 +++ /dev/null @@ -1,25 +0,0 @@ -# {{ ansible_managed }} -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p ipv6-icmp -j ACCEPT --A INPUT -i lo -j ACCEPT -{% for host in iptables_6_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -d fe80::/64 -p udp -m udp --dport 546 -m state --state NEW -j ACCEPT -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp6-adm-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/aws/ansible/site.yaml b/share/providers/aws/ansible/site.yaml deleted file mode 100644 index 158f463531..0000000000 --- a/share/providers/aws/ansible/site.yaml +++ /dev/null @@ -1,34 +0,0 @@ ---- -- name: Check hosts connectivity - hosts: node - gather_facts: false - tasks: - - name: Wait for hosts to be up - ansible.builtin.wait_for_connection: - timeout: 300 - - name: Wait for hosts to be reachable through SSH - wait_for: - host: "{{ ansible_host }}" - port: 22 - state: started - timeout: 60 - tags: always - -# ------------------------------------------------------------------------------ -# One-deploy playbooks -# ------------------------------------------------------------------------------ -- name: Configure OpenNebula nodes - ansible.builtin.import_playbook: opennebula.deploy.main - -# ------------------------------------------------------------------------------ -# Other playbooks (optional) -# ------------------------------------------------------------------------------ - -- name: 'Networking configuration' - hosts: node - remote_user: ubuntu - become: True - roles: - - role: iptables - iptables_base_rules_interface: "{{ ansible_default_ipv4.interface }}" - tags: always diff --git a/share/providers/aws/ansible/templates/ssh_cluster.j2 b/share/providers/aws/ansible/templates/ssh_cluster.j2 deleted file mode 100644 index 424f614da6..0000000000 --- a/share/providers/aws/ansible/templates/ssh_cluster.j2 +++ /dev/null @@ -1,93 +0,0 @@ -{# -name: AWS SSH Cluster -description: It deploys a SSH cluster on AWS -fireedge: - logo: "aws_ssh_cluster.png" -user_inputs: - - name: oneform_public_ips - description: Number of public IPs to allocate - type: number - default: 0 - mandatory: false - match: - type: number - values: - min: 0 - max: 5 -#} - ---- -all: - vars: - one_version: "{{ one.version }}" - features: - evpn: true - ds: - mode: generic - config: - SYSTEM_DS: - aws_system_ds: - id: "{{ one.system_ds_id }}" - template: - type: SYSTEM_DS - tm_mad: ssh - safe_dirs: "/var/tmp /tmp" - IMAGE_DS: - aws_image_ds: - id: "{{ one.image_ds_id }}" - template: - type: IMAGE_DS - ds_mad: fs - tm_mad: ssh - safe_dirs: "/var/tmp /tmp" - vn: - private_aws_network: - managed: true - template: - vn_mad: vxlan - vxlan_mode: evpn - automatic_vlan_id: "yes" - phydev: enp125s0 - ip_link_conf: nolearning= - guest_mtu: 1450 - network_address: 172.17.2.0 - network_mask: 255.255.255.0 - gateway: 172.17.2.1 - dns: 1.1.1.1 - ar: - type: ip4 - ip: 172.17.2.100 - size: 100 - public_aws_network: - managed: true - template: - vn_mad: elastic - bridge: br0 - netrole: public - vxlan_mode: evpn - vxlan_tep: dev - ip_link_conf: nolearning= - allowed_ports: - - protocol: tcp - ports: - - 22 - - 179 - - protocol: udp - ports: - - 8472 - -frontend: - hosts: - f1: { ansible_user: root, ansible_host: "{{ one.frontend_ip }}" } - -node: - hosts: - {% for node in one.nodes %} - n{{ loop.index }}: { ansible_user: ubuntu, ansible_host: "{{ node }}" } - {% endfor %} - -router: - hosts: - {% if one.nodes | length > 0 %} - n1: { ansible_user: ubuntu, ansible_host: "{{ one.nodes[0] }}" } - {% endif %} diff --git a/share/providers/aws/driver.conf b/share/providers/aws/driver.conf deleted file mode 100644 index 14a5a392b6..0000000000 --- a/share/providers/aws/driver.conf +++ /dev/null @@ -1,25 +0,0 @@ -# ------------------------------------------------ -# Driver conf -# ------------------------------------------------ - -name: 'AWS' -description: 'Amazon Web Services' -version: '1.0.0' - -# FireEdge configuration (logos, metadata, etc) -fireedge: - logo: '/fireedge/client/assets/images/providers/aws.png' - color: "FD6F8E" - operations: - add-host: amount # aws, scaleway, equinix - del-host: ids - add-ip: amount - layout: - provider: - - oneform_hosts - - instance_type - - instance_os_name - - instance_disk_size - network: - - cidr_block - - oneform_public_ips \ No newline at end of file diff --git a/share/providers/aws/elastic/aws_vnm.rb b/share/providers/aws/elastic/aws_vnm.rb deleted file mode 100644 index 4e6dc1b6d9..0000000000 --- a/share/providers/aws/elastic/aws_vnm.rb +++ /dev/null @@ -1,121 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # -# -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -require 'aws-sdk-ec2' -require 'ipaddr' - -# Class covering AWS functionality for Elastic driver -class AWSProvider < GenericProvider - - # Init the driver - def initialize(provider, host) - super(provider, host) - - options = { - :access_key_id => @connection[:access_key], - :secret_access_key => @connection[:secret_key], - :region => @connection[:region] - } - - Aws.config.merge!(options) - @ec2 = Aws::EC2::Resource.new.client - end - - # Assign a private IP to the instance, associate given elastic ip with it - # @param ip [String] private_ip for AWS - # @param external [String] public_ip, not used for AWS - # @param opts [Hash] - # opts[:alloc_id] [String] must contain public_ip alloc id - # @return 0 on success, 1 on error - def assign(ip, _external, opts = {}) - instcs = @ec2.describe_instances({ :instance_ids => [@resource_id] }) - inst = instcs.reservations[0].instances[0] - - # find NIC to which the IP belongs (avoid Ceph network) - nic_id = nil - inst.network_interfaces.each do |ec2_nic| - ec2_subnet = @ec2.describe_subnets( - { :subnet_ids => [ec2_nic.subnet_id] } - ).subnets[0] - - ip_range = IPAddr.new(ec2_subnet.cidr_block) - - if ip_range.include?(ip) - nic_id = ec2_nic.network_interface_id - end - end - - if nic_id - @ec2.assign_private_ip_addresses( - { :network_interface_id => nic_id, - :private_ip_addresses => [ip] } - ) - - @ec2.associate_address( - { :network_interface_id => nic_id, - :allocation_id => opts[:alloc_id], - :private_ip_address => ip } - ) - else - OpenNebula::DriverLogger.log_error("Can not find any interface to assign #{ip}") - exit 1 - end - - 0 - rescue StandardError => e - OpenNebula::DriverLogger.log_error("Error assigning #{ip}:#{e.message}") - 1 - end - - # Unassign a public_ip from an instance - # @param ip [String] not used for AWS - # @param external [String] the public ip - def unassign(ip, external, _opts = {}) - filter = [{ :name => 'public-ip', :values => [external] }] - aws_ip = @ec2.describe_addresses({ :filters => filter }).addresses[0] - - if aws_ip.nil? \ - || aws_ip.network_interface_id.nil? \ - || aws_ip.private_ip_address.nil? - return - end - - # free associated private ip, it frees associated public ip - @ec2.unassign_private_ip_addresses( - { :network_interface_id => aws_ip.network_interface_id, - :private_ip_addresses => [aws_ip.private_ip_address] } - ) - rescue StandardError - OpenNebula::DriverLogger.log_error("Error unassigning #{ip}:#{e.message}") - end - -end diff --git a/share/providers/aws/ipam/allocate_address b/share/providers/aws/ipam/allocate_address deleted file mode 100755 index 353840e115..0000000000 --- a/share/providers/aws/ipam/allocate_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/aws/ipam/free_address b/share/providers/aws/ipam/free_address deleted file mode 100755 index 353840e115..0000000000 --- a/share/providers/aws/ipam/free_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/aws/ipam/get_address b/share/providers/aws/ipam/get_address deleted file mode 100755 index da2ac52a51..0000000000 --- a/share/providers/aws/ipam/get_address +++ /dev/null @@ -1,96 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to get a free IP address (or set of IPs). The IP will be -# used by OpenNebula VMs and should not be allocated to any other host in the -# network. -# -# STDIN Input: -# - Base64 encoded XML with the AR description and the address request -# -# XML format -# -# -# allocation id -# access key -# secret key -# region -# -#
-# -# Number of IPs to allocate -# -#
-#
-# -# This scrit MUST output the leased IP range, if the "size" IPs cannot be -# assgined the sript must return -1, otherwise it must exit 0. The answer to -# OpenNebula needs to include the ADDRESS spec: -# -# ADDRESS = [ IP = "10.0.0.2", SIZE=34 ] -# -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION - -require 'base64' -require 'nokogiri' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - size = data.xpath('//ADDRESS/SIZE').text - ip = data.xpath('//AR/IP').text - - if size.to_i != 1 - STDERR.puts 'Only IP requests of size 1 are supported' - exit(-1) - end - - if ip.empty? - STDERR.puts 'Empty IP address in request' - exit(-1) - end - - puts <<-EOF - ADDRESS = [ - IP = "#{ip}", - SIZE = "1" - ] - EOF -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/aws/ipam/register_address_range b/share/providers/aws/ipam/register_address_range deleted file mode 100755 index 61efd1b3b6..0000000000 --- a/share/providers/aws/ipam/register_address_range +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to register a new IP network in the IPAM. The network may -# be selected by a pool of free networks or if an specific network is requested -# its availability maybe checked by the IPAM driver. -# -# The IPAM driver must return an OpenNebula AddressRange definition, potentially -# augmented with network specific variables to be used by VMs (e.g. GATEWAYS, -# MASK...) -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -# XML format -# -# -# Number of IPs to allocate -# ID -# -# -# -# The response MUST include IPAM_MAD, TYPE, IP and SIZE attributes, example: -# - A basic network definition -# AR = [ -# IPAM_MAD = "ec2", -# TYPE = "IP4", -# IP = "10.0.0.1", -# SIZE = "255", -# DEPLOY_ID = "..", -# ] -# -# - A complete network definition. Custom attributes (free form, key-value) -# can be added, named cannot be repeated. -# AR = [ -# IPAM_MAD = "ec2", -# TYPE = "IP4", -# IP = "10.0.0.2", -# SIZE = "200", -# DEPLOY_ID = "..", -# NETWORK_ADDRESS = "10.0.0.0", -# NETWORK_MASK = "255.255.255.0", -# GATEWAY = "10.0.0.1", -# DNS = "10.0.0.1", -# IPAM_ATTR = "10.0.0.240", -# OTHER_IPAM_ATTR = ".mydoamin.com" -# ] -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION - -require 'base64' -require 'nokogiri' -require 'aws-sdk-ec2' -require 'opennebula' -require 'opennebula/oneform_client' -require 'ipaddr' - -# Add ^ and < operators to the IPAddr class -class IPAddr - - attr_reader :addr - - def ^(other) - clone.set(@addr ^ other.to_i) - end - - def <(other) - @addr < other.addr - end - -end - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{document[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - values = provision[:user_inputs_values] - - if values - cidr_s = values[:cidr_block] - else - cidr_s = data.xpath('//AR/CIDR').text - end - - mask = cidr_s.split('/')[1] - - if cidr_s.empty? - STDERR.puts 'Missing CIDR block in aws_configuration or AR' - exit(-1) - end - - cidr = IPAddr.new(cidr_s) - - if !['255.255.0.0', '16'].include? mask - STDERR.puts 'Elastic CIDR block has to be /16' - exit(-1) - end - - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - - options = { - :access_key_id => connect[:access_key], - :secret_access_key => connect[:secret_key], - :region => connect[:region] - } - - # -------------------------------------------------------------------------- - # Connect to AWS and allocate a new IP. Model a 2-host network for the - # public IP. - # Gateway = IP ^ 1 - # IP = IP/31 - # -------------------------------------------------------------------------- - size = data.xpath('//AR/SIZE').text.to_i - - if size.to_i != 1 - STDERR.puts 'Only address ranges of size 1 are supported' - exit(-1) - end - - Aws.config.merge!(options) - - ec2 = Aws::EC2::Resource.new.client - ip = ec2.allocate_address({ :domain => 'vpc' }) - - # Get current number of ARs for this provision - current_nets = provision[:one_objects][:networks] || [] - public_net = current_nets.find {|n| n[:name]&.include?('public') } - public_ars = public_net&.dig(:template, :ar) || [] - - tag_list = provision[:tags].map {|k, v| { :key => k, :value => v } } - tag_list << { :key => 'PROVISION_ID', :value => provision_id.to_s } - tag_list << { - :key => 'Name', - :value => "elastic_ip_provision_#{provision_id}_#{public_ars.size}" - } - - ec2.create_tags( - { - :resources => [ip.allocation_id], - :tags => tag_list - } - ) - - eip = IPAddr.new(ip.public_ip) - - ipvm = (eip & 0x0000FFFF) | cidr.mask(16) - ipgw = ipvm ^ 1 - - first_ip = IPAddr.new('0.0.0.16') | cidr.mask(16) - - if ipvm < first_ip - ec2.release_address({ :allocation_id => ip.allocation_id }) - - STDERR.puts 'Could not allocate Elastic IP' - exit(-1) - end - - puts <<-EOF - AR = [ - TYPE = "IP4", - IP = "#{ipvm}", - EXTERNAL_IP = "#{ip.public_ip}", - SIZE = "1", - IPAM_MAD = "aws", - GATEWAY = "#{ipgw}", - NETWORK_MASK = "255.255.255.254", - AWS_ALLOCATION_ID = "#{ip.allocation_id}", - PROVISION_ID = "#{provision_id}" - ] - EOF -rescue StandardError => e - ec2.release_address({ :allocation_id => ip.allocation_id }) - - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/aws/ipam/unregister_address_range b/share/providers/aws/ipam/unregister_address_range deleted file mode 100755 index 9d85b020f8..0000000000 --- a/share/providers/aws/ipam/unregister_address_range +++ /dev/null @@ -1,128 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to register a new IP network in the IPAM. The network may -# be selected by a pool of free networks or if an specific network is requested -# its availability maybe checked by the IPAM driver. -# -# The IPAM driver must return an OpenNebula AddressRange definition, potentially -# augmented with network specific variables to be used by VMs (e.g. GATEWAYS, -# MASK...) -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -# XML format -# -# -# aws allocation id -# access key -# secret key -# region -# -# -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION - -require 'base64' -require 'nokogiri' -require 'aws-sdk-ec2' -require 'opennebula' -require 'opennebula/oneform_client' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{provision[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - - options = { - :access_key_id => connect[:access_key], - :secret_access_key => connect[:secret_key], - :region => connect[:region] - } - - # -------------------------------------------------------------------------- - # Connect to AWS delete the IP allocation - # -------------------------------------------------------------------------- - allocation_id = data.xpath('//AR/AWS_ALLOCATION_ID').text - - unless allocation_id - STDERR.puts 'AWS_ALLOCATION_ID not found in AR' - exit(-1) - end - - Aws.config.merge!(options) - - ec2 = Aws::EC2::Resource.new.client - - ec2.release_address({ :allocation_id => allocation_id }) -rescue Aws::EC2::Errors::AuthFailure - puts 'The IP address has already been released or belongs to another account.' -rescue Aws::EC2::Errors::InvalidAllocationIDNotFound - puts 'The specified allocation ID does not exist.' -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/aws/terraform/cluster/main.tf b/share/providers/aws/terraform/cluster/main.tf deleted file mode 100644 index a5f680eccd..0000000000 --- a/share/providers/aws/terraform/cluster/main.tf +++ /dev/null @@ -1,80 +0,0 @@ -resource "aws_vpc" "aws_vpc_device" { - cidr_block = var.cidr_block - - tags = merge( - var.aws_tags, - { - Name = "provision_vpc_${var.provision_id}" - } - ) -} - -resource "aws_subnet" "aws_subnet_device" { - vpc_id = aws_vpc.aws_vpc_device.id - cidr_block = var.cidr_block - - map_public_ip_on_launch = true - - tags = merge( - var.aws_tags, - { - Name = "provision_subnet_${var.provision_id}" - } - ) - - timeouts { - delete = "30m" - } -} - -resource "aws_internet_gateway" "aws_internet_gateway_device" { - vpc_id = aws_vpc.aws_vpc_device.id - - tags = merge( - var.aws_tags, - { - Name = "provision_internet_gateway_${var.provision_id}" - } - ) - - timeouts { - delete = "30m" - } -} - -resource "aws_route" "aws_route_device" { - route_table_id = aws_vpc.aws_vpc_device.main_route_table_id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.aws_internet_gateway_device.id - - timeouts { - delete = "30m" - } -} - -resource "aws_security_group" "aws_security_group_device_all" { - name = "allow_all" - description = "Allow all traffic" - vpc_id = aws_vpc.aws_vpc_device.id - - tags = merge( - var.aws_tags, - { - Name = "provision_security_group_${var.provision_id}" - } - ) - - ingress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } - - egress { - from_port = 0 - to_port = 0 - protocol = "-1" - cidr_blocks = ["0.0.0.0/0"] - } -} \ No newline at end of file diff --git a/share/providers/aws/terraform/cluster/output.tf b/share/providers/aws/terraform/cluster/output.tf deleted file mode 100644 index 57b4c9b1ca..0000000000 --- a/share/providers/aws/terraform/cluster/output.tf +++ /dev/null @@ -1,11 +0,0 @@ -output "vpc_device_id" { - value = aws_vpc.aws_vpc_device.id -} - -output "vpc_subnet_id" { - value = aws_subnet.aws_subnet_device.id -} - -output "vpc_security_group_id" { - value = aws_security_group.aws_security_group_device_all.id -} \ No newline at end of file diff --git a/share/providers/aws/terraform/cluster/provider.tf b/share/providers/aws/terraform/cluster/provider.tf deleted file mode 100644 index 3196632a85..0000000000 --- a/share/providers/aws/terraform/cluster/provider.tf +++ /dev/null @@ -1,8 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - } -} \ No newline at end of file diff --git a/share/providers/aws/terraform/cluster/variables.tf b/share/providers/aws/terraform/cluster/variables.tf deleted file mode 100644 index 9c47da96ae..0000000000 --- a/share/providers/aws/terraform/cluster/variables.tf +++ /dev/null @@ -1,15 +0,0 @@ -variable "cidr_block" { - description = "CIDR block for the VPC" - type = string - default = "10.0.0.0/16" -} - -variable "provision_id" { - description = "Provision ID for the cluster" -} - -variable "aws_tags" { - description = "Tags to assign to the AWS resources" - type = map(string) - default = {} -} diff --git a/share/providers/aws/terraform/data.tf b/share/providers/aws/terraform/data.tf deleted file mode 100644 index 633f484143..0000000000 --- a/share/providers/aws/terraform/data.tf +++ /dev/null @@ -1,31 +0,0 @@ -data "aws_ami" "ubuntu_2204" { - most_recent = true - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } - - owners = ["099720109477"] -} - -data "aws_ami" "ubuntu_2004" { - most_recent = true - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } - - owners = ["099720109477"] -} diff --git a/share/providers/aws/terraform/host/data.tf b/share/providers/aws/terraform/host/data.tf deleted file mode 100644 index b7c367440f..0000000000 --- a/share/providers/aws/terraform/host/data.tf +++ /dev/null @@ -1,32 +0,0 @@ -data "aws_ami" "ubuntu_2204" { - most_recent = true - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-jammy-22.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } - - owners = ["099720109477"] -} - -data "aws_ami" "ubuntu_2004" { - most_recent = true - - filter { - name = "name" - values = ["ubuntu/images/hvm-ssd/ubuntu-focal-20.04-amd64-server-*"] - } - - filter { - name = "virtualization-type" - values = ["hvm"] - } - - owners = ["099720109477"] -} - diff --git a/share/providers/aws/terraform/host/locals.tf b/share/providers/aws/terraform/host/locals.tf deleted file mode 100644 index 2baee188ed..0000000000 --- a/share/providers/aws/terraform/host/locals.tf +++ /dev/null @@ -1,6 +0,0 @@ -locals { - registred_instance_os_name = { - "ubuntu_2204" = data.aws_ami.ubuntu_2204.id - "ubuntu_2004" = data.aws_ami.ubuntu_2004.id - } -} diff --git a/share/providers/aws/terraform/host/main.tf b/share/providers/aws/terraform/host/main.tf deleted file mode 100644 index 4b7f7ac57c..0000000000 --- a/share/providers/aws/terraform/host/main.tf +++ /dev/null @@ -1,30 +0,0 @@ -resource "aws_key_pair" "oneadmin_pubkey" { - key_name = "provision_key_${var.provision_id}" - public_key = file(pathexpand("~/.ssh/id_rsa.pub")) -} - -resource "aws_instance" "host" { - ami = lookup(local.registred_instance_os_name, var.instance_os_name) - instance_type = var.instance_type - count = var.oneform_hosts - - vpc_security_group_ids = [var.vpc_security_group_id] - subnet_id = var.vpc_subnet_id - - root_block_device { - volume_size = var.instance_disk_size - } - - key_name = aws_key_pair.oneadmin_pubkey.key_name - - tags = merge( - var.aws_tags, - { - Name = "provision_${var.provision_id}_host_${count.index}" - } - ) - - timeouts { - delete = "30m" - } -} diff --git a/share/providers/aws/terraform/host/output.tf b/share/providers/aws/terraform/host/output.tf deleted file mode 100644 index a9556eb537..0000000000 --- a/share/providers/aws/terraform/host/output.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "id" { - value = [for instance in aws_instance.host : instance.id] -} - -output "public_ip" { - value = [for instance in aws_instance.host : instance.public_ip] -} diff --git a/share/providers/aws/terraform/host/provider.tf b/share/providers/aws/terraform/host/provider.tf deleted file mode 100644 index 3196632a85..0000000000 --- a/share/providers/aws/terraform/host/provider.tf +++ /dev/null @@ -1,8 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - } -} \ No newline at end of file diff --git a/share/providers/aws/terraform/host/variables.tf b/share/providers/aws/terraform/host/variables.tf deleted file mode 100644 index 7ac33174c8..0000000000 --- a/share/providers/aws/terraform/host/variables.tf +++ /dev/null @@ -1,39 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string -} - -variable "instance_disk_size" { - description = "Root disk size to use for the instance" - type = number - default = null -} - -variable "vpc_subnet_id" { - description = "ID of the subnet to deploy the instance" - type = string -} - -variable "vpc_security_group_id" { - description = "Set of IDs of the security groups to assign to the instance" - type = string -} - -variable "provision_id" { - description = "Provision ID for the host" -} - -variable "aws_tags" { - description = "value of the tags to assign to the instance" - type = map(string) -} diff --git a/share/providers/aws/terraform/locals.tf b/share/providers/aws/terraform/locals.tf deleted file mode 100644 index 389e715119..0000000000 --- a/share/providers/aws/terraform/locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "random_id" "key_suffix" { - byte_length = 6 -} - -locals { - provision_id = ( - contains(keys(var.oneform_tags), "provision_id") ? - var.oneform_tags["provision_id"] : random_id.key_suffix.id - ) -} diff --git a/share/providers/aws/terraform/main.tf b/share/providers/aws/terraform/main.tf deleted file mode 100644 index 6d80378d1b..0000000000 --- a/share/providers/aws/terraform/main.tf +++ /dev/null @@ -1,20 +0,0 @@ -module "cluster" { - source = "./cluster" - provision_id = local.provision_id - cidr_block = var.cidr_block -} - -module "host" { - source = "./host" - provision_id = local.provision_id - - oneform_hosts = var.oneform_hosts - instance_type = var.instance_type - instance_os_name = var.instance_os_name - instance_disk_size = var.instance_disk_size - - aws_tags = var.oneform_tags - - vpc_subnet_id = module.cluster.vpc_subnet_id - vpc_security_group_id = module.cluster.vpc_security_group_id -} diff --git a/share/providers/aws/terraform/outputs.tf b/share/providers/aws/terraform/outputs.tf deleted file mode 100644 index bc4fbccc20..0000000000 --- a/share/providers/aws/terraform/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "provisioned_hosts" { - value = [ - for idx in range(length(module.host.id)) : { - instance_id = module.host.id[idx] - instance_ip = module.host.public_ip[idx] - } - ] -} diff --git a/share/providers/aws/terraform/provider.tf b/share/providers/aws/terraform/provider.tf deleted file mode 100644 index 950db9a0bd..0000000000 --- a/share/providers/aws/terraform/provider.tf +++ /dev/null @@ -1,32 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 5.0" - } - } -} - -variable "access_key" { - type = string - sensitive = true - description = "AWS Access Key" -} - -variable "secret_key" { - type = string - sensitive = true - description = "AWS Secret Key" -} - -variable "region" { - type = string - description = "AWS Region" - default = "eu-central-1" -} - -provider "aws" { - access_key = var.access_key - secret_key = var.secret_key - region = var.region -} diff --git a/share/providers/aws/terraform/validators.tf b/share/providers/aws/terraform/validators.tf deleted file mode 100644 index 0652b62cc3..0000000000 --- a/share/providers/aws/terraform/validators.tf +++ /dev/null @@ -1,35 +0,0 @@ -locals { - # AWS provider validators - validators = { - instance_type = { - type = "list" - values = ["c5.metal", "m5.metal"] - } - - oneform_hosts = { - type = "number" - values = { - min = 1 - max = 10 - } - } - - instance_os_name = { - type = "list" - values = ["ubuntu_2204", "ubuntu_2404"] - } - - instance_disk_size = { - type = "number" - values = { - min = 32 - max = 1024 - } - } - - region = { - type = "list" - values = ["eu-central-1", "eu-west-1", "us-east-1", "us-west-1"] - } - } -} diff --git a/share/providers/aws/terraform/variables.tf b/share/providers/aws/terraform/variables.tf deleted file mode 100644 index 7d20a42fa5..0000000000 --- a/share/providers/aws/terraform/variables.tf +++ /dev/null @@ -1,35 +0,0 @@ -variable "cidr_block" { - description = "CIDR block for the VPC" - type = string - default = "10.0.0.0/16" -} - -variable "oneform_hosts" { - description = "Number of instances to create" - type = number - default = 1 -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string - default = "c5.metal" -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string - default = "ubuntu_2204" -} - -variable "instance_disk_size" { - description = "Root disk size to use for the instance" - type = number - default = 128 -} - -variable "oneform_tags" { - description = "value of the tags to assign to the instance" - type = map(string) - default = {} -} diff --git a/share/providers/dummy/ipam b/share/providers/dummy/ipam deleted file mode 120000 index 8f23a76f56..0000000000 --- a/share/providers/dummy/ipam +++ /dev/null @@ -1 +0,0 @@ -../../../src/ipamm_mad/remotes/dummy/ \ No newline at end of file diff --git a/share/providers/equinix/ansible/ansible.cfg b/share/providers/equinix/ansible/ansible.cfg deleted file mode 100644 index cd299125d6..0000000000 --- a/share/providers/equinix/ansible/ansible.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[defaults] -interpreter_python = auto - -# Dependencies, collections, plugins and roles -inventory_plugins = /usr/share/one/ansible/plugins/inventory -roles_path = /usr/share/one/one-deploy/roles:/usr/share/one/one-deploy/vendor/ceph-ansible/roles/ -collections_paths = /usr/share/one/one-deploy/ansible_collections/ -action_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/actions/ -callback_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/callback/ -filter_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/filter/ -library = /usr/share/one/one-deploy/vendor/ceph-ansible/library/ -module_utils = /usr/share/one/one-deploy/vendor/ceph-ansible/module_utils/ - -# Outputs -callbacks_enabled = profile_tasks -host_key_checking = false -display_skipped_hosts = false -retry_files_enabled = false -allow_world_readable_tmpfiles = true - -[privilege_escalation] -become = true -become_user = root - -[ssh_connection] -pipelining = true -ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/share/providers/equinix/ansible/inventory.yaml b/share/providers/equinix/ansible/inventory.yaml deleted file mode 100644 index cff6c434b9..0000000000 --- a/share/providers/equinix/ansible/inventory.yaml +++ /dev/null @@ -1 +0,0 @@ -plugin: opennebula_form diff --git a/share/providers/equinix/ansible/roles/iptables/README.md b/share/providers/equinix/ansible/roles/iptables/README.md deleted file mode 100644 index 869c8c611c..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# iptables - -## Description - -Creates the basic set of IPv4 and IPv6 packet filter rules to ensure only the specified traffic is allowed. Masqurade (NAT) with IP port forwarding can be enabled. - -## Requirements - -No special requirements. - -## Variables - -All of the variables in this role are documented in the [defaults](defaults/main.yaml) file. - -## Todo list - -None diff --git a/share/providers/equinix/ansible/roles/iptables/defaults/main.yaml b/share/providers/equinix/ansible/roles/iptables/defaults/main.yaml deleted file mode 100644 index 61aad114ae..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/defaults/main.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -################################################################################ -# Mandatory -################################################################################ - -# Enable IP forwarding -iptables_ip_forward_enabled: true - -# Manage persistent configuration -iptables_manage_persistent: true - -# Create set of base rules -iptables_base_rules_enabled: true - -# Particular network interface to limit the base rules -iptables_base_rules_interface: NULL - -# Include the rules to drop any other traffic -iptables_base_rules_strict: true - -# List of whitelisted services -iptables_base_rules_services: - - { protocol: 'tcp', port: 22, chain: INPUT } - - { protocol: 'tcp', port: 25, chain: OUTPUT } - - { protocol: 'tcp', port: 587, chain: OUTPUT } - -# List of whitelisted hosts -iptables_hosts: [] - -# List of whitelisted hosts -iptables_6_hosts: [] - -# Enable NAT -iptables_masquerade_enabled: false - -# NAT output interface -iptables_masquerade_interface: "{{ ansible_default_ipv4.interface }}" diff --git a/share/providers/equinix/ansible/roles/iptables/tasks/Debian.yml b/share/providers/equinix/ansible/roles/iptables/tasks/Debian.yml deleted file mode 100644 index 515a639b89..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/tasks/Debian.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: Install iptables persistent - package: - name: iptables-persistent - state: present - -- name: Create persistent rules configurations - template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'rules.v4.j2', dest: '/etc/iptables/rules.v4' } - - { src: 'rules.v6.j2', dest: '/etc/iptables/rules.v6' } diff --git a/share/providers/equinix/ansible/roles/iptables/tasks/main.yml b/share/providers/equinix/ansible/roles/iptables/tasks/main.yml deleted file mode 100644 index b7702f2b28..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: Set net.ipv4.ip_forward - sysctl: - name: net.ipv4.ip_forward - value: "{{ iptables_ip_forward_enabled | int }}" - state: present - sysctl_file: /etc/sysctl.d/ip_forward.conf - reload: yes - -- include_tasks: '{{ ansible_os_family }}.yml' - when: iptables_manage_persistent - -- include_tasks: rules.yml - -- name: Restart iptables service - service: - name: iptables - state: restarted diff --git a/share/providers/equinix/ansible/roles/iptables/tasks/rules.yml b/share/providers/equinix/ansible/roles/iptables/tasks/rules.yml deleted file mode 100644 index de32fa8c70..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/tasks/rules.yml +++ /dev/null @@ -1,124 +0,0 @@ ---- -- name: Manage live iptables rule - masquerade - iptables: - state: "{% if iptables_masquerade_enabled %}present{% else %}absent{% endif %}" - table: nat - chain: POSTROUTING - out_interface: "{{ iptables_masquerade_interface }}" - jump: MASQUERADE - -- block: - # default IPv4 rules - - name: Accept related/established - iptables: - action: insert - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept icmp - iptables: - action: insert - table: filter - chain: INPUT - protocol: icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template - iptables: - action: insert - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept VNC ports - iptables: - action: insert - table: filter - chain: INPUT - protocol: tcp - match: multiport - destination_port: 5900:5999 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - # default IPv6 rules - - name: Accept related/established - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept ipv6-icmp - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: ipv6-icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template [IPv6] - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept DHCPv6 - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: udp - match: state - ctstate: NEW - destination: fe80::/64 - destination_port: 546 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - - name: Save iptables rules - shell: | - iptables-save > /etc/iptables/rules.v4 - ip6tables-save > /etc/iptables/rules.v6 - when: iptables_base_rules_enabled diff --git a/share/providers/equinix/ansible/roles/iptables/templates/rules.v4.j2 b/share/providers/equinix/ansible/roles/iptables/templates/rules.v4.j2 deleted file mode 100644 index a3f9d8fe55..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/templates/rules.v4.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# {{ ansible_managed }} -*nat -:PREROUTING ACCEPT [0:0] -:INPUT ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -:POSTROUTING ACCEPT [0:0] -{% if iptables_masquerade_enabled %} --A POSTROUTING -o {{ iptables_masquerade_interface }} -j MASQUERADE -{% endif %} -COMMIT -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p icmp -j ACCEPT --A INPUT -i lo -j ACCEPT --A INPUT -d 172.20.0.1/32 -p tcp -m tcp --dport 53 -j ACCEPT --A INPUT -d 172.20.0.1/32 -p udp -m udp --dport 53 -j ACCEPT -{% for host in iptables_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp-host-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/equinix/ansible/roles/iptables/templates/rules.v6.j2 b/share/providers/equinix/ansible/roles/iptables/templates/rules.v6.j2 deleted file mode 100644 index 65a77e11c8..0000000000 --- a/share/providers/equinix/ansible/roles/iptables/templates/rules.v6.j2 +++ /dev/null @@ -1,25 +0,0 @@ -# {{ ansible_managed }} -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p ipv6-icmp -j ACCEPT --A INPUT -i lo -j ACCEPT -{% for host in iptables_6_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -d fe80::/64 -p udp -m udp --dport 546 -m state --state NEW -j ACCEPT -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp6-adm-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/equinix/ansible/site.yaml b/share/providers/equinix/ansible/site.yaml deleted file mode 100644 index 72ce70ddc3..0000000000 --- a/share/providers/equinix/ansible/site.yaml +++ /dev/null @@ -1,33 +0,0 @@ ---- -- name: Check hosts connectivity - hosts: node - gather_facts: false - tasks: - - name: Wait for hosts to be up - ansible.builtin.wait_for_connection: - timeout: 300 - - name: Wait for hosts to be reachable through SSH - wait_for: - host: "{{ ansible_host }}" - port: 22 - state: started - timeout: 60 - tags: always - -# ------------------------------------------------------------------------------ -# One-deploy playbooks -# ------------------------------------------------------------------------------ -- ansible.builtin.import_playbook: opennebula.deploy.main - -# ------------------------------------------------------------------------------ -# Other playbooks (optional) -# ------------------------------------------------------------------------------ - -- name: 'Networking configuration' - hosts: node - remote_user: ubuntu - become: True - roles: - - role: iptables - iptables_base_rules_interface: "{{ ansible_default_ipv4.interface }}" - tags: always diff --git a/share/providers/equinix/ansible/templates/ssh_cluster.j2 b/share/providers/equinix/ansible/templates/ssh_cluster.j2 deleted file mode 100644 index 96e07a3e22..0000000000 --- a/share/providers/equinix/ansible/templates/ssh_cluster.j2 +++ /dev/null @@ -1,92 +0,0 @@ -{# -name: Equinix SSH Cluster -description: It deploys a SSH cluster on Equinix -fireedge: - logo: "equinix_ssh_cluster.png" -user_inputs: - - name: oneform_public_ips - description: Number of public IPs to allocate - type: number - default: 0 - mandatory: false - match: - type: number - values: - min: 0 - max: 5 -#} - ---- -all: - vars: - one_version: "{{ one.version }}" - ds: - mode: generic - config: - SYSTEM_DS: - equinix_system_ds: - id: "{{ one.system_ds_id }}" - template: - type: SYSTEM_DS - tm_mad: ssh - safe_dirs: /var/tmp /tmp - IMAGE_DS: - equinix_image_ds: - id: "{{ one.image_ds_id }}" - template: - type: IMAGE_DS - ds_mad: fs - tm_mad: ssh - safe_dirs: /var/tmp /tmp - vn: - private_equinix_network: - managed: true - template: - vn_mad: vxlan - vxlan_mode: evpn - automatic_vlan_id: "yes" - phydev: enp125s0 - ip_link_conf: nolearning= - guest_mtu: 1450 - network_address: 172.17.2.0 - network_mask: 255.255.255.0 - gateway: 172.17.2.1 - dns: 1.1.1.1 - ar: - type: ip4 - ip: 172.17.2.100 - size: 100 - public_equinix_network: - managed: true - template: - vn_mad: elastic - bridge: br0 - netrole: public - vxlan_mode: evpn - vxlan_tep: dev - ip_link_conf: nolearning= - allowed_ports: - - protocol: tcp - ports: - - 22 - - 179 - - protocol: udp - ports: - - 8472 - - -frontend: - hosts: - f1: { ansible_user: root, ansible_host: "{{ one.frontend_ip}}" } - -node: - hosts: - {% for node in one.nodes %} - n{{ loop.index }}: { ansible_user: root, ansible_host: "{{ node }}" } - {% endfor %} - -router: - hosts: - {% if one.nodes | length > 0 %} - n1: { ansible_user: root, ansible_host: "{{ one.nodes[0] }}" } - {% endif %} diff --git a/share/providers/equinix/driver.conf b/share/providers/equinix/driver.conf deleted file mode 100644 index a6dfa9b2b6..0000000000 --- a/share/providers/equinix/driver.conf +++ /dev/null @@ -1,28 +0,0 @@ -# ------------------------------------------------ -# Driver conf -# ------------------------------------------------ - -name: 'Equinix' -description: 'Equinix Metal Cloud' -version: '1.0.0' - -# FireEdge configuration (logos, metadata, etc) -fireedge: - logo: '/fireedge/client/assets/images/providers/equinix.png' - color: "2EBFA5" - literals: - ny: 'New York' - am: 'Amsterdam' - sv: 'Silicon Valley' - ty: 'Tokyo' - operations: - add-host: amount # aws, scaleway, equinix - del-host: ids - add-ip: amount - layout: - provider: - - oneform_hosts - - instance_type - - instance_os_name - network: - - oneform_public_ips \ No newline at end of file diff --git a/share/providers/equinix/elastic/equinix.rb b/share/providers/equinix/elastic/equinix.rb deleted file mode 100644 index a98094c1d3..0000000000 --- a/share/providers/equinix/elastic/equinix.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # -require 'net/http' -require 'uri' -require 'json' - -# Class covering Equinix client -class Equinix - - def initialize(token) - @eq_token = token - @eq_endpoint = 'https://api.equinix.com/metal/v1' - end - - def api_call(path, type = Net::HTTP::Get, data = {}) - uri = URI.parse(@eq_endpoint + path) - https = Net::HTTP.new(uri.host, uri.port) - https.use_ssl = true - req = type.new(uri.path) - req['Content-Type'] = 'application/json' - req['X-Auth-Token'] = @eq_token - req.body = data.to_json unless data.empty? - - return https.request(req) - end - -end diff --git a/share/providers/equinix/elastic/equinix_vnm.rb b/share/providers/equinix/elastic/equinix_vnm.rb deleted file mode 100644 index 21843fe36b..0000000000 --- a/share/providers/equinix/elastic/equinix_vnm.rb +++ /dev/null @@ -1,134 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # -# -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - EQUINIX_LOCATION ||= '/usr/lib/one/ruby/vendors/packethost/lib' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - EQUINIX_LOCATION ||= ONE_LOCATION + '/lib/ruby/vendors/packethost/lib' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << EQUINIX_LOCATION - -require 'net/http' -require 'uri' -require 'json' -require 'equinix' - -# Class covering Equinix functionality for Elastic driver -class EquinixProvider < GenericProvider - - def initialize(provider, host) - super(provider, host) - @eq = Equinix.new(@connection[:auth_token]) - end - - # Assign external IP to the device - def assign(_ip, external, _opts = {}) - ip_req = { - :manageable => true, - :address => external - } - resp = @eq.api_call( - "/devices/#{@resource_id}/ips", - Net::HTTP::Post, - ip_req - ) - - # HTTP 422 is returned if IP already assigned to the device - # e.g. VM poweroff from inside + onevm resume - unless ['201', '422'].include?(resp.code) - STDERR.puts "Error assigning #{external}: #{resp.code} - #{resp.message}" - return 1 - end - - return 0 - rescue StandardError => e - OpenNebula::DriverLogger.log_error("Error assigning #{external}: #{e.message}") - 1 - end - - def unassign(_ip, external, _opts = {}) - # find assignment id for external in device - resp = @eq.api_call("/devices/#{@resource_id}/ips") - - unless resp.code == '200' - STDERR.puts "Error unassigning #{external}: #{resp.message}" - return 1 - end - - assignment_id = nil - - JSON.parse(resp.body)['ip_addresses'].each do |ip| - if ip['address'] == external - assignment_id = ip['id'] - break - end - end - - unless assignment_id - STDERR.puts "Error unassigning #{external}: Can not find " << - "{external} ip in device #{@resource_id}" - # although unexpected still harmless, consider OK - return 0 - end - - # unassign external ip - resp = @eq.api_call("/ips/#{assignment_id}", Net::HTTP::Delete) - - unless resp.code == '204' - STDERR.puts "Equinix API failure, HTTP #{resp.code}, " << - "#{resp.message}, #{resp.body}" - return 1 - end - - return 0 - rescue StandardError => e - OpenNebula::DriverLogger.log_error("Error unassigning #{external}: #{e.message}") - 1 - end - - def activate(cmds, nic) - cmds.add :iptables, - "-t nat -A POSTROUTING -s #{nic[:ip]} -j SNAT " \ - "--to-source #{nic[:external_ip]}" - cmds.add :iptables, - "-t nat -A PREROUTING -d #{nic[:external_ip]} -j DNAT " \ - "--to-destination #{nic[:ip]}" - end - - def deactivate(cmds, nic) - cmds.add :iptables, - "-t nat -D POSTROUTING -s #{nic[:ip]} -j SNAT " \ - "--to-source #{nic[:external_ip]}" - cmds.add :iptables, - "-t nat -D PREROUTING -d #{nic[:external_ip]} -j DNAT " \ - "--to-destination #{nic[:ip]}" - end - -end diff --git a/share/providers/equinix/ipam/allocate_address b/share/providers/equinix/ipam/allocate_address deleted file mode 100755 index db56a76af9..0000000000 --- a/share/providers/equinix/ipam/allocate_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/equinix/ipam/free_address b/share/providers/equinix/ipam/free_address deleted file mode 100755 index db56a76af9..0000000000 --- a/share/providers/equinix/ipam/free_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/equinix/ipam/get_address b/share/providers/equinix/ipam/get_address deleted file mode 100755 index baa40039ad..0000000000 --- a/share/providers/equinix/ipam/get_address +++ /dev/null @@ -1,94 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to get a free IP address (or set of IPs). The IP will be -# used by OpenNebula VMs and should not be allocated to any other host in the -# network. -# -# STDIN Input: -# - Base64 encoded XML with the AR description and the address request -# -# XML format -# -# -# Equinix AR ID -# Equinix auth token -# -#
-# -# Number of IPs to allocate -# -#
-#
-# -# This scrit MUST output the leased IP range, if the "size" IPs cannot be -# assgined the sript must return -1, otherwise it must exit 0. The answer to -# OpenNebula needs to include the ADDRESS spec: -# -# ADDRESS = [ IP = "10.0.0.2", SIZE=34 ] -# -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION - -require 'base64' -require 'nokogiri' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - size = data.xpath('//ADDRESS/SIZE').text - ip = data.xpath('//AR/IP').text - - if size.to_i != 1 - STDERR.puts 'Only IP requests of size 1 are supported' - exit(-1) - end - - if ip.empty? - STDERR.puts 'Empty IP address in request' - exit(-1) - end - - puts <<-EOF - ADDRESS = [ - IP = "#{ip}", - SIZE = "1" - ] - EOF -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/equinix/ipam/register_address_range b/share/providers/equinix/ipam/register_address_range deleted file mode 100755 index 1259bb5b7e..0000000000 --- a/share/providers/equinix/ipam/register_address_range +++ /dev/null @@ -1,239 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to register a new IP network in the IPAM. The network may -# be selected by a pool of free networks or if an specific network is requested -# its availability maybe checked by the IPAM driver. -# -# The IPAM driver must return an OpenNebula AddressRange definition, potentially -# augmented with network specific variables to be used by VMs (e.g. GATEWAYS, -# MASK...) -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -# XML format -# -# -# Type of the Ip (public/global) -# Number of IPs to allocate -# ID -# -# -# -# The response MUST include IPAM_MAD, TYPE, IP and SIZE attributes, example: -# - A basic network definition -# AR = [ -# IPAM_MAD = "equinix", -# TYPE = "IP4", -# IP = "10.0.0.1", -# SIZE = "255", -# DEPLOY_ID = "..", -# ] -# -# - A complete network definition. Custom attributes (free form, key-value) -# can be added, named cannot be repeated. -# AR = [ -# IPAM_MAD = "equinix", -# TYPE = "IP4", -# IP = "10.0.0.2", -# SIZE = "200", -# DEPLOY_ID = "..", -# NETWORK_ADDRESS = "10.0.0.0", -# NETWORK_MASK = "255.255.255.0", -# GATEWAY = "10.0.0.1", -# DNS = "10.0.0.1", -# IPAM_ATTR = "10.0.0.240", -# OTHER_IPAM_ATTR = ".mydoamin.com" -# ] -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION = '/usr/lib/one' - EQUINIX_LOCATION = '/usr/lib/one/ruby/vendors/packethost/lib' - RUBY_LIB_LOCATION = '/usr/lib/one/ruby' - GEMS_LOCATION = '/usr/share/one/gems' - DRIVERS_PATH = '/usr/share/one/oneform/drivers' -else - LIB_LOCATION = ONE_LOCATION + '/lib' - EQUINIX_LOCATION = ONE_LOCATION + '/lib/ruby/vendors/packethost/lib' - RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION = ONE_LOCATION + '/share/gems' - DRIVERS_PATH = ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << EQUINIX_LOCATION -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << DRIVERS_PATH + '/equinix/elastic' - -require 'net/http' -require 'uri' -require 'json' -require 'equinix' -require 'base64' -require 'nokogiri' -require 'opennebula' -require 'opennebula/oneform_client' -require 'ipaddr' -require 'digest' - -IP_TYPE = ['public_ipv4', 'global_ipv4'] - -DEFAULT_PRIVATE_CIDR = '172.16.0.0/12' - -# IP Address class -class IPAddr - - # Add ^ operator to the IPAddr class - def ^(other) - clone.set(@addr ^ other.to_i) - end - - # Add prefix method, to work with older ipadddr & ruby - def prefix - case @family - when Socket::AF_INET - n = IN4MASK ^ @mask_addr - i = 32 - when Socket::AF_INET6 - n = IN6MASK ^ @mask_addr - i = 128 - else - raise AddressFamilyError, 'unsupported address family' - end - while n>0 - n >>= 1 - i -= 1 - end - i - end - -end - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{document[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - - eq_token = connect[:auth_token] - eq_project = connect[:project_id] - eq_metro = connect[:region] - - # -------------------------------------------------------------------------- - # Connect to Equinix and allocate a new IP - # -------------------------------------------------------------------------- - private_cidr = data.xpath('//AR/PRIVATE_CIDR').text - - if private_cidr.empty? - private_cidr = DEFAULT_PRIVATE_CIDR - end - - cidr = IPAddr.new(private_cidr) - mask = 0x0FFFFFFFF >> cidr.prefix - - ip_req = { - 'type' => data.xpath('//AR/EQUINIX_IP_TYPE').text, - 'quantity' => data.xpath('//AR/SIZE').text.to_i, - 'metro' => eq_metro, - 'fail_on_approval_required' => true - } - - if ip_req['quantity'] != 1 - STDERR.puts 'Only address ranges of size 1 are supported' - exit(-1) - end - - if ip_req['type'].empty? - ip_req['type'] = IP_TYPE[0] - elsif !IP_TYPE.include?(ip_req['type']) - STDERR.puts "Type #{ip_req['type']} not supported. " \ - "Must be: #{IP_TYPE.join(', ')}" - exit(-1) - end - - eq = Equinix.new(eq_token) - resp = eq.api_call( - "/projects/#{eq_project}/ips", - Net::HTTP::Post, - ip_req - ) - - unless resp.code == '201' - STDERR.puts "Equinix API failure, HTTP #{resp.code}, #{resp.message}, #{resp.body}" - exit(-1) - end - - addr, id = JSON.parse(resp.body).fetch_values('address', 'id') - - ipmd5 = Digest::MD5.hexdigest(addr).to_i(16) & mask - eip = IPAddr.new(ipmd5, Socket::AF_INET) - - ipvm = (eip & mask) | cidr - ipgw = ipvm ^ 1 - - puts <<-EOF - AR = [ - TYPE = "IP4", - IP = "#{ipvm}", - SIZE = "#{ip_req['quantity']}", - IPAM_MAD = "equinix", - GATEWAY = "#{ipgw}", - EXTERNAL_IP = "#{addr}", - NETWORK_MASK = "255.255.255.254", - EQUINIX_IP_ID = "#{id}", - PROVISION_ID = "#{provision_id}" - ] - EOF -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/equinix/ipam/unregister_address_range b/share/providers/equinix/ipam/unregister_address_range deleted file mode 100755 index ad9a0bb03b..0000000000 --- a/share/providers/equinix/ipam/unregister_address_range +++ /dev/null @@ -1,122 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to unregister a new IP network in the IPAM. -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -# XML format -# -# -# Equinix AR ID -# Equinix auth token -# -# -# -################################################################################ -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - EQUINIX_LOCATION ||= '/usr/lib/one/ruby/vendors/packethost/lib' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - EQUINIX_LOCATION ||= ONE_LOCATION + '/lib/ruby/vendors/packethost/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << EQUINIX_LOCATION -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << DRIVERS_PATH + '/equinix/elastic' - -require 'net/http' -require 'uri' -require 'json' -require 'equinix' -require 'base64' -require 'nokogiri' -require 'opennebula' -require 'opennebula/oneform_client' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{provision[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - eq_token = connect[:auth_token] - - # -------------------------------------------------------------------------- - # Connect to Equinix and delete the IP - # -------------------------------------------------------------------------- - - equinix_id = data.xpath('//AR/EQUINIX_IP_ID').text.to_s - - if equinix_id.empty? - STDERR.puts 'Missing Equinix range ID' - exit(-1) - end - - eq = Equinix.new(eq_token) - resp = eq.api_call("/ips/#{equinix_id}", Net::HTTP::Delete) - - # In case resource not exists (404), we assume is already removed - unless ['204', '404'].include?(resp.code) - STDERR.puts "Equinix API failure, HTTP #{resp.code}, #{resp.message}, #{resp.body}" - exit(-1) - end -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/equinix/terraform/host/main.tf b/share/providers/equinix/terraform/host/main.tf deleted file mode 100644 index 8f77a72b2b..0000000000 --- a/share/providers/equinix/terraform/host/main.tf +++ /dev/null @@ -1,16 +0,0 @@ -resource "equinix_metal_ssh_key" "oneadmin_pubkey" { - name = "provision_key_${var.provision_id}" - public_key = file(pathexpand("~/.ssh/id_rsa.pub")) -} - -resource "equinix_metal_device" "host" { - count = var.oneform_hosts - hostname = "provision-${var.provision_id}-host-${count.index}" - plan = var.instance_type - metro = var.equinix_region - operating_system = var.instance_os_name - project_id = var.equinix_project_id - billing_cycle = "hourly" - tags = [for key, value in var.equinix_tags : "${key}=${value}"] - depends_on = [equinix_metal_ssh_key.oneadmin_pubkey] -} \ No newline at end of file diff --git a/share/providers/equinix/terraform/host/outputs.tf b/share/providers/equinix/terraform/host/outputs.tf deleted file mode 100644 index 0c8d79365c..0000000000 --- a/share/providers/equinix/terraform/host/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "id" { - value = [for instance in equinix_metal_device.host : instance.id] -} - -output "public_ip" { - value = [for instance in equinix_metal_device.host : instance.network[0].address] -} diff --git a/share/providers/equinix/terraform/host/provider.tf b/share/providers/equinix/terraform/host/provider.tf deleted file mode 100644 index 097d7edde6..0000000000 --- a/share/providers/equinix/terraform/host/provider.tf +++ /dev/null @@ -1,7 +0,0 @@ -terraform { - required_providers { - equinix = { - source = "equinix/equinix" - } - } -} diff --git a/share/providers/equinix/terraform/host/variables.tf b/share/providers/equinix/terraform/host/variables.tf deleted file mode 100644 index f62fb2966e..0000000000 --- a/share/providers/equinix/terraform/host/variables.tf +++ /dev/null @@ -1,34 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number - default = 1 -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string -} - -variable "equinix_project_id" { - description = "Project ID to use for the instance" - type = string -} - -variable "equinix_region" { - description = "Region to use for the instance" - type = string -} - -variable "equinix_tags" { - description = "value of the tags to assign to the instance" - type = map(string) -} - -variable "provision_id" { - description = "Provision ID for the host" -} \ No newline at end of file diff --git a/share/providers/equinix/terraform/locals.tf b/share/providers/equinix/terraform/locals.tf deleted file mode 100644 index ce7eb41c94..0000000000 --- a/share/providers/equinix/terraform/locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "random_id" "key_suffix" { - byte_length = 6 -} - -locals { - provision_id = ( - contains(keys(var.oneform_tags), "provision_id") ? - var.oneform_tags["provision_id"] : random_id.key_suffix.id - ) -} \ No newline at end of file diff --git a/share/providers/equinix/terraform/main.tf b/share/providers/equinix/terraform/main.tf deleted file mode 100644 index 7df3f3da71..0000000000 --- a/share/providers/equinix/terraform/main.tf +++ /dev/null @@ -1,14 +0,0 @@ -module "host" { - source = "./host" - provision_id = local.provision_id - - # Equinix info - equinix_region = var.region - equinix_project_id = var.project_id - equinix_tags = var.oneform_tags - - # Host info - oneform_hosts = var.oneform_hosts - instance_type = var.instance_type - instance_os_name = var.instance_os_name -} diff --git a/share/providers/equinix/terraform/outputs.tf b/share/providers/equinix/terraform/outputs.tf deleted file mode 100644 index 975165f891..0000000000 --- a/share/providers/equinix/terraform/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "provisioned_hosts" { - value = [ - for idx in range(length(module.host.id)) : { - instance_id = module.host.id[idx] - instance_ip = module.host.public_ip[idx] - } - ] -} diff --git a/share/providers/equinix/terraform/provider.tf b/share/providers/equinix/terraform/provider.tf deleted file mode 100644 index e7bb9b075f..0000000000 --- a/share/providers/equinix/terraform/provider.tf +++ /dev/null @@ -1,29 +0,0 @@ -terraform { - required_providers { - equinix = { - source = "equinix/equinix" - } - } -} - -variable "auth_token" { - type = string - sensitive = true - description = "Equinix Auth Token" -} - -variable "project_id" { - type = string - sensitive = true - description = "Equinix Project ID" -} - -variable "region" { - type = string - description = "Equinix Region" - default = "am" -} - -provider "equinix" { - auth_token = var.auth_token -} diff --git a/share/providers/equinix/terraform/validators.tf b/share/providers/equinix/terraform/validators.tf deleted file mode 100644 index 68119f9836..0000000000 --- a/share/providers/equinix/terraform/validators.tf +++ /dev/null @@ -1,27 +0,0 @@ -locals { - # Equinix provider validators - validators = { - instance_type = { - type = "list" - values = ["c3.small"] - } - - oneform_hosts = { - type = "number" - values = { - min = 1 - max = 10 - } - } - - instance_os_name = { - type = "list" - values = ["ubuntu_22_04", "ubuntu_24_04"] - } - - region = { - type = "list" - values = ["am", "ty", "sv", "ny"] - } - } -} diff --git a/share/providers/equinix/terraform/variables.tf b/share/providers/equinix/terraform/variables.tf deleted file mode 100644 index 4f430c4c67..0000000000 --- a/share/providers/equinix/terraform/variables.tf +++ /dev/null @@ -1,23 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number - default = 1 -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string - default = "c3.small" -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string - default = "ubuntu_22_04" -} - -variable "oneform_tags" { - description = "value of the tags to assign to the instance" - type = map(string) - default = {} -} \ No newline at end of file diff --git a/share/providers/i3dnet/ansible/ansible.cfg b/share/providers/i3dnet/ansible/ansible.cfg deleted file mode 100644 index cd299125d6..0000000000 --- a/share/providers/i3dnet/ansible/ansible.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[defaults] -interpreter_python = auto - -# Dependencies, collections, plugins and roles -inventory_plugins = /usr/share/one/ansible/plugins/inventory -roles_path = /usr/share/one/one-deploy/roles:/usr/share/one/one-deploy/vendor/ceph-ansible/roles/ -collections_paths = /usr/share/one/one-deploy/ansible_collections/ -action_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/actions/ -callback_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/callback/ -filter_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/filter/ -library = /usr/share/one/one-deploy/vendor/ceph-ansible/library/ -module_utils = /usr/share/one/one-deploy/vendor/ceph-ansible/module_utils/ - -# Outputs -callbacks_enabled = profile_tasks -host_key_checking = false -display_skipped_hosts = false -retry_files_enabled = false -allow_world_readable_tmpfiles = true - -[privilege_escalation] -become = true -become_user = root - -[ssh_connection] -pipelining = true -ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/share/providers/i3dnet/ansible/inventory.yaml b/share/providers/i3dnet/ansible/inventory.yaml deleted file mode 100644 index cff6c434b9..0000000000 --- a/share/providers/i3dnet/ansible/inventory.yaml +++ /dev/null @@ -1 +0,0 @@ -plugin: opennebula_form diff --git a/share/providers/i3dnet/ansible/site.yaml b/share/providers/i3dnet/ansible/site.yaml deleted file mode 100644 index 5cd806b3b6..0000000000 --- a/share/providers/i3dnet/ansible/site.yaml +++ /dev/null @@ -1,35 +0,0 @@ ---- -- name: Check hosts connectivity - hosts: node - gather_facts: false - tasks: - - name: Wait for hosts to be up - ansible.builtin.wait_for_connection: - timeout: 300 - - name: Wait for hosts to be reachable through SSH - wait_for: - host: "{{ ansible_host }}" - port: 22 - state: started - timeout: 60 - tags: always - -# ------------------------------------------------------------------------------ -# One-deploy playbooks -# ------------------------------------------------------------------------------ -- name: Configure OpenNebula nodes - ansible.builtin.import_playbook: opennebula.deploy.main - -# ------------------------------------------------------------------------------ -# Other playbooks (optional) -# ------------------------------------------------------------------------------ - -- name: 'Networking configuration' - hosts: node - remote_user: ubuntu - become: True - roles: - - role: iptables - iptables_base_rules_interface: "{{ ansible_default_ipv4.interface }}" - tags: always - \ No newline at end of file diff --git a/share/providers/i3dnet/ansible/templates/ssh_cluster.j2 b/share/providers/i3dnet/ansible/templates/ssh_cluster.j2 deleted file mode 100644 index 020b5c1c07..0000000000 --- a/share/providers/i3dnet/ansible/templates/ssh_cluster.j2 +++ /dev/null @@ -1,63 +0,0 @@ -{# -name: i3Dnet SSH Cluster -description: It deploys a SSH cluster on i3Dnet -fireedge: - logo: "i3dnet_ssh_cluster.png" -#} - ---- -all: - vars: - one_version: "{{ one.version }}" - vn: - private_i3dnet_network: - managed: true - template: - vn_mad: vxlan - vxlan_mode: evpn - automatic_vlan_id: "yes" - phydev: enp125s0 - ip_link_conf: nolearning= - guest_mtu: 1450 - network_address: 172.17.2.0 - network_mask: 255.255.255.0 - gateway: 172.17.2.1 - dns: 1.1.1.1 - ar: - type: ip4 - ip: 172.17.2.100 - size: 100 - ds: - mode: generic - config: - SYSTEM_DS: - i3dnet_system_ds: - id: "{{ one.system_ds_id}}" - template: - type: SYSTEM_DS - tm_mad: ssh - safe_dirs: /var/tmp /tmp - IMAGE_DS: - i3dnet_image_ds: - id: "{{ one.image_ds_id }}" - template: - type: IMAGE_DS - ds_mad: fs - tm_mad: ssh - safe_dirs: /var/tmp /tmp - -frontend: - hosts: - f1: { ansible_user: root, ansible_host: "{{ one.frontend_ip }}" } - -node: - hosts: - {% for node in one.nodes %} - n{{ loop.index }}: { ansible_user: root, ansible_host: "{{ node }}" } - {% endfor %} - -router: - hosts: - {% if one.nodes | length > 0 %} - n1: { ansible_user: root, ansible_host: "{{ one.nodes[0] }}" } - {% endif %} diff --git a/share/providers/i3dnet/driver.conf b/share/providers/i3dnet/driver.conf deleted file mode 100644 index 38a203740c..0000000000 --- a/share/providers/i3dnet/driver.conf +++ /dev/null @@ -1,21 +0,0 @@ -# ------------------------------------------------ -# Driver conf -# ------------------------------------------------ - -name: 'i3Dnet' -description: 'i3Dnet cloud provider' -version: '1.0.0' - -# FireEdge configuration (logos, metadata, etc) -fireedge: - logo: '/fireedge/client/assets/images/providers/i3dnet.png' - color: "000f00" - operations: - add-host: amount # aws, scaleway, equinix - del-host: ids - add-ip: amount - layout: - provider: - - oneform_hosts - - instance_type - - instance_os_name \ No newline at end of file diff --git a/share/providers/i3dnet/terraform/host/main.tf b/share/providers/i3dnet/terraform/host/main.tf deleted file mode 100644 index e10e3e8f4e..0000000000 --- a/share/providers/i3dnet/terraform/host/main.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "i3dnet_flexmetal_server" "host" { - count = var.oneform_hosts - name = "provision_${var.provision_id}_host_${count.index}" - location = var.i3dnet_region - instance_type = var.instance_type - os = { - slug = var.instance_os_name - } - ssh_key = [file("~/.ssh/id_rsa.pub")] -} diff --git a/share/providers/i3dnet/terraform/host/output.tf b/share/providers/i3dnet/terraform/host/output.tf deleted file mode 100644 index baac036ac9..0000000000 --- a/share/providers/i3dnet/terraform/host/output.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "id" { - value = [for instance in i3dnet_flexmetal_server.host : instance.uuid] -} - -output "public_ip" { - value = [for instance in i3dnet_flexmetal_server.host : instance.ip_addresses[0].ip_address] -} diff --git a/share/providers/i3dnet/terraform/host/provider.tf b/share/providers/i3dnet/terraform/host/provider.tf deleted file mode 100644 index a911aedbe0..0000000000 --- a/share/providers/i3dnet/terraform/host/provider.tf +++ /dev/null @@ -1,7 +0,0 @@ -terraform { - required_providers { - i3dnet = { - source = "registry.terraform.io/i3D-net/i3dnet" - } - } -} diff --git a/share/providers/i3dnet/terraform/host/variables.tf b/share/providers/i3dnet/terraform/host/variables.tf deleted file mode 100644 index 3e5ca79948..0000000000 --- a/share/providers/i3dnet/terraform/host/variables.tf +++ /dev/null @@ -1,28 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string -} - -variable "i3dnet_region" { - description = "Region to use for the instance" - type = string -} - -variable "i3dnet_tags" { - description = "value of the tags to assign to the instance" - type = map(string) -} - -variable "provision_id" { - description = "Provision ID for the host" -} \ No newline at end of file diff --git a/share/providers/i3dnet/terraform/locals.tf b/share/providers/i3dnet/terraform/locals.tf deleted file mode 100644 index ce7eb41c94..0000000000 --- a/share/providers/i3dnet/terraform/locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "random_id" "key_suffix" { - byte_length = 6 -} - -locals { - provision_id = ( - contains(keys(var.oneform_tags), "provision_id") ? - var.oneform_tags["provision_id"] : random_id.key_suffix.id - ) -} \ No newline at end of file diff --git a/share/providers/i3dnet/terraform/main.tf b/share/providers/i3dnet/terraform/main.tf deleted file mode 100644 index 73e205df88..0000000000 --- a/share/providers/i3dnet/terraform/main.tf +++ /dev/null @@ -1,10 +0,0 @@ -module "host" { - source = "./host" - provision_id = local.provision_id - - i3dnet_region = var.region - oneform_hosts = var.oneform_hosts - instance_type = var.instance_type - instance_os_name = var.instance_os_name - i3dnet_tags = var.oneform_tags -} diff --git a/share/providers/i3dnet/terraform/outputs.tf b/share/providers/i3dnet/terraform/outputs.tf deleted file mode 100644 index 975165f891..0000000000 --- a/share/providers/i3dnet/terraform/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "provisioned_hosts" { - value = [ - for idx in range(length(module.host.id)) : { - instance_id = module.host.id[idx] - instance_ip = module.host.public_ip[idx] - } - ] -} diff --git a/share/providers/i3dnet/terraform/provider.tf b/share/providers/i3dnet/terraform/provider.tf deleted file mode 100644 index 3b9f1c138c..0000000000 --- a/share/providers/i3dnet/terraform/provider.tf +++ /dev/null @@ -1,22 +0,0 @@ -terraform { - required_providers { - i3dnet = { - source = "registry.terraform.io/i3D-net/i3dnet" - } - } -} - -variable "i3dnet_api_key" { - sensitive = true - type = string - description = "API key for i3D.net" -} - -variable "region" { - type = string - description = "Region for i3D.net" -} - -provider "i3dnet" { - api_key = var.i3dnet_api_key -} diff --git a/share/providers/i3dnet/terraform/validators.tf b/share/providers/i3dnet/terraform/validators.tf deleted file mode 100644 index 06dfe64531..0000000000 --- a/share/providers/i3dnet/terraform/validators.tf +++ /dev/null @@ -1,27 +0,0 @@ -locals { - # I3D provider validators - validators = { - instance_type = { - type = "list" - values = ["bm7.std.8"] - } - - oneform_hosts = { - type = "number" - values = { - min = 1 - max = 10 - } - } - - instance_os_name = { - type = "list" - values = ["ubuntu-2404-lts"] - } - - region = { - type = "list" - values = ["EU: Rotterdam"] - } - } -} diff --git a/share/providers/i3dnet/terraform/variables.tf b/share/providers/i3dnet/terraform/variables.tf deleted file mode 100644 index 630179e89e..0000000000 --- a/share/providers/i3dnet/terraform/variables.tf +++ /dev/null @@ -1,23 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number - default = 1 -} - -variable "instance_type" { - description = "Instance type to use for the instance" - type = string - default = "bm7.std.8" -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string - default = "ubuntu-2404-lts" -} - -variable "oneform_tags" { - description = "value of the tags to assign to the instance" - type = map(string) - default = {} -} diff --git a/share/providers/onprem/ansible/ansible.cfg b/share/providers/onprem/ansible/ansible.cfg deleted file mode 100644 index 572bcb0751..0000000000 --- a/share/providers/onprem/ansible/ansible.cfg +++ /dev/null @@ -1,18 +0,0 @@ -[defaults] -interpreter_python = /usr/bin/python3 -library = ./roles -roles_path = ./roles -inventory_plugins = /usr/share/one/ansible/plugins/inventory -collections_path = /usr/share/one/one-deploy -callback_whitelist = profile_tasks -display_skipped_hosts = False -retry_files_enabled = False -host_key_checking = False -allow_world_readable_tmpfiles = True - -[privilege_escalation] -become = True -become_user = root - -[ssh_connection] -ssh_args = -o ControlMaster=auto -o ControlPersist=60s \ No newline at end of file diff --git a/share/providers/onprem/ansible/inventory.yaml b/share/providers/onprem/ansible/inventory.yaml deleted file mode 100644 index cff6c434b9..0000000000 --- a/share/providers/onprem/ansible/inventory.yaml +++ /dev/null @@ -1 +0,0 @@ -plugin: opennebula_form diff --git a/share/providers/scaleway/ansible/ansible.cfg b/share/providers/scaleway/ansible/ansible.cfg deleted file mode 100644 index cd299125d6..0000000000 --- a/share/providers/scaleway/ansible/ansible.cfg +++ /dev/null @@ -1,27 +0,0 @@ -[defaults] -interpreter_python = auto - -# Dependencies, collections, plugins and roles -inventory_plugins = /usr/share/one/ansible/plugins/inventory -roles_path = /usr/share/one/one-deploy/roles:/usr/share/one/one-deploy/vendor/ceph-ansible/roles/ -collections_paths = /usr/share/one/one-deploy/ansible_collections/ -action_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/actions/ -callback_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/callback/ -filter_plugins = /usr/share/one/one-deploy/vendor/ceph-ansible/plugins/filter/ -library = /usr/share/one/one-deploy/vendor/ceph-ansible/library/ -module_utils = /usr/share/one/one-deploy/vendor/ceph-ansible/module_utils/ - -# Outputs -callbacks_enabled = profile_tasks -host_key_checking = false -display_skipped_hosts = false -retry_files_enabled = false -allow_world_readable_tmpfiles = true - -[privilege_escalation] -become = true -become_user = root - -[ssh_connection] -pipelining = true -ssh_args = -o ControlMaster=auto -o ControlPersist=60s diff --git a/share/providers/scaleway/ansible/inventory.yaml b/share/providers/scaleway/ansible/inventory.yaml deleted file mode 100644 index 2fd559e1fa..0000000000 --- a/share/providers/scaleway/ansible/inventory.yaml +++ /dev/null @@ -1 +0,0 @@ -plugin: opennebula_form \ No newline at end of file diff --git a/share/providers/scaleway/ansible/roles/iptables/README.md b/share/providers/scaleway/ansible/roles/iptables/README.md deleted file mode 100644 index 869c8c611c..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/README.md +++ /dev/null @@ -1,17 +0,0 @@ -# iptables - -## Description - -Creates the basic set of IPv4 and IPv6 packet filter rules to ensure only the specified traffic is allowed. Masqurade (NAT) with IP port forwarding can be enabled. - -## Requirements - -No special requirements. - -## Variables - -All of the variables in this role are documented in the [defaults](defaults/main.yaml) file. - -## Todo list - -None diff --git a/share/providers/scaleway/ansible/roles/iptables/defaults/main.yaml b/share/providers/scaleway/ansible/roles/iptables/defaults/main.yaml deleted file mode 100644 index 61aad114ae..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/defaults/main.yaml +++ /dev/null @@ -1,38 +0,0 @@ ---- - -################################################################################ -# Mandatory -################################################################################ - -# Enable IP forwarding -iptables_ip_forward_enabled: true - -# Manage persistent configuration -iptables_manage_persistent: true - -# Create set of base rules -iptables_base_rules_enabled: true - -# Particular network interface to limit the base rules -iptables_base_rules_interface: NULL - -# Include the rules to drop any other traffic -iptables_base_rules_strict: true - -# List of whitelisted services -iptables_base_rules_services: - - { protocol: 'tcp', port: 22, chain: INPUT } - - { protocol: 'tcp', port: 25, chain: OUTPUT } - - { protocol: 'tcp', port: 587, chain: OUTPUT } - -# List of whitelisted hosts -iptables_hosts: [] - -# List of whitelisted hosts -iptables_6_hosts: [] - -# Enable NAT -iptables_masquerade_enabled: false - -# NAT output interface -iptables_masquerade_interface: "{{ ansible_default_ipv4.interface }}" diff --git a/share/providers/scaleway/ansible/roles/iptables/tasks/Debian.yml b/share/providers/scaleway/ansible/roles/iptables/tasks/Debian.yml deleted file mode 100644 index 515a639b89..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/tasks/Debian.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- - -- name: Install iptables persistent - package: - name: iptables-persistent - state: present - -- name: Create persistent rules configurations - template: - src: "{{ item.src }}" - dest: "{{ item.dest }}" - with_items: - - { src: 'rules.v4.j2', dest: '/etc/iptables/rules.v4' } - - { src: 'rules.v6.j2', dest: '/etc/iptables/rules.v6' } diff --git a/share/providers/scaleway/ansible/roles/iptables/tasks/main.yml b/share/providers/scaleway/ansible/roles/iptables/tasks/main.yml deleted file mode 100644 index b7702f2b28..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/tasks/main.yml +++ /dev/null @@ -1,19 +0,0 @@ ---- - -- name: Set net.ipv4.ip_forward - sysctl: - name: net.ipv4.ip_forward - value: "{{ iptables_ip_forward_enabled | int }}" - state: present - sysctl_file: /etc/sysctl.d/ip_forward.conf - reload: yes - -- include_tasks: '{{ ansible_os_family }}.yml' - when: iptables_manage_persistent - -- include_tasks: rules.yml - -- name: Restart iptables service - service: - name: iptables - state: restarted diff --git a/share/providers/scaleway/ansible/roles/iptables/tasks/rules.yml b/share/providers/scaleway/ansible/roles/iptables/tasks/rules.yml deleted file mode 100644 index de32fa8c70..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/tasks/rules.yml +++ /dev/null @@ -1,124 +0,0 @@ ---- -- name: Manage live iptables rule - masquerade - iptables: - state: "{% if iptables_masquerade_enabled %}present{% else %}absent{% endif %}" - table: nat - chain: POSTROUTING - out_interface: "{{ iptables_masquerade_interface }}" - jump: MASQUERADE - -- block: - # default IPv4 rules - - name: Accept related/established - iptables: - action: insert - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept icmp - iptables: - action: insert - table: filter - chain: INPUT - protocol: icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template - iptables: - action: insert - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept VNC ports - iptables: - action: insert - table: filter - chain: INPUT - protocol: tcp - match: multiport - destination_port: 5900:5999 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - # default IPv6 rules - - name: Accept related/established - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - match: state - ctstate: RELATED,ESTABLISHED - jump: ACCEPT - rule_num: 1 - - name: Accept ipv6-icmp - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: ipv6-icmp - jump: ACCEPT - rule_num: 2 - - name: Accept all on lo - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - in_interface: lo - jump: ACCEPT - rule_num: 3 - - name: Add allowed ports from the Hosted Template [IPv6] - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: "{{ item[0].protocol }}" - match: state - ctstate: NEW - destination_port: "{{ item[1] }}" - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - with_subelements: - - "{{ allowed_ports }}" - - ports - - name: Accept DHCPv6 - iptables: - action: insert - ip_version: ipv6 - table: filter - chain: INPUT - protocol: udp - match: state - ctstate: NEW - destination: fe80::/64 - destination_port: 546 - in_interface: "{{ iptables_base_rules_interface }}" - jump: ACCEPT - - - name: Save iptables rules - shell: | - iptables-save > /etc/iptables/rules.v4 - ip6tables-save > /etc/iptables/rules.v6 - when: iptables_base_rules_enabled diff --git a/share/providers/scaleway/ansible/roles/iptables/templates/rules.v4.j2 b/share/providers/scaleway/ansible/roles/iptables/templates/rules.v4.j2 deleted file mode 100644 index a3f9d8fe55..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/templates/rules.v4.j2 +++ /dev/null @@ -1,35 +0,0 @@ -# {{ ansible_managed }} -*nat -:PREROUTING ACCEPT [0:0] -:INPUT ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -:POSTROUTING ACCEPT [0:0] -{% if iptables_masquerade_enabled %} --A POSTROUTING -o {{ iptables_masquerade_interface }} -j MASQUERADE -{% endif %} -COMMIT -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p icmp -j ACCEPT --A INPUT -i lo -j ACCEPT --A INPUT -d 172.20.0.1/32 -p tcp -m tcp --dport 53 -j ACCEPT --A INPUT -d 172.20.0.1/32 -p udp -m udp --dport 53 -j ACCEPT -{% for host in iptables_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp-host-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/scaleway/ansible/roles/iptables/templates/rules.v6.j2 b/share/providers/scaleway/ansible/roles/iptables/templates/rules.v6.j2 deleted file mode 100644 index 65a77e11c8..0000000000 --- a/share/providers/scaleway/ansible/roles/iptables/templates/rules.v6.j2 +++ /dev/null @@ -1,25 +0,0 @@ -# {{ ansible_managed }} -*filter -:INPUT ACCEPT [0:0] -:FORWARD ACCEPT [0:0] -:OUTPUT ACCEPT [0:0] -{% if iptables_base_rules_enabled %} --A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT --A INPUT -p ipv6-icmp -j ACCEPT --A INPUT -i lo -j ACCEPT -{% for host in iptables_6_hosts %} --A INPUT -s {{ host }} -j ACCEPT -{% endfor %} -{% for service in iptables_base_rules_services %} -{% if service.chain == 'INPUT' %} --A INPUT -i {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% elif service.chain == 'OUTPUT' %} --A OUTPUT -o {{ iptables_base_rules_interface }} -p {{ service.protocol }} -m state --state NEW -m {{ service.protocol }} --dport {{ service.port }} -j ACCEPT -{% endif %} -{% endfor %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -d fe80::/64 -p udp -m udp --dport 546 -m state --state NEW -j ACCEPT -{% if iptables_base_rules_strict %} --A INPUT {% if iptables_base_rules_interface %}-i {{ iptables_base_rules_interface }}{% endif %} -j REJECT --reject-with icmp6-adm-prohibited -{% endif %} -{% endif %} -COMMIT diff --git a/share/providers/scaleway/ansible/site.yaml b/share/providers/scaleway/ansible/site.yaml deleted file mode 100644 index 2a76e148ba..0000000000 --- a/share/providers/scaleway/ansible/site.yaml +++ /dev/null @@ -1,40 +0,0 @@ ---- -- name: Check hosts connectivity - hosts: all - gather_facts: false - tasks: - - name: Wait for hosts to be up - ansible.builtin.wait_for_connection: - timeout: 900 - - name: Wait for hosts to be reachable through SSH - wait_for: - host: "{{ ansible_host }}" - port: 22 - state: started - timeout: 900 - tags: always - -# ------------------------------------------------------------------------------ -# One-deploy playbooks -# ------------------------------------------------------------------------------ -- ansible.builtin.import_playbook: opennebula.deploy.main - -# ------------------------------------------------------------------------------ -# Other playbooks (optional) -# ------------------------------------------------------------------------------ -# - name: 'Example role' -# hosts: all -# tasks: -# - name: 'Example task' -# ansible.builtin.debug: -# msg: 'Hello, world!' -# tags: always - -- name: 'Networking configuration' - hosts: node - remote_user: ubuntu - become: True - roles: - - role: iptables - iptables_base_rules_interface: "{{ ansible_default_ipv4.interface }}" - tags: always diff --git a/share/providers/scaleway/ansible/templates/ssh_cluster.j2 b/share/providers/scaleway/ansible/templates/ssh_cluster.j2 deleted file mode 100644 index 23ff8e0624..0000000000 --- a/share/providers/scaleway/ansible/templates/ssh_cluster.j2 +++ /dev/null @@ -1,92 +0,0 @@ -{# -name: Scaleway SSH Cluster -description: It deploys a SSH cluster on Scaleway -fireedge: - logo: "scaleway_ssh_cluster.png" -user_inputs: - - name: oneform_public_ips - description: Number of public IPs to allocate - type: number - default: 0 - mandatory: false - match: - type: number - values: - min: 0 - max: 5 -#} - ---- -all: - vars: - one_version: "{{ one.version }}" - ds: - mode: generic - config: - SYSTEM_DS: - scaleway_system_ds: - id: "{{ one.system_ds_id}}" - template: - type: SYSTEM_DS - tm_mad: ssh - safe_dirs: /var/tmp /tmp - IMAGE_DS: - scaleway_image_ds: - id: "{{ one.image_ds_id }}" - template: - type: IMAGE_DS - ds_mad: fs - tm_mad: ssh - safe_dirs: /var/tmp /tmp - vn: - private_scaleway_network: - managed: true - template: - vn_mad: vxlan - vxlan_mode: evpn - automatic_vlan_id: "yes" - phydev: eno1 - ip_link_conf: nolearning= - guest_mtu: 1450 - network_address: 172.17.2.0 - network_mask: 255.255.255.0 - gateway: 172.17.2.1 - dns: 1.1.1.1 - ar: - type: ip4 - ip: 172.17.2.100 - size: 100 - public_scaleway_network: - managed: true - template: - vn_mad: elastic - bridge: br0 - netrole: public - vxlan_mode: evpn - vxlan_tep: dev - ip_link_conf: nolearning= - allowed_ports: - - protocol: tcp - ports: - - 22 - - 179 - - protocol: udp - ports: - - 8472 - - -frontend: - hosts: - f1: { ansible_user: root, ansible_host: "{{ one.frontend_ip}}" } - -node: - hosts: - {% for node in one.nodes %} - n{{ loop.index }}: { ansible_user: ubuntu, ansible_host: "{{ node }}" } - {% endfor %} - -router: - hosts: - {% if one.nodes | length > 0 %} - n1: { ansible_user: ubuntu, ansible_host: "{{ one.nodes[0] }}" } - {% endif %} diff --git a/share/providers/scaleway/driver.conf b/share/providers/scaleway/driver.conf deleted file mode 100644 index 7a02cc2603..0000000000 --- a/share/providers/scaleway/driver.conf +++ /dev/null @@ -1,23 +0,0 @@ -# ------------------------------------------------ -# Driver conf -# ------------------------------------------------ - -name: 'Scaleway' -description: 'Scaleway provider template' -version: '1.0.0' - -# FireEdge configuration (logos, metadata, etc) -fireedge: - logo: '/fireedge/client/assets/images/providers/scaleway.png' - color: "948DD7" - operations: - add-host: amount # aws, scaleway, equinix - del-host: ids - add-ip: amount - layout: - provider: - - oneform_hosts - - instance_type - - instance_os_name - network: - - cidr_block \ No newline at end of file diff --git a/share/providers/scaleway/elastic/scaleway.rb b/share/providers/scaleway/elastic/scaleway.rb deleted file mode 100644 index 23a8911da6..0000000000 --- a/share/providers/scaleway/elastic/scaleway.rb +++ /dev/null @@ -1,40 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # -require 'net/http' -require 'uri' -require 'json' - -# Class covering Scaleway client -class Scaleway - - def initialize(token) - @sw_token = token - @sw_endpoint = 'https://api.scaleway.com' - end - - def api_call(path, type = Net::HTTP::Get, data = {}) - uri = URI.parse(@sw_endpoint + path) - https = Net::HTTP.new(uri.host, uri.port) - https.use_ssl = true - req = type.new(uri.path) - req['Content-Type'] = 'application/json' - req['X-Auth-Token'] = @sw_token - req.body = data.to_json unless data.empty? - - return https.request(req) - end - -end diff --git a/share/providers/scaleway/elastic/scaleway_vnm.rb b/share/providers/scaleway/elastic/scaleway_vnm.rb deleted file mode 100644 index 34ccf0d201..0000000000 --- a/share/providers/scaleway/elastic/scaleway_vnm.rb +++ /dev/null @@ -1,148 +0,0 @@ -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # -# -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - SCALEWAY_LOCATION ||= '/usr/lib/one/ruby/vendors/packethost/lib' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - SCALEWAY_LOCATION ||= ONE_LOCATION + '/lib/ruby/vendors/packethost/lib' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << SCALEWAY_LOCATION - -require 'net/http' -require 'uri' -require 'json' -require 'scaleway' - -# Class covering Scaleway functionality for Elastic driver -class ScalewayProvider < GenericProvider - - def initialize(provider, host) - super(provider, host) - @sw = Scaleway.new(@connection[:secret_key]) - - # Remove zone from resource uuid ("zone/uuid" by default) - @resource_id = @resource_id[%r{[^/]+\z}] if @resource_id - end - - def assign(_ip, external, _opts = {}) - # We need the fip_id of the external IP - flexible_ip = sw_flexible_ip(external) - - unless flexible_ip - STDERR.puts "Error assigning #{external}: IP not found" - return 1 - end - - return 0 if flexible_ip['status'] == 'attached' - - fip_req = { - :fips_ids => [flexible_ip['id']], - :server_id => @resource_id - } - - resp = @sw.api_call( - "/flexible-ip/v1alpha1/zones/#{@connection[:zone]}/fips/attach", - Net::HTTP::Post, - fip_req - ) - - # HTTP 409 is returned if IP is being assigned to the device - unless ['200', '409'].include?(resp.code) - STDERR.puts "Error assigning #{external}: #{resp.message}" - return 1 - end - - return 0 - rescue StandardError => e - OpenNebula::DriverLogger.log_error("Error assigning #{external}:#{e.message}") - 1 - end - - def unassign(_ip, external, _opts = {}) - # First of all, we need the fip_id of the external IP - flexible_ip = sw_flexible_ip(external) - - unless flexible_ip - STDERR.puts "Error unassigning #{external}: Can not find " << - "#{external} ip in device #{@resource_id}" - # although unexpected still harmless, consider OK - return 0 - end - - fip_req = { :fips_ids => [flexible_ip['id']] } - resp = @sw.api_call( - "/flexible-ip/v1alpha1/zones/#{@connection[:zone]}/fips/detach", - Net::HTTP::Post, - fip_req - ) - - # HTTP 409 is returned if IP is being unassigned to the device - unless ['200', '409'].include?(resp.code) - STDERR.puts "Error unassigning #{external}: #{resp.message}" - return 1 - end - - return 0 - rescue StandardError => e - OpenNebula::DriverLogger.log_error("Error unassigning #{external}: #{e.message}") - 1 - end - - def activate(cmds, nic) - cmds.add :iptables, - "-t nat -A POSTROUTING -s #{nic[:ip]} -j SNAT " \ - "--to-source #{nic[:external_ip]}" - cmds.add :iptables, - "-t nat -A PREROUTING -d #{nic[:external_ip]} -j DNAT " \ - "--to-destination #{nic[:ip]}" - end - - def deactivate(cmds, nic) - cmds.add :iptables, - "-t nat -D POSTROUTING -s #{nic[:ip]} -j SNAT " \ - "--to-source #{nic[:external_ip]}" - cmds.add :iptables, - "-t nat -D PREROUTING -d #{nic[:external_ip]} -j DNAT " \ - "--to-destination #{nic[:ip]}" - end - - private - - def sw_flexible_ip(external_ip) - path = "/flexible-ip/v1alpha1/zones/#{@connection[:zone]}/fips" - response = @sw.api_call(path) - - return unless response&.body - - flexible_ips = JSON.parse(response.body).fetch('flexible_ips', []) - flexible_ips.find {|fip| fip['ip_address'] == external_ip } - end - -end diff --git a/share/providers/scaleway/ipam/allocate_address b/share/providers/scaleway/ipam/allocate_address deleted file mode 100755 index 353840e115..0000000000 --- a/share/providers/scaleway/ipam/allocate_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/scaleway/ipam/free_address b/share/providers/scaleway/ipam/free_address deleted file mode 100755 index 353840e115..0000000000 --- a/share/providers/scaleway/ipam/free_address +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -STDIN=`cat -` - -exit 0 diff --git a/share/providers/scaleway/ipam/get_address b/share/providers/scaleway/ipam/get_address deleted file mode 100755 index a6ff71b2ca..0000000000 --- a/share/providers/scaleway/ipam/get_address +++ /dev/null @@ -1,97 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to get a free IP address (or set of IPs). The IP will be -# used by OpenNebula VMs and should not be allocated to any other host in the -# network. -# -# STDIN Input: -# - Base64 encoded XML with the AR description and the address request -# -# XML format -# -# -# Scaleway AR id -# access key -# secret key -# Scaleway Project ID -# zone -# -#
-# -# Number of IPs to allocate -# -#
-#
-# -# This scrit MUST output the leased IP range, if the "size" IPs cannot be -# assgined the sript must return -1, otherwise it must exit 0. The answer to -# OpenNebula needs to include the ADDRESS spec: -# -# ADDRESS = [ IP = "10.0.0.2", SIZE=34 ] -# -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION - -require 'base64' -require 'nokogiri' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - size = data.xpath('//ADDRESS/SIZE').text - ip = data.xpath('//AR/IP').text - - if size.to_i != 1 - STDERR.puts 'Only IP requests of size 1 are supported' - exit(-1) - end - - if ip.empty? - STDERR.puts 'Empty IP address in request' - exit(-1) - end - - puts <<-EOF - ADDRESS = [ - IP = "#{ip}", - SIZE = "1" - ] - EOF -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/scaleway/ipam/register_address_range b/share/providers/scaleway/ipam/register_address_range deleted file mode 100755 index 818fbf94e9..0000000000 --- a/share/providers/scaleway/ipam/register_address_range +++ /dev/null @@ -1,237 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to register a new IP network in the IPAM. The network may -# be selected by a pool of free networks or if an specific network is requested -# its availability maybe checked by the IPAM driver. -# -# The IPAM driver must return an OpenNebula AddressRange definition, potentially -# augmented with network specific variables to be used by VMs (e.g. GATEWAYS, -# MASK...) -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -# XML format -# -# -# Type of the Ip (ipv4/ipv6) -# ID -# -# -# -# The response MUST include IPAM_MAD, TYPE, IP and SIZE attributes, example: -# - A basic network definition -# AR = [ -# IPAM_MAD = "scaleway", -# TYPE = "IP4", -# IP = "10.0.0.1", -# SIZE = "255", -# DEPLOY_ID = "..", -# ] -# -# - A complete network definition. Custom attributes (free form, key-value) -# can be added, named cannot be repeated. -# AR = [ -# IPAM_MAD = "scaleway", -# TYPE = "IP4", -# IP = "10.0.0.2", -# SIZE = "200", -# DEPLOY_ID = "..", -# NETWORK_ADDRESS = "10.0.0.0", -# NETWORK_MASK = "255.255.255.0", -# GATEWAY = "10.0.0.1", -# DNS = "10.0.0.1", -# IPAM_ATTR = "10.0.0.240", -# OTHER_IPAM_ATTR = ".mydoamin.com" -# ] -################################################################################ - -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION = '/usr/lib/one' - RUBY_LIB_LOCATION = '/usr/lib/one/ruby' - GEMS_LOCATION = '/usr/share/one/gems' - DRIVERS_PATH = '/usr/share/one/oneform/drivers' -else - LIB_LOCATION = ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION = ONE_LOCATION + '/share/gems' - DRIVERS_PATH = ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << DRIVERS_PATH + '/scaleway/elastic' - -require 'net/http' -require 'uri' -require 'json' -require 'scaleway' -require 'base64' -require 'nokogiri' -require 'opennebula' -require 'opennebula/oneform_client' -require 'ipaddr' -require 'digest' - -IP_TYPE = ['ipv4', 'ipv6'] -DEFAULT_PRIVATE_CIDR = '172.16.0.0/12' - -# IP Address class -class IPAddr - - # Add ^ operator to the IPAddr class - def ^(other) - clone.set(@addr ^ other.to_i) - end - - # Add prefix method, to work with older ipadddr & ruby - def prefix - case @family - when Socket::AF_INET - n = IN4MASK ^ @mask_addr - i = 32 - when Socket::AF_INET6 - n = IN6MASK ^ @mask_addr - i = 128 - else - raise AddressFamilyError, 'unsupported address family' - end - while n>0 - n >>= 1 - i -= 1 - end - i - end - -end - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{document[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - - sw_secret_key = connect[:secret_key] - sw_project_id = connect[:project_id] - sw_zone = connect[:zone] - - # -------------------------------------------------------------------------- - # Connect to Scaleway and allocate a new Flexible IP - # -------------------------------------------------------------------------- - - private_cidr = data.xpath('//AR/PRIVATE_CIDR').text - - if private_cidr.empty? - private_cidr = DEFAULT_PRIVATE_CIDR - end - - cidr = IPAddr.new(private_cidr) - mask = 0x0FFFFFFFF >> cidr.prefix - - sw_ip_type = data.xpath('//AR/SCALEWAY_IP_TYPE').text - - if sw_ip_type.empty? - sw_ip_type = IP_TYPE[0] - elsif !IP_TYPE.include?(sw_ip_type) - STDERR.puts "Type #{sw_ip_type} not supported. " \ - "Must be: #{IP_TYPE.join(', ')}" - exit(-1) - end - - # Request a new fip - tags = (provision[:tags] || {}).map {|k, v| "#{k}=#{v}" } - tags << "PROVISION_ID=#{provision[:provider_id]}" \ - unless tags.any? {|t| t.start_with?('PROVISION_ID=') } - - fip_req = { - :project_id => sw_project_id, - :is_ipv6 => sw_ip_type == 'ipv6', - :server_id => nil, - :tags => tags - } - - sw = Scaleway.new(sw_secret_key) - resp = sw.api_call( - "/flexible-ip/v1alpha1/zones/#{sw_zone}/fips", - Net::HTTP::Post, - fip_req - ) - - unless resp.code == '200' - STDERR.puts "Scaleway API failure, HTTP #{resp.code}, #{resp.message}, #{resp.body}" - exit(-1) - end - - addr, id = JSON.parse(resp.body).fetch_values('ip_address', 'id') - - ipmd5 = Digest::MD5.hexdigest(addr).to_i(16) & mask - eip = IPAddr.new(ipmd5, Socket::AF_INET) - - ipvm = (eip & mask) | cidr - ipgw = ipvm ^ 1 - - puts <<-EOF - AR = [ - TYPE = "IP4", - IP = "#{ipvm}", - SIZE = "1", - IPAM_MAD = "scaleway", - GATEWAY = "#{ipgw}", - EXTERNAL_IP = "#{addr}", - NETWORK_MASK = "255.255.255.254", - SCALEWAY_IP_ID = "#{id}", - PROVISION_ID = "#{provision_id}" - ] - EOF -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/scaleway/ipam/unregister_address_range b/share/providers/scaleway/ipam/unregister_address_range deleted file mode 100755 index cd976a0160..0000000000 --- a/share/providers/scaleway/ipam/unregister_address_range +++ /dev/null @@ -1,119 +0,0 @@ -#!/usr/bin/env ruby - -# -------------------------------------------------------------------------- # -# Copyright 2002-2025, 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. # -#--------------------------------------------------------------------------- # - -############################################################################### -# This script is used to unregister a new IP network in the IPAM. -# -# STDIN Input: -# - Base64 encoded XML with AR request -# -################################################################################ -ONE_LOCATION = ENV['ONE_LOCATION'] unless defined?(ONE_LOCATION) - -if !ONE_LOCATION - LIB_LOCATION ||= '/usr/lib/one' - RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' - GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' -else - LIB_LOCATION ||= ONE_LOCATION + '/lib' - RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' - GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' -end - -# %%RUBYGEMS_SETUP_BEGIN%% -require 'load_opennebula_paths' -# %%RUBYGEMS_SETUP_END%% - -$LOAD_PATH << RUBY_LIB_LOCATION -$LOAD_PATH << LIB_LOCATION + '/scaleway/elastic' - -require 'net/http' -require 'uri' -require 'json' -require 'scaleway' -require 'base64' -require 'nokogiri' -require 'opennebula' -require 'opennebula/oneform_client' -require 'ipaddr' -require 'digest' - -begin - data = Nokogiri::XML(Base64.decode64(STDIN.read)) - - # -------------------------------------------------------------------------- - # Get connection details for the provider - # -------------------------------------------------------------------------- - provision_id = data.xpath('//AR/PROVISION_ID').text - - if provision_id.empty? - STDERR.puts 'Missing provision id in address range' - exit(-1) - end - - client = OneForm::Client.new - document = client.get_provision(provision_id) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provision_id}: #{provision[:message]}" - exit(-1) - end - - provision = document[:TEMPLATE][:PROVISION_BODY] - document = client.get_provider(provision[:provider_id]) - - if document.key?(:err_code) - STDERR.puts "Error retrieving provider #{provision[:provider_id]}: #{document[:message]}" - exit(-1) - end - - provider = document[:TEMPLATE][:PROVIDER_BODY] - connect = provider[:connection] - - sw_secret_key = connect[:secret_key] - sw_zone = connect[:zone] - - # -------------------------------------------------------------------------- - # Connect to Scaleway and delete the Flexible IP - # -------------------------------------------------------------------------- - - scaleway_id = data.xpath('//AR/SCALEWAY_IP_ID').text.to_s - - if scaleway_id.empty? - STDERR.puts 'Missing Scaleway range ID' - exit(-1) - end - - sw = Scaleway.new(sw_secret_key) - resp = sw.api_call( - "/flexible-ip/v1alpha1/zones/#{sw_zone}/fips/#{scaleway_id}", - Net::HTTP::Delete - ) - - unless ['204', '403'].include?(resp.code) - STDERR.puts "Scaleway API failure, HTTP #{resp.code}, #{resp.message}, #{resp.body}" - exit(-1) - end - - exit(0) -rescue StandardError => e - STDERR.puts e.to_s - exit(-1) -end diff --git a/share/providers/scaleway/terraform/cluster/main.tf b/share/providers/scaleway/terraform/cluster/main.tf deleted file mode 100644 index f26cc02558..0000000000 --- a/share/providers/scaleway/terraform/cluster/main.tf +++ /dev/null @@ -1,31 +0,0 @@ -resource "scaleway_vpc" "scaleway_vpc_device" { - name = "provision_vpc_${var.provision_id}" - enable_routing = true - tags = [for key, value in var.scaleway_tags : "${key}=${value}"] -} - -resource "scaleway_vpc_private_network" "scaleway_vpc_private_network_device" { - name = "provision_private_network_${var.provision_id}" - vpc_id = scaleway_vpc.scaleway_vpc_device.id - ipv4_subnet { - subnet = var.cidr_block - } - tags = [for key, value in var.scaleway_tags : "${key}=${value}"] -} - -resource "scaleway_vpc_public_gateway" "scaleway_vpc_public_gateway_device" { - name = "provision_internet_gateway_${var.provision_id}" - type = "VPC-GW-S" - bastion_enabled = true - bastion_port = 61000 - tags = [for key, value in var.scaleway_tags : "${key}=${value}"] - -} - -resource "scaleway_vpc_gateway_network" "scaleway_vpc_gateway_network_device" { - gateway_id = scaleway_vpc_public_gateway.scaleway_vpc_public_gateway_device.id - private_network_id = scaleway_vpc_private_network.scaleway_vpc_private_network_device.id - ipam_config { - push_default_route = true - } -} diff --git a/share/providers/scaleway/terraform/cluster/provider.tf b/share/providers/scaleway/terraform/cluster/provider.tf deleted file mode 100644 index 7720fedf54..0000000000 --- a/share/providers/scaleway/terraform/cluster/provider.tf +++ /dev/null @@ -1,8 +0,0 @@ -terraform { - required_providers { - scaleway = { - source = "scaleway/scaleway" - } - } - required_version = ">= 0.13" -} diff --git a/share/providers/scaleway/terraform/cluster/variables.tf b/share/providers/scaleway/terraform/cluster/variables.tf deleted file mode 100644 index 398ca036ed..0000000000 --- a/share/providers/scaleway/terraform/cluster/variables.tf +++ /dev/null @@ -1,13 +0,0 @@ -variable "cidr_block" { - description = "CIDR block for the VPC" - type = string -} - -variable "scaleway_tags" { - description = "Tags for Scaleway resources" - type = map(string) -} - -variable "provision_id" { - description = "Provision ID for the host" -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/host/data.tf b/share/providers/scaleway/terraform/host/data.tf deleted file mode 100644 index ee8f162392..0000000000 --- a/share/providers/scaleway/terraform/host/data.tf +++ /dev/null @@ -1,13 +0,0 @@ -data "scaleway_baremetal_os" "ubuntu_2204" { - name = "Ubuntu" - version = "22.04 LTS (Jammy Jellyfish)" -} - -data "scaleway_baremetal_os" "ubuntu_2404" { - name = "Ubuntu" - version = "24.04 LTS (Noble Numbat)" -} - -data "scaleway_baremetal_offer" "em_a116x_ssd" { - name = "EM-A116X-SSD" -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/host/locals.tf b/share/providers/scaleway/terraform/host/locals.tf deleted file mode 100644 index 34fd63830d..0000000000 --- a/share/providers/scaleway/terraform/host/locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -locals { - registred_instance_os_name = { - "ubuntu_2204" = data.scaleway_baremetal_os.ubuntu_2204 - "ubuntu_2404" = data.scaleway_baremetal_os.ubuntu_2404 - } - - instance_offer = { - "em_a116x_ssd" = data.scaleway_baremetal_offer.em_a116x_ssd - } -} diff --git a/share/providers/scaleway/terraform/host/main.tf b/share/providers/scaleway/terraform/host/main.tf deleted file mode 100644 index 7718f8e610..0000000000 --- a/share/providers/scaleway/terraform/host/main.tf +++ /dev/null @@ -1,26 +0,0 @@ -resource "scaleway_iam_ssh_key" "oneadmin_pubkey" { - name = "provision_key_${var.provision_id}" - public_key = file(pathexpand("~/.ssh/id_rsa.pub")) -} - -data "scaleway_baremetal_os" "scw_baremetal_os" { - name = lookup(local.registred_instance_os_name, var.instance_os_name).name - version = lookup(local.registred_instance_os_name, var.instance_os_name).version -} - -data "scaleway_baremetal_offer" "scw_offer" { - name = lookup(local.instance_offer, var.instance_offer).name -} - -resource "scaleway_baremetal_server" "host" { - count = var.oneform_hosts - name = "provision_${var.provision_id}_host_${count.index}" - offer = data.scaleway_baremetal_offer.scw_offer.offer_id - os = data.scaleway_baremetal_os.scw_baremetal_os.os_id - - ssh_key_ids = [ - scaleway_iam_ssh_key.oneadmin_pubkey.id - ] - - tags = [for key, value in var.scaleway_tags : "${key}=${value}"] -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/host/outputs.tf b/share/providers/scaleway/terraform/host/outputs.tf deleted file mode 100644 index aea9f05195..0000000000 --- a/share/providers/scaleway/terraform/host/outputs.tf +++ /dev/null @@ -1,7 +0,0 @@ -output "id" { - value = [for instance in scaleway_baremetal_server.host : instance.id] -} - -output "public_ip" { - value = [for instance in scaleway_baremetal_server.host : instance.ipv4[0].address] -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/host/provider.tf b/share/providers/scaleway/terraform/host/provider.tf deleted file mode 100644 index 7720fedf54..0000000000 --- a/share/providers/scaleway/terraform/host/provider.tf +++ /dev/null @@ -1,8 +0,0 @@ -terraform { - required_providers { - scaleway = { - source = "scaleway/scaleway" - } - } - required_version = ">= 0.13" -} diff --git a/share/providers/scaleway/terraform/host/variables.tf b/share/providers/scaleway/terraform/host/variables.tf deleted file mode 100644 index 47f4244910..0000000000 --- a/share/providers/scaleway/terraform/host/variables.tf +++ /dev/null @@ -1,23 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string -} - -variable "instance_offer" { - description = "Scaleway offer to use for the instance" - type = string -} - -variable "scaleway_tags" { - description = "Tags for Scaleway resources" - type = map(string) -} - -variable "provision_id" { - description = "Provision ID for the host" -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/locals.tf b/share/providers/scaleway/terraform/locals.tf deleted file mode 100644 index ce7eb41c94..0000000000 --- a/share/providers/scaleway/terraform/locals.tf +++ /dev/null @@ -1,10 +0,0 @@ -resource "random_id" "key_suffix" { - byte_length = 6 -} - -locals { - provision_id = ( - contains(keys(var.oneform_tags), "provision_id") ? - var.oneform_tags["provision_id"] : random_id.key_suffix.id - ) -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/main.tf b/share/providers/scaleway/terraform/main.tf deleted file mode 100644 index cdbc3d5551..0000000000 --- a/share/providers/scaleway/terraform/main.tf +++ /dev/null @@ -1,16 +0,0 @@ -module "cluster" { - source = "./cluster" - provision_id = local.provision_id - cidr_block = var.cidr_block - scaleway_tags = var.oneform_tags -} - -module "host" { - source = "./host" - provision_id = local.provision_id - - oneform_hosts = var.oneform_hosts - instance_os_name = var.instance_os_name - instance_offer = var.instance_type - scaleway_tags = var.oneform_tags -} diff --git a/share/providers/scaleway/terraform/outputs.tf b/share/providers/scaleway/terraform/outputs.tf deleted file mode 100644 index ffad494deb..0000000000 --- a/share/providers/scaleway/terraform/outputs.tf +++ /dev/null @@ -1,8 +0,0 @@ -output "provisioned_hosts" { - value = [ - for idx in range(length(module.host.id)) : { - instance_id = module.host.id[idx] - instance_ip = module.host.public_ip[idx] - } - ] -} diff --git a/share/providers/scaleway/terraform/provider.tf b/share/providers/scaleway/terraform/provider.tf deleted file mode 100644 index e7c022576f..0000000000 --- a/share/providers/scaleway/terraform/provider.tf +++ /dev/null @@ -1,46 +0,0 @@ -terraform { - required_providers { - scaleway = { - source = "scaleway/scaleway" - } - } - required_version = ">= 0.13" -} - -variable "access_key" { - type = string - sensitive = true - description = "Scaleway access key" -} - -variable "secret_key" { - type = string - sensitive = true - description = "Scaleway secret key" -} - -variable "project_id" { - type = string - sensitive = true - description = "Scaleway project ID" -} - -variable "region" { - type = string - description = "Scaleway region" - default = "fr-par" -} - -variable "zone" { - type = string - description = "Scaleway zone" - default = "fr-par-1" -} - -provider "scaleway" { - access_key = var.access_key - secret_key = var.secret_key - project_id = var.project_id - zone = var.zone - region = var.region -} \ No newline at end of file diff --git a/share/providers/scaleway/terraform/validators.tf b/share/providers/scaleway/terraform/validators.tf deleted file mode 100644 index 0ab9f93a8d..0000000000 --- a/share/providers/scaleway/terraform/validators.tf +++ /dev/null @@ -1,37 +0,0 @@ -locals { - # Scaleway provider validators - validators = { - instance_type = { - type = "list" - values = ["em_a116x_ssd"] - } - - oneform_hosts = { - type = "number" - values = { - min = 1 - max = 10 - } - } - - instance_os_name = { - type = "list" - values = ["ubuntu_2204", "ubuntu_2404"] - } - - region = { - type = "list" - values = ["fr-par", "nl-ams", "pl-waw"] - } - - zone = { - type = "map" - grouped_by = "region" - values = { - fr-par = ["fr-par-1", "fr-par-2", "fr-par-3"] - nl-ams = ["nl-ams-1", "nl-ams-2", "nl-ams-3"] - pl-waw = ["pl-waw-1", "pl-waw-2", "pl-waw-3"] - } - } - } -} diff --git a/share/providers/scaleway/terraform/variables.tf b/share/providers/scaleway/terraform/variables.tf deleted file mode 100644 index ca25e60da2..0000000000 --- a/share/providers/scaleway/terraform/variables.tf +++ /dev/null @@ -1,29 +0,0 @@ -variable "oneform_hosts" { - description = "Number of instances to create" - type = number - default = 1 -} - -variable "instance_type" { - description = "Size of the instance to create" - type = string - default = "em_a116x_ssd" -} - -variable "instance_os_name" { - description = "Operating system to use for the instance" - type = string - default = "ubuntu_2204" -} - -variable "cidr_block" { - description = "CIDR block for the VPC" - type = string - default = "172.18.0.0/24" -} - -variable "oneform_tags" { - description = "value of the tags to assign to the instance" - type = map(string) - default = {} -} \ No newline at end of file diff --git a/share/shell/bash_completion b/share/shell/bash_completion index def1e20dfd..bf1c8e92c5 100755 --- a/share/shell/bash_completion +++ b/share/shell/bash_completion @@ -107,6 +107,10 @@ _oneflow_server() { _one_simple "start stop" } +_oneform_server() { + _one_simple "start stop" +} + _onehem_server() { _one_simple "start stop" } @@ -121,6 +125,7 @@ _sunstone_server() { complete -F _one one complete -F _oneflow_server oneflow-server +complete -F _oneform_server oneform-server complete -F _onehem_server onehem-server complete -F _onegate_server onegate-server complete -F _sunstone_server sunstone-server @@ -528,23 +533,52 @@ _onemarketapp() { fi } -_oneprovision() { +_oneform() +{ local cur prev opts cmd COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="create validate list show configure delete" - cmd=oneprovision + + cmd=oneform + opts="list top show sync enable disable" + if [ "$COMP_CWORD" == 1 ]; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 elif [ "$COMP_CWORD" == 2 ]; then case "$prev" in - show|configure|delete) + show|enable|disable|create) + local drivers + drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')" + COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") ) + return 0 + ;; + esac +fi +} + +_oneprovision() { + local cur prev opts cmd + COMPREPLY=() + cur="${COMP_WORDS[COMP_CWORD]}" + prev="${COMP_WORDS[COMP_CWORD-1]}" + + cmd=oneprovision + opts="list top show create update rename chgrp chown chmod retry add-host del-host add-ip del-ip deprovision delete logs" + + if [ "$COMP_CWORD" == 1 ]; then + COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) + return 0 + elif [ "$COMP_CWORD" == 2 ]; then + case "$prev" in + show|update|rename|chgrp|chown|chmod|delete|retry) _complete $cmd ID ;; - create|validate) - COMPREPLY=( $(compgen -A file -- "${cur}") ) + create) + local drivers + drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')" + COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") ) return 0 ;; esac @@ -556,18 +590,22 @@ _oneprovider() { COMPREPLY=() cur="${COMP_WORDS[COMP_CWORD]}" prev="${COMP_WORDS[COMP_CWORD-1]}" - opts="create list show delete update" + cmd=oneprovider + opts="list top show create update rename chgrp chown chmod delete" + if [ "$COMP_CWORD" == 1 ]; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 elif [ "$COMP_CWORD" == 2 ]; then case "$prev" in - show|delete|update) + show|update|rename|chgrp|chown|chmod|delete|retry) _complete $cmd ID ;; create) - COMPREPLY=( $(compgen -A file -- "${cur}") ) + local drivers + drivers="$(oneform list --csv --no-header -l name 2>/dev/null | tr -d '\r')" + COMPREPLY=( $(compgen -W "${drivers}" -- "${cur}") ) return 0 ;; esac @@ -902,6 +940,7 @@ complete -F _onehost onehost complete -F _oneimage oneimage complete -F _onemarket onemarket complete -F _onemarketapp onemarketapp +complete -F _oneform oneform complete -F _oneprovision oneprovision complete -F _oneprovider oneprovider complete -F _onesecgroup onesecgroup diff --git a/src/cli/cli_helper.rb b/src/cli/cli_helper.rb index c73d5d7330..85eff6aa8e 100644 --- a/src/cli/cli_helper.rb +++ b/src/cli/cli_helper.rb @@ -265,6 +265,158 @@ module CLIHelper exit(-1) end + # Render a small HTML subset for terminal output + # Supports: p, br, ul/ol/li, strong/b, em/i, code, a[href] + def self.render_html(text) + return '' if text.nil? || text.empty? + + use_ansi = $stdout.tty? + + bold_on = use_ansi ? "\33[1m" : '' + faint_on = use_ansi ? "\33[2m" : '' + reset = use_ansi ? "\33[0m" : '' + mono_on = use_ansi ? "\33[36m" : '' + bullet = use_ansi ? '•' : '*' + + # OSC 8 hyperlink escape (clickable links) + osc8_link = lambda do |label, url| + return "#{label} (#{url})" unless use_ansi + + "\e]8;;#{url}\a#{label}\e]8;;\a" + end + + s = text.to_s.gsub("\r\n", "\n") + + # Block tags -> newlines + s = s.gsub(%r{<\s*br\s*/?\s*>}i, "\n") + s = s.gsub(%r{<\s*/\s*p\s*>}i, "\n") + s = s.gsub(/<\s*p\b[^>]*>/i, '') + s = s.gsub(%r{<\s*/\s*(div|section|article)\s*>}i, "\n\n") + s = s.gsub(/<\s*(div|section|article)\b[^>]*>/i, '') + + # Links: label + s = s.gsub(%r{<\s*a\b[^>]*href\s*=\s*["']([^"']+)["'][^>]*>(.*?)<\s*/\s*a\s*>}im) do + url = Regexp.last_match(1).strip + label = Regexp.last_match(2).to_s + osc8_link.call(label, url) + end + + # Lists + s = s.gsub(/<\s*li\b[^>]*>/i, "#{bullet} ") + + # Inline formatting + if use_ansi + s = s.gsub(%r{<\s*/\s*(strong|b)\s*>}i, reset) + s = s.gsub(/<\s*(strong|b)\b[^>]*>/i, bold_on) + + s = s.gsub(%r{<\s*/\s*(em|i)\s*>}i, reset) + s = s.gsub(/<\s*(em|i)\b[^>]*>/i, faint_on) + + # + s = s.gsub(%r{<\s*code\b[^>]*>(.*?)<\s*/\s*code\s*>}im) do + "#{faint_on}#{mono_on}#{Regexp.last_match(1)}#{reset}" + end + else + s = s.gsub(%r{<\s*/?\s*(strong|b|em|i|code)\b[^>]*>}i, '') + end + + # Remove any remaining tags + s = s.gsub(/<[^>]+>/, '') + + # Decode minimal HTML entities + s = s.gsub('&', '&') + .gsub('<', '<') + .gsub('>', '>') + .gsub('"', '"') + .gsub(''', "'") + .gsub(' ', ' ') + + # Normalize whitespace + s = s.lines.map(&:rstrip).join("\n") + s.gsub(/\n{3,}/, "\n\n").strip + end + + # Render a small Markdown subset for terminal output. Supports headings, + # bold, italic, inline code, and unordered lists. + def self.render_md(text) + return '' if text.nil? || text.empty? + + use_ansi = $stdout.tty? + + bold_on = use_ansi ? "\33[1m" : '' + reset = use_ansi ? "\33[0m" : '' + faint_on = use_ansi ? "\33[2m" : '' + mono_on = use_ansi ? "\33[36m" : '' + bullet = use_ansi ? '•' : '*' + + # OSC 8 hyperlink sequences + osc8_link = lambda do |label, url| + return "#{label} (#{url})" unless use_ansi + + "\e]8;;#{url}\a#{label}\e]8;;\a" + end + + lines = text.to_s.gsub("\r\n", "\n").split("\n", -1) + + out = lines.map do |line| + # Preserve empty lines + if line.strip.empty? + '' + # Headings (#, ##, ###) + elsif (m = line.match(/\A\s{0,3}(\#{1,3})\s+(.*)\z/)) + title = m[2].strip + "#{bold_on}#{title}#{reset}" + # Unordered list items (*, -, +) + elsif (m = line.match(/\A(\s*)[*+-]\s+(.*)\z/)) + indent = m[1] + item = m[2] + "#{indent}#{bullet} #{item}" + else + line + end + end.join("\n") + + # Links [label](url) + out = out.gsub(/\[([^\]]+)\]\(([^)]+)\)/) do + label = Regexp.last_match(1) + url = Regexp.last_match(2).strip + osc8_link.call(label, url) + end + + # Autolinks + out = out.gsub(/<((?:https?|mailto):[^>\s]+)>/) do + url = Regexp.last_match(1) + osc8_link.call(url, url) + end + + # Inline formatting (simple, non-nested) + if use_ansi + # Inline code: `code` + out = out.gsub(/`([^`]+)`/) do + m = Regexp.last_match(1) + "#{faint_on}#{mono_on}#{m}#{reset}" + end + + # Bold: **text** + out = out.gsub(/\*\*([^\*]+)\*\*/) do + m = Regexp.last_match(1) + "#{bold_on}#{m}#{reset}" + end + + # Italic: *text* + out = out.gsub(/(^|[^*])\*([^*\n]+)\*(?!\*)/) do + m1 = Regexp.last_match(1) + m2 = Regexp.last_match(2) + "#{m1}#{faint_on}#{m2}#{reset}" + end + else + # Non-tty, keep markdown mostly as-is, but normalize list bullets + out = out.gsub(/\A(\s*)[*+-]\s+/m, "\\1#{bullet} ") + end + + out + end + # Check if value is in base64 # # @param value [String] Value to check diff --git a/src/cli/one_helper/oneform_helper.rb b/src/cli/one_helper/oneform_helper.rb index b5161211ca..ae308f00e7 100644 --- a/src/cli/one_helper/oneform_helper.rb +++ b/src/cli/one_helper/oneform_helper.rb @@ -42,7 +42,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper CLIHelper::ShowTable.new(config_file, self) do column :NAME, 'NAME', :left, :size => 15 do |d| - File.basename(d[:source]) + File.basename(d[:system_path]) end column :DEPLOYMENTS, 'DEPLOYMENTS', :left, :expand => true do |d| @@ -65,8 +65,8 @@ class OneFormHelper < OpenNebulaHelper::OneHelper # # @param client [OneForm::Client] Petition client # @param options [Hash] CLI options - def list_driver_pool(client, options) - response = client.list_drivers + def list_driver_pool(client, options, params = {}) + response = client.list_drivers(params) if CloudClient.is_error?(response) [response[:err_code], response[:message]] @@ -90,7 +90,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper # # @param client [OneForm::Client] Petition client # @param options [Hash] CLI options - def top_driver_pool(client, options) + def top_driver_pool(client, options, params = {}) options[:delay] ? delay = options[:delay] : delay = 4 begin @@ -98,7 +98,7 @@ class OneFormHelper < OpenNebulaHelper::OneHelper CLIHelper.scr_cls CLIHelper.scr_move(0, 0) - list_driver_pool(client, options) + list_driver_pool(client, options, params) sleep delay end @@ -129,15 +129,14 @@ class OneFormHelper < OpenNebulaHelper::OneHelper str = '%-20s: %-20s' str_h1 = '%-80s' - CLIHelper.print_header( - str_h1 % "#{File.basename(response[:source]).upcase} ONEFORM DRIVER INFORMATION" - ) + driver_name = File.basename(response[:system_path]) + CLIHelper.print_header(str_h1 % "#{driver_name.upcase} ONEFORM DRIVER INFORMATION") puts Kernel.format str, 'NAME', response[:name] puts Kernel.format str, 'DESCRIPTION', response[:description] - puts Kernel.format str, 'SYSTEM PATH', response[:source] - puts Kernel.format str, 'VERSION', response[:version] puts Kernel.format str, 'STATE', response[:state] + puts Kernel.format str, 'SOURCE', response[:registry] + puts Kernel.format str, 'VERSION', response[:version] puts @@ -191,21 +190,20 @@ class OneFormHelper < OpenNebulaHelper::OneHelper puts - CLIHelper.print_header(str_h1 % 'DEPLOYMENT CONFIGURATIONS', false) + CLIHelper.print_header(str_h1 % 'DEPLOYMENT CONFIGURATIONS', true) + puts configs = response[:deployment_confs] || [] configs.each do |conf| - CLIHelper.print_header(str_h1 % conf[:name], false) - - puts Kernel.format str, 'DESCRIPTION', conf[:description] || '--' - puts Kernel.format str, 'INVENTORY_FILE', conf[:inventory] || '--' + CLIHelper.print_header(str_h1 % conf[:name].upcase, false) + puts conf[:description].nil? ? '--' : CLIHelper.render_html(conf[:description]) puts next unless conf[:user_inputs] && !conf[:user_inputs].empty? - CLIHelper.print_header("#{conf[:inventory].upcase} INPUTS", false) + CLIHelper.print_header("#{conf[:inventory].upcase} CONFIGURATION INPUTS", false) CLIHelper::ShowTable.new(nil, self) do column :NAME, '', :left, :size => 25, :adjust => true do |input| input[:name] || '--' @@ -233,13 +231,14 @@ class OneFormHelper < OpenNebulaHelper::OneHelper [ :name, :description, - :source, + :version, + :registry, :state, :fireedge, :connection, :user_inputs, :deployment_confs, - :version + :system_path ].include?(k) end diff --git a/src/cli/one_helper/oneprovider_helper.rb b/src/cli/one_helper/oneprovider_helper.rb index 9bded83343..d3f982d6f2 100644 --- a/src/cli/one_helper/oneprovider_helper.rb +++ b/src/cli/one_helper/oneprovider_helper.rb @@ -79,8 +79,8 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper # # @param client [Service::Client] Petition client # @param options [Hash] CLI options - def list_provider_pool(client, options) - response = client.list_providers + def list_provider_pool(client, options, params = {}) + response = client.list_providers(params) if CloudClient.is_error?(response) [response[:err_code], response[:message]] @@ -104,7 +104,7 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper # # @param client [Service::Client] Petition client # @param options [Hash] CLI options - def top_provider_pool(client, options) + def top_provider_pool(client, options, params = {}) options[:delay] ? delay = options[:delay] : delay = 4 begin @@ -112,7 +112,7 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper CLIHelper.scr_cls CLIHelper.scr_move(0, 0) - list_provider_pool(client, options) + list_provider_pool(client, options, params) sleep delay end @@ -129,8 +129,8 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper # @param client [Service::Client] Petition client # @param service_template [Integer] Provider ID # @param options [Hash] CLI options - def format_resource(client, provider_id, options) - response = client.get_provider(provider_id) + def format_resource(client, provider_id, options, params = {}) + response = client.get_provider(provider_id, params) if CloudClient.is_error?(response) [response[:err_code], response[:message]] @@ -195,6 +195,7 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper :name, :description, :fireedge, + :user_inputs, :connection, :registration_time, :provision_ids, diff --git a/src/cli/one_helper/oneprovision_helper.rb b/src/cli/one_helper/oneprovision_helper.rb index f4adf71c0f..6b1bdd6a2f 100644 --- a/src/cli/one_helper/oneprovision_helper.rb +++ b/src/cli/one_helper/oneprovision_helper.rb @@ -93,8 +93,8 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper # # @param client [Service::Client] Petition client # @param options [Hash] CLI options - def list_provision_pool(client, options) - response = client.list_provisions(options) + def list_provision_pool(client, options, params = {}) + response = client.list_provisions(params) if CloudClient.is_error?(response) [response[:err_code], response[:message]] @@ -118,7 +118,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper # # @param client [Service::Client] Petition client # @param options [Hash] CLI options - def top_provision_pool(client, options) + def top_provision_pool(client, options, params = {}) options[:delay] ? delay = options[:delay] : delay = 4 begin @@ -126,7 +126,7 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper CLIHelper.scr_cls CLIHelper.scr_move(0, 0) - list_provision_pool(client, options) + list_provision_pool(client, options, params) sleep delay end @@ -143,8 +143,8 @@ class OneProvisionHelper < OpenNebulaHelper::OneHelper # @param client [Service::Client] Petition client # @param service_template [Integer] Provider ID # @param options [Hash] CLI options - def format_resource(client, provision_id, options) - response = client.get_provision(provision_id) + def format_resource(client, provision_id, options, params = {}) + response = client.get_provision(provision_id, params) if CloudClient.is_error?(response) [response[:err_code], response[:message]] diff --git a/src/cli/oneform b/src/cli/oneform index 012935f3a2..127514ac9a 100755 --- a/src/cli/oneform +++ b/src/cli/oneform @@ -52,6 +52,14 @@ CommandParser::CmdParser.new(ARGV) do set :option, CommandParser::VERSION set :option, CommandParser::HELP + ENABLED = { + :name => 'enabled', + :short => '-e', + :large => '--enabled', + :description => 'Show only enabled providers', + :default => false + } + helper = OneFormHelper.new ######################################################################## @@ -64,8 +72,9 @@ CommandParser::CmdParser.new(ARGV) do command :list, list_desc, - :options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE] do - helper.list_driver_pool(helper.client(options), options) + :options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE, ENABLED] do + enabled = options[:enabled] || false + helper.list_driver_pool(helper.client(options), options, :enabled => enabled) end top_desc = <<-EOT.unindent @@ -74,9 +83,10 @@ CommandParser::CmdParser.new(ARGV) do command :top, top_desc, - :options => FORMAT + [CLIHelper::DELAY] do + :options => FORMAT + [CLIHelper::DELAY, ENABLED] do Signal.trap('INT') { exit(-1) } - helper.top_driver_pool(helper.client(options), options) + enabled = options[:enabled] || false + helper.top_driver_pool(helper.client(options), options, :enabled => enabled) 0 end diff --git a/src/cli/oneprovider b/src/cli/oneprovider index 8be834bd88..7cbc85ae87 100755 --- a/src/cli/oneprovider +++ b/src/cli/oneprovider @@ -52,6 +52,22 @@ CommandParser::CmdParser.new(ARGV) do set :option, CommandParser::VERSION set :option, CommandParser::HELP + SENSITIVE = { + :name => 'sensitive', + :short => '-s', + :large => '--sensitive', + :description => 'Include sensitive values information in the output', + :default => false + } + + ENABLED = { + :name => 'enabled', + :short => '-e', + :large => '--enabled', + :description => 'Show only enabled providers', + :default => false + } + helper = OneProviderHelper.new ############################################################################ @@ -83,8 +99,19 @@ CommandParser::CmdParser.new(ARGV) do command :list, list_desc, - :options => FORMAT + CLIHelper::OPTIONS + [OpenNebulaHelper::DESCRIBE] do - helper.list_provider_pool(helper.client(options), options) + :options => ( + FORMAT + CLIHelper::OPTIONS + + [OpenNebulaHelper::DESCRIBE, SENSITIVE, ENABLED] + ) do + sensitive = options[:sensitive] || false + enabled = options[:enabled] || false + + helper.list_provider_pool( + helper.client(options), + options, + :include_sensitive => sensitive, + :enabled => enabled + ) end top_desc = <<-EOT.unindent @@ -93,9 +120,17 @@ CommandParser::CmdParser.new(ARGV) do command :top, top_desc, - :options => FORMAT + [CLIHelper::DELAY] do + :options => FORMAT + [CLIHelper::DELAY, SENSITIVE, ENABLED] do Signal.trap('INT') { exit(-1) } - helper.top_provider_pool(helper.client(options), options) + sensitive = options[:sensitive] || false + enabled = options[:enabled] || false + + helper.top_provider_pool( + helper.client(options), + options, + :include_sensitive => sensitive, + :enabled => enabled + ) 0 end @@ -104,15 +139,21 @@ CommandParser::CmdParser.new(ARGV) do Show details of a specific provider template. EOT - command :show, show_desc, :provider_id, :options => FORMAT do + command :show, show_desc, :provider_id, :options => FORMAT + [SENSITIVE] do provider_id = args[0].to_i + sensitive = options[:sensitive] || false if args[0].to_s !~ /^\d+$/ STDERR.puts 'Invalid provider ID' exit(-1) end - helper.format_resource(helper.client(options), provider_id, options) + helper.format_resource( + helper.client(options), + provider_id, + options, + :include_sensitive => sensitive + ) end create_desc = <<-EOT.unindent diff --git a/src/cli/oneprovision b/src/cli/oneprovision index 76dc5aaa9b..3778f2d4bc 100755 --- a/src/cli/oneprovision +++ b/src/cli/oneprovision @@ -126,6 +126,14 @@ CommandParser::CmdParser.new(ARGV) do :format => String } + SENSITIVE = { + :name => 'sensitive', + :short => '-s', + :large => '--sensitive', + :description => 'Include sensitive values information in the output', + :default => false + } + helper = OneProvisionHelper.new ############################################################################ @@ -157,8 +165,17 @@ CommandParser::CmdParser.new(ARGV) do command :list, list_desc, - :options => FORMAT + CLIHelper::OPTIONS + [ALL, OpenNebulaHelper::DESCRIBE] do - helper.list_provision_pool(helper.client(options), options) + :options => ( + FORMAT + CLIHelper::OPTIONS + + [ALL, OpenNebulaHelper::DESCRIBE, SENSITIVE] + )do + sensitive = options[:sensitive] || false + + helper.list_provision_pool( + helper.client(options), + options, + :include_sensitive => sensitive + ) end top_desc = <<-EOT.unindent @@ -167,9 +184,15 @@ CommandParser::CmdParser.new(ARGV) do command :top, top_desc, - :options => FORMAT + [CLIHelper::DELAY] do + :options => FORMAT + [CLIHelper::DELAY, SENSITIVE] do Signal.trap('INT') { exit(-1) } - helper.top_provision_pool(helper.client(options), options) + sensitive = options[:sensitive] || false + + helper.top_provision_pool( + helper.client(options), + options, + :include_sensitive => sensitive + ) 0 end @@ -178,10 +201,16 @@ CommandParser::CmdParser.new(ARGV) do Show details of a specific provision. EOT - command :show, show_desc, :provision_id, :options => FORMAT do + command :show, show_desc, :provision_id, :options => FORMAT + [SENSITIVE] do provision_id = args[0].to_i + sensitive = options[:sensitive] || false - helper.format_resource(helper.client(options), provision_id, options) + helper.format_resource( + helper.client(options), + provision_id, + options, + :include_sensitive => sensitive + ) end create_desc = <<-EOT.unindent diff --git a/src/form/app/controllers/driver_controller.rb b/src/form/app/controllers/driver_controller.rb index 840aa7f399..574af21205 100644 --- a/src/form/app/controllers/driver_controller.rb +++ b/src/form/app/controllers/driver_controller.rb @@ -42,6 +42,10 @@ module OneFormServer # GET /drivers # Lists all available drivers and their metadata. # + # Query Params: + # enabled [true|false] - Optional. Defaults to false. + # If true, returns only enabled providers. + # # Returns: # 200 OK - Driver object (JSON) # 500 Internal Server Error - On unexpected failure or OpenNebula error @@ -53,6 +57,11 @@ module OneFormServer rc.message, one_error_to_http(rc.errno) ) if OpenNebula.is_error?(rc) + only_enabled = params['enabled'].to_s.downcase == 'true' + rc = rc.select do |driver| + !only_enabled || driver.enabled? + end + status 200 body process_response(rc) rescue StandardError => e diff --git a/src/form/app/controllers/provider_controller.rb b/src/form/app/controllers/provider_controller.rb index 3395678f7c..c31411f0b7 100644 --- a/src/form/app/controllers/provider_controller.rb +++ b/src/form/app/controllers/provider_controller.rb @@ -23,20 +23,26 @@ module OneFormServer # GET /providers # Retrieves all providers. # - # Params: - # None + # Query Params: + # include_sensitive [true|false] - Optional. Defaults to false. + # If true, includes sensitive user_inputs_values in the response. + # enabled [true|false] - Optional. Defaults to false. + # If true, returns only enabled providers. # # Returns: # 200 OK - Array of providers (JSON) # 500 Internal Server Error - If OpenNebula or retrieval error app.get '/providers' do - pool = OneForm::ProviderDocumentPool.new(@client) - rc = pool.info + pool = OneForm::ProviderDocumentPool.new(@client) + rc = pool.info if OpenNebula.is_error?(rc) return internal_error(rc.message, one_error_to_http(rc.errno)) end + only_enabled = params['enabled'].to_s.downcase == 'true' + include_sensitive = params['include_sensitive'].to_s.downcase == 'true' + providers = [] pool.ids.each do |id| @@ -46,11 +52,16 @@ module OneFormServer provider.message, one_error_to_http(provider.errno) ) if OpenNebula.is_error?(provider) + # Skip disabled providers if enabled filter is set + next if only_enabled && !provider.enabled? + providers << provider end + opts = { :include_sensitive => include_sensitive } + status 200 - body process_response(providers) + body process_response(providers, opts) end # GET /providers/:id @@ -59,6 +70,10 @@ module OneFormServer # Params: # :id [String] - ID of the provider # + # Query Params: + # include_sensitive [true|false] - Optional. Defaults to false. + # If true, includes sensitive user_inputs_values in the response. + # # Returns: # 200 OK - Provider object (JSON) # 404 Not Found - If provider does not exist @@ -66,6 +81,9 @@ module OneFormServer app.get '/providers/:id' do id = params[:id] + include_sensitive = params['include_sensitive'].to_s.downcase == 'true' + opts = { :include_sensitive => include_sensitive } + provider = OneForm::Provider.new_from_id(@client, id) return internal_error( @@ -73,7 +91,7 @@ module OneFormServer ) if OpenNebula.is_error?(provider) status 200 - body process_response(provider) + body process_response(provider, opts) end # GET /providers/:id/path @@ -95,7 +113,7 @@ module OneFormServer provider.message, one_error_to_http(provider.errno) ) if OpenNebula.is_error?(provider) - path = File.join(DRIVERS_PATH, provider.driver) + path = provider.driver_path status 200 body process_response({ 'path' => path }) @@ -145,7 +163,7 @@ module OneFormServer return internal_error( 'Provider creation is not allowed from a disabled driver', ResponseHelper::VALIDATION_EC - ) unless driver.enable? + ) unless driver.enabled? # Merge request body to driver content driver.merge(body) diff --git a/src/form/app/controllers/provision_controller.rb b/src/form/app/controllers/provision_controller.rb index 71b150390d..fd669f2667 100644 --- a/src/form/app/controllers/provision_controller.rb +++ b/src/form/app/controllers/provision_controller.rb @@ -39,19 +39,22 @@ module OneFormServer # GET /provisions # Retrieves all provisions. # - # Params: - # all [Boolean] - If true, show all provisions, including those in DONE state - # (default: false) + # Query Params: + # all [true|false] - If true, show all provisions including DONE + # (default: false) + # include_provider [true|false] - If true, include provider info (default: false) + # include_sensitive [true|false] - If true, include sensitive values (default: false) # # Returns: # 200 OK - Array of provisions (JSON) - # 500 Internal Server Error - If OpenNebula or retrieval error + # 500 Internal Server Error app.get '/provisions' do - show_all = params['all'] == 'true' - include_provider = params['include_provider'] == 'true' + show_all = params['all'].to_s.downcase == 'true' + include_provider = params['include_provider'].to_s.downcase == 'true' + include_sensitive = params['include_sensitive'].to_s.downcase == 'true' - pool = OneForm::ProvisionDocumentPool.new(@client) - rc = pool.info + pool = OneForm::ProvisionDocumentPool.new(@client) + rc = pool.info return internal_error( rc.message, one_error_to_http(rc.errno) @@ -66,15 +69,17 @@ module OneFormServer provision.message, one_error_to_http(provision.errno) ) if OpenNebula.is_error?(provision) + # Skip DONE unless show_all next if provision.state == OneForm::Provision::STATE['DONE'] && !show_all provision.include_provider if include_provider - provisions << provision end + opts = { :include_sensitive => include_sensitive } + status 200 - body process_response(provisions) + body process_response(provisions, opts) end # GET /provisions/:id @@ -82,16 +87,20 @@ module OneFormServer # # Params: # :id [String] - ID of the provision - # decode [Boolean] - If true, decode and returns the Terraform state - # (default: false) + # + # Query Params: + # decode [true|false] - Decode Terraform state (default: false) + # include_provider [true|false] - Include provider info (default: false) + # include_sensitive [true|false] - Include sensitive values (default: false) # # Returns: # 200 OK - Provision object (JSON) - # 404 Not Found - If provision does not exist - # 500 Internal Server Error - If OpenNebula error + # 404 Not Found + # 500 Internal Server Error app.get '/provisions/:id' do - decode = params['decode'] == 'true' - include_provider = params['include_provider'] == 'true' + decode = params['decode'].to_s.downcase == 'true' + include_provider = params['include_provider'].to_s.downcase == 'true' + include_sensitive = params['include_sensitive'].to_s.downcase == 'true' provision = OneForm::Provision.new_from_id(@client, params[:id]) @@ -102,8 +111,10 @@ module OneFormServer provision.decode_tfstate if decode provision.include_provider if include_provider + opts = { :include_sensitive => include_sensitive } + status 200 - body process_response(provision) + body process_response(provision, opts) end # GET /provisions/:id/unmanaged @@ -191,7 +202,7 @@ module OneFormServer return internal_error( 'Provision creation is not allowed from a disabled driver', ResponseHelper::VALIDATION_EC - ) unless driver.enable? + ) unless driver.enabled? # Merge request body to driver content driver.merge(body) @@ -210,10 +221,10 @@ module OneFormServer # Check that driver and provider are compatibles return internal_error( - "The specified driver '#{provider.driver}' is not compatible " \ - "with the '#{File.basename(driver.source)}' driver used for this provision.", + "The specified driver '#{provider.driver}' is not compatible with " \ + "the '#{File.basename(driver.system_path)}' driver used for this provision.", ResponseHelper::VALIDATION_EC - ) if provider.driver != File.basename(driver.source) + ) if provider.driver != File.basename(driver.system_path) # Create provision from driver deployment body provision = OneForm::Provision.new(@client) diff --git a/src/form/app/models/driver.rb b/src/form/app/models/driver.rb index 127ecec19f..019100c738 100644 --- a/src/form/app/models/driver.rb +++ b/src/form/app/models/driver.rb @@ -24,9 +24,10 @@ module OneForm DRIVER_ATTRS = [ 'name', 'description', - 'source', 'state', + 'registry', 'version', + 'system_path', 'fireedge', 'connection', 'connection_values', @@ -65,11 +66,15 @@ module OneForm end end + def to_h(_opts = {}) + @body.to_h + end + def to_json(opts = {}) @body.to_json(opts) end - def enable? + def enabled? state == STR_STATES[:enabled] end @@ -124,7 +129,7 @@ module OneForm body = OneForm::Provider::PROVIDER_ATTRS.each_with_object({}) do |attr, hash| value = case attr when 'driver' - File.basename(@body['source']) + File.basename(@body['system_path']) when 'connection' @body['connection_values'] else @@ -168,7 +173,7 @@ module OneForm OneForm::Provision::PROVISION_ATTRS.each_with_object({}) do |attr, hash| value = case attr when 'driver' - File.basename(@body['source']) + File.basename(@body['system_path']) when 'deployment_file' deployment_conf[:inventory] when 'user_inputs' @@ -191,27 +196,98 @@ module OneForm class << self + DEFAULT_DRIVER_DIR = "#{LIB_LOCATION}/oneform/drivers" + EXTERNAL_DRIVER_DIR = "#{VAR_LOCATION}/oneform/drivers" + STATES_DIR = "#{VAR_LOCATION}/oneform/drivers/.states" + + # Returns a list of directories where drivers are located. + # It includes all subdirectories of default and all subdirectories inside each + # external registry source + # + # @return [Array] + def driver_dirs + dirs = [] + + default_root = Pathname.new(DEFAULT_DRIVER_DIR) + dirs.concat(visible_dirs(default_root)) if default_root.directory? + + external_root = Pathname.new(EXTERNAL_DRIVER_DIR) + if external_root.directory? + visible_dirs(external_root).each do |source_dir| + dirs.concat(visible_dirs(source_dir)) + end + end + + dirs + end + + def visible_dirs(path) + path.children.select {|p| p.directory? && !p.basename.to_s.start_with?('.') } + end + + # Builds a { driver_name => absolute_path } index + # + # @return [Hash{String => String}] + def driver_index + idx = {} + + driver_dirs.each do |dir| + name = dir.basename.to_s + idx[name] ||= dir.to_s + end + + idx + end + + # Resolves a driver directory path from its name. + # + # @param driver_name [String] + # @return [String, nil] + def driver_dir_for(driver_name) + driver_index[driver_name.to_s] + end + + # Determines the registry source for a given driver directory + def driver_registry_for_dir(driver_dir) + dir = Pathname.new(driver_dir).cleanpath + + default_root = Pathname.new(DEFAULT_DRIVER_DIR).cleanpath + external_root = Pathname.new(EXTERNAL_DRIVER_DIR).cleanpath + + dir_s = dir.to_s + default_s = default_root.to_s + external_s = external_root.to_s + + # default/ + if dir_s.start_with?(default_s + File::SEPARATOR) || dir == default_root + return 'default' + end + + # external// + if dir_s.start_with?(external_s + File::SEPARATOR) || dir == external_root + # rel = ["oneform-registry", "example"] -> source name is rel[0] + rel = dir.relative_path_from(external_root).each_filename.to_a + return rel[0] if rel && rel[0] + end + + 'unknown' + end + # Returns all driver names, optionally filtered by state. # # @param [Symbol, nil] state to filter drivers # @return [Array, OpenNebula::Error] def names(state = nil) - ddir = Pathname.new(DRIVERS_PATH) - return [] unless ddir.directory? + idx = driver_index + idx.keys.sort.select do |dname| + next true unless state - ddir.children - .select(&:directory?) - .map(&:basename) - .map(&:to_s) - .select do |dname| - next true unless state - - begin - get_driver_state(dname) == state - rescue StandardError - false - end + begin + get_driver_state(dname) == state + rescue StandardError + false end + end rescue StandardError => e error_msg = "Error retrieving driver names: #{e.message}" @@ -239,34 +315,34 @@ module OneForm # if something goes wrong, or nil if the # driver is in unknown state def from_name(driver_name) - driver_dir = File.join(DRIVERS_PATH, driver_name) - driver_file = File.join(driver_dir, 'driver.conf') + driver_dir = driver_dir_for(driver_name) return OpenNebula::Error.new( "Error getting #{driver_name} OneForm driver", OpenNebula::Error::ENO_EXISTS - ) unless Dir.exist?(driver_dir) + ) unless driver_dir && Dir.exist?(driver_dir) - state = get_driver_state(driver_name) + driver_file = File.join(driver_dir, 'driver.conf') + state = get_driver_state(driver_name) case state when :unknown - # Ignoring driver if we don't have state for it return when :error return error_body(driver_name) when :enabled, :disabled raise "Driver configuration file #{driver_file} does not exist" \ - unless File.exist?(driver_file) + unless File.exist?(driver_file) conf = YAML.load_file(driver_file, :symbolize_names => true) body = { :name => conf[:name], :description => conf[:description], - :source => driver_dir, :state => STR_STATES[state], + :registry => driver_registry_for_dir(driver_dir), :version => conf[:version], + :system_path => driver_dir, :fireedge => conf[:fireedge], :connection => tf_inputs(driver_name, 'provider'), :user_inputs => tf_inputs(driver_name, 'variables'), @@ -278,24 +354,18 @@ module OneForm raise "Driver #{driver_name} is in an invalid state (#{state})" end rescue StandardError => e - error_msg = "Error getting driver body: #{e.message}" - Log.error(error_msg) + Log.error("Error getting driver body: #{e.message}") - return OpenNebula::Error.new(error_msg) + set_driver_state(driver_name, :error, true) + set_driver_error(driver_name, e.message) + return error_body(driver_name) end # Returns a list of all available drivers. # # @return [Array, OpenNebula::Error] list of drivers, OpenNebula error otherwise def list - ddir = Pathname.new(DRIVERS_PATH) - return [] unless ddir.directory? - - ddir.children - .select(&:directory?) - .map {|dir| File.basename(dir.to_s) } - .map {|dname| Driver.from_name(dname) } - .compact + driver_index.keys.map {|dname| from_name(dname) }.compact rescue StandardError => e error_msg = "Error listing drivers: #{e.message}" @@ -304,7 +374,7 @@ module OneForm end # Tries to validate and enable all drivers from the local drivers path. - # - Iterates through each driver directory in DRIVERS_PATH. + # - Iterates through each driver directory. # - Verifies each driver using `verify_driver`. # - Sets the state to `:enabled` if valid, or `:error` otherwise. # - Writes the state to a `.state` file using `set_driver_state`. @@ -317,43 +387,33 @@ module OneForm # } # or an OpenNebula::Error if a top-level error occurs def sync - ddir = Pathname.new(DRIVERS_PATH) results = { :success => [], :failed => [] } - return results unless ddir.directory? + driver_index.keys.each do |dname| + rc = verify_driver(dname) + state = OpenNebula.is_error?(rc) ? :error : :enabled - ddir.children - .select(&:directory?) - .each do |dir| - dname = dir.basename.to_s - - rc = verify_driver(dname) - state = OpenNebula.is_error?(rc) ? :error : :enabled - - if OpenNebula.is_error?(rc) - results[:failed] << { :name => dname, :error => rc.message } - else - results[:success] << dname - end - - begin - # Avoid to enable disabled drivers - next if get_driver_state(dname) == :disabled && state == :enabled - - set_driver_state(dname, state, true) - rescue StandardError => e - Log.error( - "Failed to write .state file for driver '#{dname}': #{e.message}" - ) - end + if OpenNebula.is_error?(rc) + results[:failed] << { :name => dname, :error => rc.message } + else + results[:success] << dname end + begin + # Avoid to enable disabled drivers + next if get_driver_state(dname) == :disabled && state == :enabled + + set_driver_state(dname, state, true) + rescue StandardError => e + Log.error("Failed to write .state file for driver '#{dname}': #{e.message}") + end + end + results rescue StandardError => e error_msg = "Error syncing drivers: #{e.message}" - Log.error(error_msg) - return OpenNebula::Error.new(error_msg) + OpenNebula::Error.new(error_msg) end # Enables the given driver by name if it exists in the drivers directory. @@ -362,12 +422,12 @@ module OneForm # @param [String] driver_name the name of the driver to enable # @return [nil, OpenNebula::Error] nil on success, OpenNebula::Error otherwise def enable(driver_name) - driver_dir = File.join(DRIVERS_PATH, driver_name) + driver_dir = driver_dir_for(driver_name) return OpenNebula::Error.new( "Error getting #{driver_name} OneForm driver", OpenNebula::Error::ENO_EXISTS - ) unless Dir.exist?(driver_dir) + ) unless driver_dir && Dir.exist?(driver_dir) set_driver_state(driver_name, :enabled) end @@ -378,12 +438,12 @@ module OneForm # @param [String] driver_name the name of the driver to disable # @return [nil, OpenNebula::Error] nil on success, OpenNebula::Error otherwise def disable(driver_name) - driver_dir = File.join(DRIVERS_PATH, driver_name) + driver_dir = driver_dir_for(driver_name) return OpenNebula::Error.new( "Error getting #{driver_name} OneForm driver", OpenNebula::Error::ENO_EXISTS - ) unless Dir.exist?(driver_dir) + ) unless driver_dir && Dir.exist?(driver_dir) set_driver_state(driver_name, :disabled) end @@ -396,12 +456,10 @@ module OneForm # Lists all deployment inventories for the given driver def deployment_list(driver_name) - tmpl_dir = Pathname.new( - File.join(DRIVERS_PATH, driver_name, 'ansible', 'templates') - ) + tmpl_dir = Pathname.new(File.join(driver_path(driver_name), 'ansible', 'templates')) raise "Driver '#{driver_name}' does not exist or is missing 'ansible/templates'" \ - unless tmpl_dir.exist? && tmpl_dir.directory? + unless tmpl_dir.exist? && tmpl_dir.directory? tmpl_dir.children .select {|file| file.file? && file.extname == '.j2' } @@ -482,6 +540,7 @@ module OneForm } end + # Replaces user input tokens in the given template with actual values. def replace_user_inputs!(template, user_inputs) return {} unless template return template unless user_inputs @@ -512,12 +571,12 @@ module OneForm # including any associated validation rules def tf_inputs(driver_name, vars_path, keys = nil) keys = ['variable'] if keys.nil? || keys.empty? - tf_dir = File.join(DRIVERS_PATH, driver_name, 'terraform') + tf_dir = File.join(driver_path(driver_name), 'terraform') vars_file = File.join(tf_dir, "#{vars_path}.tf") validators_file = File.join(tf_dir, 'validators.tf') raise "Driver '#{driver_name}' does not exist or is missing " \ - "terraform/#{vars_path}.tf" unless File.exist?(vars_file) + "terraform/#{vars_path}.tf" unless File.exist?(vars_file) vars = load_hcl_file(vars_file, keys) validators = load_hcl_file(validators_file, ['locals', 'validators']) @@ -532,6 +591,7 @@ module OneForm :type => normalized_values['type'].to_s.downcase, :default => normalized_values['default'], :mandatory => normalized_values['default'].nil?, + :sensitive => normalized_values['sensitive'] || false, :match => match.empty? ? nil : match }.compact end @@ -570,14 +630,22 @@ module OneForm # Driver states and verifications # -------------------------------------------------------- + # Returns the path to a driver's directory + def driver_path(driver_name) + dir = driver_dir_for(driver_name) + raise "Driver '#{driver_name}' does not exist" unless dir + + dir + end + # Returns the path to the driver's .state file. def state_file(driver_name) - File.join(DRIVERS_PATH, driver_name, '.state') + File.join(STATES_DIR, "#{driver_name}.state") end # Returns the path to the driver's .error file. def error_file(driver_name) - File.join(DRIVERS_PATH, driver_name, '.error') + File.join(STATES_DIR, "#{driver_name}.error") end # Retrieves the current state of the driver as a symbol @@ -639,20 +707,20 @@ module OneForm # Builds a hash representing the driver's error state and message def error_body(driver_name) - ddir = File.join(DRIVERS_PATH, driver_name) + ddir = File.join(driver_path(driver_name)) error = File.read(error_file(driver_name)) if File.exist?(error_file(driver_name)) { - :name => driver_name, - :source => ddir, - :state => STR_STATES[:error], - :error_msg => error + :name => driver_name, + :state => STR_STATES[:error], + :system_path => ddir, + :error_msg => error }.compact end # Verifies that the required files and structure exist for a driver def verify_driver(driver_name) - path = File.join(DRIVERS_PATH, driver_name) + path = driver_path(driver_name) raise "Path '#{path}' does not exist or is not a directory" \ unless File.directory?(path) @@ -693,12 +761,10 @@ module OneForm # === Validate templates metadata Dir.glob(File.join(templates_dir, '*.j2')).each do |template_path| template = File.read(template_path) - - # Get YAML block from template between `{# ... #}` yaml_block = template.match(/(?<=\{#).+?(?=\#\})/m) raise "OneForm metadata block not found in template: #{template_path}" \ - if yaml_block.nil? + if yaml_block.nil? end # === Optional: elastic @@ -722,7 +788,6 @@ module OneForm assert_file_exists(File.join(ipam_dir, script)) end - # Create symlinks to ipam remotes folder create_symlinks(driver_name) end @@ -740,7 +805,7 @@ module OneForm # Creates symbolic links for the driver's IPAM files def create_symlinks(driver_name) - ipam_path = File.join(DRIVERS_PATH, driver_name, 'ipam') + ipam_path = File.join(driver_path(driver_name), 'ipam') target_dir = File.join(VAR_LOCATION, 'remotes', 'ipam', driver_name) return unless Dir.exist?(ipam_path) diff --git a/src/form/app/models/provider.rb b/src/form/app/models/provider.rb index bddd251245..f952b958e9 100644 --- a/src/form/app/models/provider.rb +++ b/src/form/app/models/provider.rb @@ -102,6 +102,7 @@ module OneForm DOCUMENT_TYPE = ProviderDocumentPool::DOCUMENT_TYPE TEMPLATE_TAG = 'PROVIDER_BODY' + REDACTED_MARK = '__redacted__' PROVIDER_ATTRS = [ 'name', @@ -109,6 +110,7 @@ module OneForm 'driver', 'version', 'fireedge', + 'user_inputs', 'connection', 'provision_ids', 'registration_time' @@ -181,12 +183,47 @@ module OneForm ) if validation.failure? end - # Transform the provision body to JSON - def to_json(opts = {}) - document = to_hash.clone - document['DOCUMENT']['TEMPLATE'][TEMPLATE_TAG] = @body.clone + def to_h(opts = {}) + include_sensitive = opts[:include_sensitive] == true - document.to_json(opts) + document = to_hash.clone + template = Marshal.load(Marshal.dump(@body)) + + ui = template['user_inputs'] || [] + ui_values = (template['connection'] || {}).dup + + unless include_sensitive + ui.each do |input| + sensitive = input[:sensitive] || input['sensitive'] + name = input[:name] || input['name'] + next unless sensitive && name + + ui_values[name] = REDACTED_MARK if ui_values.key?(name) + end + end + + template = template.merge('connection' => ui_values) + document['DOCUMENT']['TEMPLATE'][TEMPLATE_TAG] = template + + document + end + + def to_json(*args) + super + end + + def enabled? + rc = OneForm::Driver.from_name(driver) + return false if OpenNebula.is_error?(rc) + + rc.enabled? + end + + def driver_path + rc = OneForm::Driver.from_name(driver) + return rc.system_path if OpenNebula.is_error?(rc) == false + + nil end ######################################################## diff --git a/src/form/app/models/provision.rb b/src/form/app/models/provision.rb index 56d912e421..d8943b089f 100644 --- a/src/form/app/models/provision.rb +++ b/src/form/app/models/provision.rb @@ -83,6 +83,7 @@ module OneForm DOCUMENT_TYPE = ProvisionDocumentPool::DOCUMENT_TYPE TEMPLATE_TAG = 'PROVISION_BODY' + REDACTED_MARK = '__redacted__' BASE_DIR = conf[:work_dir] # Log configuration @@ -272,31 +273,52 @@ module OneForm File.join(logdir, "#{id}.log") end - # Transform the provision body to JSON - def to_json(opts = {}) + def to_h(opts = {}) + include_sensitive = opts[:include_sensitive] == true + document = to_hash.clone - body = @body.clone - - # Transformin state - body['state'] = str_state + template = Marshal.load(Marshal.dump(@body)) + # Transforming state + template['state'] = str_state # Removing tfstate - body.delete('tfstate') - - # Removing component from inputs - body['user_inputs'].each do |ui| - ui.delete('component') - end + template.delete('tfstate') # Transforming tags - body['tags'] = tags_values + template['tags'] = tags_values - if body['tags'].any? - body['user_inputs_values'] = body['user_inputs_values'].except('oneform_tags') + ui = template['user_inputs'] || [] + ui_values = (template['user_inputs_values'] || {}).dup + + # Removing component from inputs + ui.each do |input| + input.delete('component') end - document['DOCUMENT']['TEMPLATE'][TEMPLATE_TAG] = body - document.to_json(opts) + # Remove oneform_tags from user_inputs_values if tags exist + if template['tags'].is_a?(Array) && !template['tags'].empty? + ui_values.delete(:oneform_tags) + end + + # Redact sensitive values + unless include_sensitive + ui.each do |input| + sensitive = input[:sensitive] || input['sensitive'] + name = input[:name] || input['name'] + next unless sensitive && name + + ui_values[name] = REDACTED_MARK if ui_values.key?(name) + end + end + + template['user_inputs_values'] = ui_values + + document['DOCUMENT']['TEMPLATE'][TEMPLATE_TAG] = template + document + end + + def to_json(*args) + super end # Returns a logger for this provision. Provision::dir should exist before @@ -785,8 +807,15 @@ module OneForm def create_one_objects(success_cb, failure_cb) @logger.info('Creating OpenNebula objects') - suffix = "(provision_#{id})" - tags = { 'oneform' => { 'provision_id' => id }.merge(tags_values) } + provider = Provider.new_from_id(@client, provider_id) + suffix = "(provision_#{id})" + tags = { + 'oneform' => { + 'provision_id' => id, + 'provider_id' => provider.id, + 'driver' => provider.driver + }.merge(tags_values) + } run_block(@logger, success_cb, failure_cb) do # Create the OpenNebula objects for each resource type diff --git a/src/form/config/environment.rb b/src/form/config/environment.rb index 3f38efcc34..f5b81d7fdb 100644 --- a/src/form/config/environment.rb +++ b/src/form/config/environment.rb @@ -28,7 +28,6 @@ if !ONE_LOCATION VAR_LOCATION = '/var/lib/one' ETC_LOCATION = '/etc/one' LIB_LOCATION = '/usr/lib/one' - DRIVERS_PATH = '/usr/share/one/oneform/drivers' else RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' GEMS_LOCATION = ONE_LOCATION + '/share/gems' @@ -36,7 +35,6 @@ else LOG_LOCATION = ONE_LOCATION + '/var' ETC_LOCATION = ONE_LOCATION + '/etc' LIB_LOCATION = ONE_LOCATION + '/lib' - DRIVERS_PATH = ONE_LOCATION + '/share/oneform/drivers' end require 'load_opennebula_paths' diff --git a/src/form/drivers/.states/dummy.state b/src/form/drivers/.states/dummy.state new file mode 100644 index 0000000000..c96dafabd8 --- /dev/null +++ b/src/form/drivers/.states/dummy.state @@ -0,0 +1 @@ +DISABLED \ No newline at end of file diff --git a/src/form/drivers/.states/onprem.state b/src/form/drivers/.states/onprem.state new file mode 100644 index 0000000000..d671fd7092 --- /dev/null +++ b/src/form/drivers/.states/onprem.state @@ -0,0 +1 @@ +ENABLED \ No newline at end of file diff --git a/share/providers/aws/ansible/ansible.cfg b/src/form/drivers/dummy/ansible/ansible.cfg similarity index 100% rename from share/providers/aws/ansible/ansible.cfg rename to src/form/drivers/dummy/ansible/ansible.cfg diff --git a/share/providers/dummy/ansible/inventory.yaml b/src/form/drivers/dummy/ansible/inventory.yaml similarity index 100% rename from share/providers/dummy/ansible/inventory.yaml rename to src/form/drivers/dummy/ansible/inventory.yaml diff --git a/share/providers/dummy/ansible/site.yaml b/src/form/drivers/dummy/ansible/site.yaml similarity index 100% rename from share/providers/dummy/ansible/site.yaml rename to src/form/drivers/dummy/ansible/site.yaml diff --git a/share/providers/dummy/ansible/templates/dummy_cluster.j2 b/src/form/drivers/dummy/ansible/templates/dummy_cluster.j2 similarity index 96% rename from share/providers/dummy/ansible/templates/dummy_cluster.j2 rename to src/form/drivers/dummy/ansible/templates/dummy_cluster.j2 index 33061b443e..5345ebc791 100644 --- a/share/providers/dummy/ansible/templates/dummy_cluster.j2 +++ b/src/form/drivers/dummy/ansible/templates/dummy_cluster.j2 @@ -81,7 +81,7 @@ all: frontend: hosts: - f1: { ansible_user: root, ansible_host: "{{ one.frontend_ip}}" } + f1: { ansible_user: root, ansible_host: "{{one.frontend_ip}}" } node: hosts: {} diff --git a/share/providers/dummy/driver.conf b/src/form/drivers/dummy/driver.conf similarity index 100% rename from share/providers/dummy/driver.conf rename to src/form/drivers/dummy/driver.conf diff --git a/share/providers/dummy/elastic/dummy_vnm.rb b/src/form/drivers/dummy/elastic/dummy_vnm.rb similarity index 94% rename from share/providers/dummy/elastic/dummy_vnm.rb rename to src/form/drivers/dummy/elastic/dummy_vnm.rb index 3e94ab8fa8..57deeb7b9a 100644 --- a/share/providers/dummy/elastic/dummy_vnm.rb +++ b/src/form/drivers/dummy/elastic/dummy_vnm.rb @@ -20,12 +20,10 @@ if !ONE_LOCATION LIB_LOCATION ||= '/usr/lib/one' RUBY_LIB_LOCATION ||= '/usr/lib/one/ruby' GEMS_LOCATION ||= '/usr/share/one/gems' - DRIVERS_PATH ||= '/usr/share/one/oneform/drivers' else LIB_LOCATION ||= ONE_LOCATION + '/lib' RUBY_LIB_LOCATION ||= ONE_LOCATION + '/lib/ruby' GEMS_LOCATION ||= ONE_LOCATION + '/share/gems' - DRIVERS_PATH ||= ONE_LOCATION + '/share/oneform/drivers' end # %%RUBYGEMS_SETUP_BEGIN%% diff --git a/src/form/drivers/dummy/ipam b/src/form/drivers/dummy/ipam new file mode 120000 index 0000000000..673cc35552 --- /dev/null +++ b/src/form/drivers/dummy/ipam @@ -0,0 +1 @@ +../../../ipamm_mad/remotes/dummy/ \ No newline at end of file diff --git a/share/providers/dummy/terraform/locals.tf b/src/form/drivers/dummy/terraform/locals.tf similarity index 100% rename from share/providers/dummy/terraform/locals.tf rename to src/form/drivers/dummy/terraform/locals.tf diff --git a/share/providers/dummy/terraform/main.tf b/src/form/drivers/dummy/terraform/main.tf similarity index 100% rename from share/providers/dummy/terraform/main.tf rename to src/form/drivers/dummy/terraform/main.tf diff --git a/share/providers/dummy/terraform/outputs.tf b/src/form/drivers/dummy/terraform/outputs.tf similarity index 100% rename from share/providers/dummy/terraform/outputs.tf rename to src/form/drivers/dummy/terraform/outputs.tf diff --git a/share/providers/dummy/terraform/provider.tf b/src/form/drivers/dummy/terraform/provider.tf similarity index 100% rename from share/providers/dummy/terraform/provider.tf rename to src/form/drivers/dummy/terraform/provider.tf diff --git a/share/providers/dummy/terraform/validators.tf b/src/form/drivers/dummy/terraform/validators.tf similarity index 100% rename from share/providers/dummy/terraform/validators.tf rename to src/form/drivers/dummy/terraform/validators.tf diff --git a/share/providers/dummy/terraform/variables.tf b/src/form/drivers/dummy/terraform/variables.tf similarity index 95% rename from share/providers/dummy/terraform/variables.tf rename to src/form/drivers/dummy/terraform/variables.tf index 4f40127089..f654301e4b 100644 --- a/share/providers/dummy/terraform/variables.tf +++ b/src/form/drivers/dummy/terraform/variables.tf @@ -20,6 +20,6 @@ variable "oneform_tags" { description = "value of the tags to assign to the instance" type = map(string) default = { - provider = "dummy" + driver = "dummy" } } diff --git a/share/providers/dummy/ansible/ansible.cfg b/src/form/drivers/onprem/ansible/ansible.cfg similarity index 100% rename from share/providers/dummy/ansible/ansible.cfg rename to src/form/drivers/onprem/ansible/ansible.cfg diff --git a/share/providers/aws/ansible/inventory.yaml b/src/form/drivers/onprem/ansible/inventory.yaml similarity index 100% rename from share/providers/aws/ansible/inventory.yaml rename to src/form/drivers/onprem/ansible/inventory.yaml diff --git a/share/providers/onprem/ansible/site.yaml b/src/form/drivers/onprem/ansible/site.yaml similarity index 100% rename from share/providers/onprem/ansible/site.yaml rename to src/form/drivers/onprem/ansible/site.yaml diff --git a/share/providers/onprem/ansible/templates/nfs_cluster.j2 b/src/form/drivers/onprem/ansible/templates/nfs_cluster.j2 similarity index 79% rename from share/providers/onprem/ansible/templates/nfs_cluster.j2 rename to src/form/drivers/onprem/ansible/templates/nfs_cluster.j2 index 21805729e4..beec7f519f 100644 --- a/share/providers/onprem/ansible/templates/nfs_cluster.j2 +++ b/src/form/drivers/onprem/ansible/templates/nfs_cluster.j2 @@ -1,13 +1,17 @@ {# name: On-Prem NFS Cluster description: | - Creates a cluster using your on-prem (local) infrastructure. - * Requirements. Hosts must have the OS installed and be reachable via SSH. An NFS export must exist and be reachable from all hosts. The shared export MUST be owned by oneadmin (UID/GID 9869). And mounted in the the front-end in the designeted NFS mount pat in the designeted NFS mount path. - * Storage. VM images and system files are stored on shared NFS storage. - * Network. VMs use a flat bridged network via a physical NIC on every host. - -fireedge: - logo: "onprem_ssh_cluster.png" +

Creates a cluster using your on-prem (local) infrastructure.

+
    +
  • Requirements:
      +
    • Hosts must have the OS installed and be reachable via SSH.
    • +
    • An NFS export must exist and be reachable from all hosts.
    • +
    • The shared export MUST be owned by oneadmin (UID/GID 9869).
    • +
    • The shared export MUST be mounted in the front-end in the designated NFS mount path.
  • +
  • Storage: VM images and system files are stored on shared NFS storage.
  • +
  • Network: VMs use a flat bridged network via a physical NIC on every host.
  • +
+

For more details please check the NFS datastore documentation.

user_inputs: - name: phydev_name diff --git a/share/providers/onprem/ansible/templates/ssh_cluster.j2 b/src/form/drivers/onprem/ansible/templates/ssh_cluster.j2 similarity index 84% rename from share/providers/onprem/ansible/templates/ssh_cluster.j2 rename to src/form/drivers/onprem/ansible/templates/ssh_cluster.j2 index 76008b76e8..1ccf55a6f9 100644 --- a/share/providers/onprem/ansible/templates/ssh_cluster.j2 +++ b/src/form/drivers/onprem/ansible/templates/ssh_cluster.j2 @@ -1,12 +1,13 @@ {# name: On-Prem SSH Cluster description: | - Creates a cluster on your on-prem (local) infrastructure. - * Requirements. Hosts must have the OS installed and be reachable via SSH. - * Storage. VM images are copied to each host over SSH and stored on local disk. - * Network. VMs use a flat bridged network via a physical NIC on every host. -fireedge: - logo: "onprem_ssh_cluster.png" +

Creates a cluster on your on-prem (local) infrastructure.

+
    +
  • Requirements: Hosts must have the OS installed and be reachable via SSH.
  • +
  • Storage: VM images are copied to each host over SSH and stored on local disk.
  • +
  • Network: VMs use a flat bridged network via a physical NIC on every host.
  • +
+ user_inputs: - name: phydev_name description: Host NIC used to bridge the VM network (must exist on all hosts), e.g. eth0 or ens3 diff --git a/share/providers/onprem/driver.conf b/src/form/drivers/onprem/driver.conf similarity index 100% rename from share/providers/onprem/driver.conf rename to src/form/drivers/onprem/driver.conf diff --git a/share/providers/onprem/terraform/main.tf b/src/form/drivers/onprem/terraform/main.tf similarity index 100% rename from share/providers/onprem/terraform/main.tf rename to src/form/drivers/onprem/terraform/main.tf diff --git a/share/providers/onprem/terraform/outputs.tf b/src/form/drivers/onprem/terraform/outputs.tf similarity index 100% rename from share/providers/onprem/terraform/outputs.tf rename to src/form/drivers/onprem/terraform/outputs.tf diff --git a/share/providers/onprem/terraform/provider.tf b/src/form/drivers/onprem/terraform/provider.tf similarity index 100% rename from share/providers/onprem/terraform/provider.tf rename to src/form/drivers/onprem/terraform/provider.tf diff --git a/share/providers/onprem/terraform/variables.tf b/src/form/drivers/onprem/terraform/variables.tf similarity index 100% rename from share/providers/onprem/terraform/variables.tf rename to src/form/drivers/onprem/terraform/variables.tf diff --git a/src/form/lib/helpers/response_helper.rb b/src/form/lib/helpers/response_helper.rb index f55b9bbcd2..221f9f269a 100644 --- a/src/form/lib/helpers/response_helper.rb +++ b/src/form/lib/helpers/response_helper.rb @@ -90,13 +90,33 @@ module ResponseHelper # -------------------------------------------------------------------------- # Response processing # -------------------------------------------------------------------------- - def process_response(response) + def process_response(response, opts = {}) content_type = request.env['CONTENT_TYPE'] || 'application/json' case content_type when 'application/json' content_type(:json) - response.to_json + + data = + if response.is_a?(Array) + response.map do |obj| + if obj.is_a?(Hash) + obj + elsif obj.respond_to?(:to_h) + obj.to_h(opts) + else + obj + end + end + elsif response.is_a?(Hash) + response + elsif response.respond_to?(:to_h) + response.to_h(opts) + else + response + end + + JSON.generate(data) else content_type(:text) response.to_s diff --git a/src/form/lib/tools/ansible.rb b/src/form/lib/tools/ansible.rb index e6abe5abcf..f0836bd78d 100644 --- a/src/form/lib/tools/ansible.rb +++ b/src/form/lib/tools/ansible.rb @@ -43,7 +43,7 @@ class Ansible ddir = ansible_dir(provision, true) log.debug("Gathering Ansible files for provision #{provision.id}") - FileUtils.cp_r("#{DRIVERS_PATH}/#{provider.driver}/ansible/.", ddir) + FileUtils.cp_r("#{provider.driver_path}/ansible/.", ddir) within_dir(ddir) do check_files(ddir) diff --git a/src/form/lib/tools/terraform.rb b/src/form/lib/tools/terraform.rb index eba032214e..0817f419fe 100644 --- a/src/form/lib/tools/terraform.rb +++ b/src/form/lib/tools/terraform.rb @@ -37,17 +37,16 @@ class Terraform ddir = tf_dir(provision, true) log.debug("Gathering Terraform files for provision #{provision.id}") - - FileUtils.cp_r( - "#{DRIVERS_PATH}/#{provider.driver}/terraform/.", ddir - ) + FileUtils.cp_r("#{provider.driver_path}/terraform/.", ddir) # Change to the terraform provision directory within_dir(ddir) do # Add provider info to terraform tags vars = provision.user_inputs_values.merge( 'oneform_tags' => { - 'provision_id' => provision.id + 'provision_id' => provision.id, + 'provider_id' => provider.id, + 'driver' => provider.driver }.merge(provision.tags_values) ) generate_tfvars(provider.connection, vars) @@ -257,9 +256,7 @@ class Terraform def copy_terraform_files(provision, provider) ddir = tf_dir(provision, true) - FileUtils.cp_r( - "#{DRIVERS_PATH}/#{provider.driver}/terraform/.", ddir - ) + FileUtils.cp_r("#{provider.driver_path}/terraform/.", ddir) end # Generate the terraform variables file diff --git a/src/ipamm_mad/one_ipam.rb b/src/ipamm_mad/one_ipam.rb index 42f0599799..83aba7b456 100755 --- a/src/ipamm_mad/one_ipam.rb +++ b/src/ipamm_mad/one_ipam.rb @@ -22,12 +22,10 @@ if !ONE_LOCATION RUBY_LIB_LOCATION = '/usr/lib/one/ruby' GEMS_LOCATION = '/usr/share/one/gems' ETC_LOCATION = '/etc/one/' - DRIVERS_PATH = '/usr/share/one/oneform/drivers' else RUBY_LIB_LOCATION = ONE_LOCATION + '/lib/ruby' GEMS_LOCATION = ONE_LOCATION + '/share/gems' ETC_LOCATION = ONE_LOCATION + '/etc/' - DRIVERS_PATH = ONE_LOCATION + '/share/oneform/drivers' end # %%RUBYGEMS_SETUP_BEGIN%% @@ -76,10 +74,9 @@ class IPAMDriver < OpenNebulaDriver super('ipam/', @options) if ipam_type.nil? - @types = ( Dir["#{@local_scripts_path}/*/"] + - Dir["#{DRIVERS_PATH}/*/ipam"]).map do |d| - File.basename(File.dirname(d)) - end.uniq + @types = Dir["#{@local_scripts_path}/*/"].map do |d| + d.split('/')[-1] + end elsif ipam_type.class == String @types = [ipam_type] else @@ -154,15 +151,7 @@ class IPAMDriver < OpenNebulaDriver return unless available?(ipam, id, action) - local_path = File.join(@local_scripts_path, ipam) - driver_path = File.join(DRIVERS_PATH, ipam, 'ipam') - - path = if File.exist?(driver_path) - driver_path - else - local_path - end - + path = File.join(@local_scripts_path, ipam) cmd = File.join(path, ACTION[action].downcase) cmd << ' ' << id diff --git a/src/oca/ruby/opennebula/form/drivers.rb b/src/oca/ruby/opennebula/form/drivers.rb index fcb4e0652d..7639a77843 100644 --- a/src/oca/ruby/opennebula/form/drivers.rb +++ b/src/oca/ruby/opennebula/form/drivers.rb @@ -21,9 +21,10 @@ module OneForm # Return a list of all drivers registered on the system # + # @param opts [Hash] Optional parameters for filtering drivers # @return [Array[Hash]] List of drivers installed on the system - def list_drivers - get('/drivers') + def list_drivers(opts = {}) + get('/drivers', opts) end # Get information about a specific driver diff --git a/src/oca/ruby/opennebula/form/providers.rb b/src/oca/ruby/opennebula/form/providers.rb index 52770f62af..404ef709e2 100644 --- a/src/oca/ruby/opennebula/form/providers.rb +++ b/src/oca/ruby/opennebula/form/providers.rb @@ -22,16 +22,16 @@ module OneForm # List all existing cloud providers. # # @return [Array] List of configured providers with their metadata. - def list_providers - get('/providers') + def list_providers(opts = {}) + get('/providers', opts) end # Retrieve a specific provider by its ID. # # @param id [Int] The provider's unique identifier. # @return [Hash] Provider configuration and status. - def get_provider(id) - get("/providers/#{id}") + def get_provider(id, opts = {}) + get("/providers/#{id}", opts) end # Retrieve the location path of a provider. diff --git a/src/oca/ruby/opennebula/form/provisions.rb b/src/oca/ruby/opennebula/form/provisions.rb index e071aecea7..d294d89406 100644 --- a/src/oca/ruby/opennebula/form/provisions.rb +++ b/src/oca/ruby/opennebula/form/provisions.rb @@ -31,8 +31,8 @@ module OneForm # # @param id [String] Provision ID. # @return [Hash] Details of the provision. - def get_provision(id) - get("/provisions/#{id}") + def get_provision(id, opts = {}) + get("/provisions/#{id}", opts) end # Retrieve the unmanaged version of a provision. diff --git a/src/vnm_mad/remotes/elastic/elastic.rb b/src/vnm_mad/remotes/elastic/elastic.rb index 8271548238..e5496d97f7 100644 --- a/src/vnm_mad/remotes/elastic/elastic.rb +++ b/src/vnm_mad/remotes/elastic/elastic.rb @@ -93,10 +93,10 @@ class ElasticDriver < VNMMAD::VNMDriver provision = document[:TEMPLATE][:PROVISION_BODY] provider_id = provision[:provider_id] - document = client.get_provider(provider_id) + document = client.get_provider(provider_id, :sensitive => true) if document.key?(:err_code) - STDERR.puts "Error retrieving provision #{provider_id}: #{document[:message]}" + STDERR.puts "Error retrieving provider #{provider_id}: #{document[:message]}" exit(-1) end