mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-22 18:50:08 +03:00
F #5332: On-premises provider
co-authored-by: Christian González <cgonzalez@opennebula.io> (cherry picked from commit 824d2bd4486b5d414d827b1be1e37d64431ab092)
This commit is contained in:
parent
a6c7898544
commit
fd33ba72a7
22
share/oneprovision/ansible/onprem.yml
Normal file
22
share/oneprovision/ansible/onprem.yml
Normal file
@ -0,0 +1,22 @@
|
||||
---
|
||||
|
||||
- hosts: all
|
||||
gather_facts: false
|
||||
roles:
|
||||
- python
|
||||
|
||||
- hosts: nodes
|
||||
roles:
|
||||
- ddc
|
||||
- opennebula-repository
|
||||
- { role: opennebula-node-kvm, when: oneprovision_hypervisor == 'kvm' }
|
||||
- { role: opennebula-node-firecracker, when: oneprovision_hypervisor == 'firecracker' }
|
||||
- { role: opennebula-node-lxc, when: oneprovision_hypervisor == 'lxc' }
|
||||
- opennebula-ssh
|
||||
- update-replica
|
||||
- role: frr
|
||||
#bond0_0 is attached to the project private network
|
||||
frr_iface: '{{ oneprovision_private_phydev }}'
|
||||
# Use /25 for the internal management network address
|
||||
frr_prefix_length: 25
|
||||
|
1
share/oneprovision/edge-clusters/onprem/description.md
Normal file
1
share/oneprovision/edge-clusters/onprem/description.md
Normal file
@ -0,0 +1 @@
|
||||
The onprem provision uses on premises infrastructure to build an **edge cluster**. This provision is useful for automate the datacenter configuration and operation.
|
@ -0,0 +1,8 @@
|
||||
name: 'onprem'
|
||||
|
||||
description: 'On Premises datacenter infrastructure'
|
||||
provider: 'dummy'
|
||||
|
||||
plain:
|
||||
image: 'ON-PREMISE'
|
||||
provision_type: 'onprem'
|
@ -0,0 +1,39 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# datastores: Defines the storage area for the cluster using the SSH replication
|
||||
# drivers. It creates the following datastores, using Replica driver:
|
||||
# 1. Image datastore, ${cluster_name}-image
|
||||
# 2. System datastore, ${cluster_name}-system
|
||||
#
|
||||
# Configuration/Input attributes:
|
||||
# - replica_host: The host that will hold the cluster replicas and snapshots.
|
||||
#-------------------------------------------------------------------------------
|
||||
datastores:
|
||||
|
||||
- name: "${provision}-image"
|
||||
type: 'image_ds'
|
||||
ds_mad: 'fs'
|
||||
tm_mad: 'ssh'
|
||||
safe_dirs: "/var/tmp /tmp"
|
||||
|
||||
- name: "${provision}-system"
|
||||
type: 'system_ds'
|
||||
tm_mad: 'ssh'
|
||||
safe_dirs: "/var/tmp /tmp"
|
||||
replica_host: "use-first-host"
|
@ -0,0 +1,31 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# defaults: Common configuration attributes for provision objects
|
||||
#--------------------------------------------------------------------------------
|
||||
|
||||
defaults:
|
||||
configuration:
|
||||
# Select the hypervisor package to install
|
||||
oneprovision_hypervisor: "${input.one_hypervisor}"
|
||||
|
||||
# required for copying recovery VM snapshots to the replica host
|
||||
opennebula_ssh_deploy_private_key: true
|
||||
|
||||
# Select the physical device for private network (VXLAN)
|
||||
oneprovision_private_phydev: "${input.private_phydev}"
|
@ -0,0 +1,20 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
image: 'OPENNEBULA-ON-PREM'
|
||||
provider: 'dummy'
|
||||
provision_type: 'onprem'
|
@ -0,0 +1,34 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# hosts: Packet or AWS metal servers
|
||||
# provision:
|
||||
# - count: Number of servers to create
|
||||
# - hostname: kvm-host1, kvm-host2 .... of the server
|
||||
#
|
||||
# You can define specific OpenNebula configuration attributes for all the hosts:
|
||||
# - reserved_cpu: In percentage. It will be subtracted from the TOTAL CPU
|
||||
# - reserved_memory: In percentage. It will be subtracted from the TOTAL MEM
|
||||
#-------------------------------------------------------------------------------
|
||||
hosts:
|
||||
|
||||
- im_mad: "${input.one_hypervisor}"
|
||||
vm_mad: "${input.one_hypervisor}"
|
||||
provision:
|
||||
hostname: "${input.hosts_names}"
|
||||
...
|
@ -0,0 +1,57 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
inputs:
|
||||
- name: 'hosts_names'
|
||||
type: array
|
||||
description: 'Comma separated list of FQDNs or IP addresses of the hosts to be added to the cluster'
|
||||
|
||||
- name: 'one_hypervisor'
|
||||
type: list
|
||||
description: "Virtualization technology for the cluster hosts"
|
||||
options:
|
||||
- 'kvm'
|
||||
- 'lxc'
|
||||
- 'firecracker'
|
||||
|
||||
- name: 'dns'
|
||||
type: text
|
||||
description: 'Comma separated list of DNS servers for public network'
|
||||
default: '1.1.1.1'
|
||||
|
||||
- name: 'public_network_bridge'
|
||||
type: text
|
||||
description: 'Name of the bridge to be created by OpenNebula for public networking.'
|
||||
|
||||
- name: 'first_public_ip'
|
||||
type: text
|
||||
description: 'First public IP for the public IPs address range.'
|
||||
|
||||
- name: 'number_public_ips'
|
||||
type: text
|
||||
description: 'Number of public IPs to get'
|
||||
default: '1'
|
||||
|
||||
- name: 'public_phydev'
|
||||
type: text
|
||||
description: 'Physical device to be used for public networking.'
|
||||
|
||||
- name: 'private_phydev'
|
||||
type: text
|
||||
description: 'Physical device to be used for private networking.'
|
||||
|
||||
...
|
@ -0,0 +1,39 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
networks:
|
||||
- name: "${provision}-public"
|
||||
vn_mad: 'bridge'
|
||||
phydev: "${input.public_phydev}"
|
||||
bridge: '${input.public_network_bridge}'
|
||||
netrole: 'public'
|
||||
dns: "${input.dns}"
|
||||
ar:
|
||||
- type: IP4
|
||||
ip: "${input.first_public_ip}"
|
||||
size: "${input.number_public_ips}"
|
||||
|
||||
vntemplates:
|
||||
- name: "${provision}-private"
|
||||
vn_mad: 'vxlan'
|
||||
phydev: "${input.private_phydev}"
|
||||
automatic_vlan_id: 'yes'
|
||||
netrole: 'private'
|
||||
vxlan_mode: 'evpn'
|
||||
vxlan_tep: 'dev'
|
||||
ip_link_conf: 'nolearning='
|
||||
cluster_ids: "${cluster.0.id}"
|
@ -0,0 +1,31 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Use this file to define custom resources associated to the cluster, example:
|
||||
# - images
|
||||
# - marketplaceapps
|
||||
# - templates
|
||||
# - vntemplates
|
||||
# - flowtemplates
|
||||
#
|
||||
# Cross-references to other objects can be made:
|
||||
# - by name, eg. ${datastore.images.id} to get the OpenNebula ID of the
|
||||
# datastore with name "images"
|
||||
# - by index, eg. ${datastore.0.id} to get the OpenNebula ID of the **first**
|
||||
# datastore defined in the provision
|
||||
#-------------------------------------------------------------------------------
|
@ -0,0 +1,66 @@
|
||||
---
|
||||
# ---------------------------------------------------------------------------- #
|
||||
# Copyright 2002-2021, OpenNebula Project, OpenNebula Systems #
|
||||
# #
|
||||
# Licensed under the Apache License, Version 2.0 (the "License"); you may #
|
||||
# not use this file except in compliance with the License. You may obtain #
|
||||
# a copy of the License at #
|
||||
# #
|
||||
# http://www.apache.org/licenses/LICENSE-2.0 #
|
||||
# #
|
||||
# Unless required by applicable law or agreed to in writing, software #
|
||||
# distributed under the License is distributed on an "AS IS" BASIS, #
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. #
|
||||
# See the License for the specific language governing permissions and #
|
||||
# limitations under the License. #
|
||||
# ---------------------------------------------------------------------------- #
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# This is the canonical description file for a cluster build On-Premise
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
name: 'onprem-cluster'
|
||||
|
||||
extends:
|
||||
- onprem.d/defaults.yml
|
||||
- onprem.d/resources.yml
|
||||
- onprem.d/hosts.yml
|
||||
- onprem.d/datastores.yml
|
||||
- onprem.d/fireedge.yml
|
||||
- onprem.d/inputs.yml
|
||||
- onprem.d/networks.yml
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# playbook: Ansible playbook used for hosts configuration. Check ansible/aws.yml
|
||||
# for the specific roles applied.
|
||||
#-------------------------------------------------------------------------------
|
||||
playbook:
|
||||
- onprem
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# defaults: Common configuration attributes for provision objects
|
||||
#--------------------------------------------------------------------------------
|
||||
defaults:
|
||||
provision:
|
||||
provider_name: 'onprem'
|
||||
connection:
|
||||
remote_user: 'root'
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# cluster: Parameters for the OpenNebula cluster. Applies to all the Hosts
|
||||
#--------------------------------------------------------------------------------
|
||||
# name: of the cluster
|
||||
# description: Additional information
|
||||
# reserved_cpu: In percentage. It will be subtracted from the TOTAL CPU
|
||||
# reserved_memory: In percentage. It will be subtracted from the TOTAL MEM
|
||||
#--------------------------------------------------------------------------------
|
||||
cluster:
|
||||
name: "${provision}"
|
||||
description: 'On-Premise edge cluster'
|
||||
reserved_cpu: '0'
|
||||
reserved_mem: '0'
|
||||
datastores:
|
||||
- 1
|
||||
- 2
|
||||
|
||||
...
|
@ -102,6 +102,8 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper
|
||||
puts format('ID : %<s>s', :s => id)
|
||||
puts format('NAME : %<s>s', :s => provider['NAME'])
|
||||
|
||||
return if body['provider'] == 'dummy'
|
||||
|
||||
# Get max size to adjust all the values
|
||||
size = body['connection'].keys.map {|k| k.size }.max
|
||||
data = {}
|
||||
@ -176,7 +178,6 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper
|
||||
template = YAML.load_file(template)
|
||||
|
||||
raise 'Name not found' unless template['name']
|
||||
raise 'Connection info not found' unless template['connection']
|
||||
|
||||
unless OneProvision::Terraform::PROVIDERS.include?(
|
||||
template['provider']
|
||||
@ -185,6 +186,10 @@ class OneProviderHelper < OpenNebulaHelper::OneHelper
|
||||
"#{OneProvision::Terraform::PROVIDERS.join(', ')}"
|
||||
end
|
||||
|
||||
return template if template['provider'] == 'dummy'
|
||||
|
||||
raise 'Connection info not found' unless template['connection']
|
||||
|
||||
template
|
||||
rescue StandardError => e
|
||||
OpenNebula::Error.new("ERROR: #{e}")
|
||||
|
@ -129,8 +129,6 @@ CommandParser::CmdParser.new(ARGV) do
|
||||
STDERR.puts rc.message
|
||||
exit(-1)
|
||||
elsif rc.to_i < 0
|
||||
puts CLIHelper.green('Provision successfully created')
|
||||
puts "ID: #{rc}"
|
||||
rc
|
||||
else
|
||||
puts CLIHelper.green('Provision successfully created')
|
||||
|
@ -148,8 +148,6 @@ module OneProvision
|
||||
#
|
||||
# @return [Provider]
|
||||
def self.by_name(client, provider)
|
||||
return Provider.new_with_id(-1) if provider == 'dummy'
|
||||
|
||||
if provider.to_s.match(/^[0123456789]+$/)
|
||||
provider = Provider.new_with_id(Integer(provider), client)
|
||||
rc = provider.info(true)
|
||||
|
@ -30,6 +30,8 @@ module OneProvision
|
||||
end
|
||||
|
||||
def deploy(_)
|
||||
OneProvisionLogger.info('(Deploy skipped)')
|
||||
|
||||
[@hosts.map do |h|
|
||||
h.to_hash['HOST']['TEMPLATE']['PROVISION']['HOSTNAME']
|
||||
end,
|
||||
@ -51,12 +53,34 @@ module OneProvision
|
||||
# @return [Array]
|
||||
# - Terraform state in base64
|
||||
# - Terraform config in base64
|
||||
def destroy(_ = nil) end
|
||||
def destroy(_ = nil)
|
||||
OneProvisionLogger.info('(Destroy skipped)')
|
||||
end
|
||||
|
||||
# Destroys a host
|
||||
#
|
||||
# @param host [String] Host ID
|
||||
def destroy_host(_) end
|
||||
def destroy_host(_)
|
||||
OneProvisionLogger.info('(Destroy host skipped)')
|
||||
end
|
||||
|
||||
def destroy_cluster(_)
|
||||
OneProvisionLogger.info('(Destroy cluster skipped)')
|
||||
end
|
||||
|
||||
# Destroys a datastore
|
||||
#
|
||||
# @param id [String] Datastore ID
|
||||
def destroy_datastore(_)
|
||||
OneProvisionLogger.info('(Destroy datastore skipped)')
|
||||
end
|
||||
|
||||
# Destriys a network
|
||||
#
|
||||
# @param id [String] Network ID
|
||||
def destroy_network(_)
|
||||
OneProvisionLogger.info('(Destroy network skipped)')
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
@ -46,7 +46,7 @@ module OneProvision
|
||||
class Terraform
|
||||
|
||||
# Providers that are currently available
|
||||
PROVIDERS = %w[aws packet]
|
||||
PROVIDERS = %w[aws packet dummy]
|
||||
|
||||
# Class constructor
|
||||
#
|
||||
@ -66,13 +66,13 @@ module OneProvision
|
||||
#
|
||||
# @return [Terraform] Terraform provider
|
||||
def self.singleton(provider, tf)
|
||||
return Dummy.new if Integer(provider['ID']) == -1
|
||||
|
||||
case provider.body['provider']
|
||||
when 'packet'
|
||||
tf_class = Packet
|
||||
when 'aws'
|
||||
tf_class = AWS
|
||||
when 'dummy'
|
||||
tf_class = Dummy
|
||||
else
|
||||
raise OneProvisionLoopException,
|
||||
"Unknown provider: #{provider.body['provider']}"
|
||||
@ -91,6 +91,8 @@ module OneProvision
|
||||
keys = Packet::KEYS
|
||||
when 'aws'
|
||||
keys = AWS::KEYS
|
||||
when 'dummy'
|
||||
return true
|
||||
else
|
||||
raise OneProvisionLoopException,
|
||||
"Unknown provider: #{provider['provider']}"
|
||||
|
Loading…
x
Reference in New Issue
Block a user