mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-20 10:50:08 +03:00
F #5218: Provision fixes
- Remove provision tag from provision templates - Support to add existing datastores to a provision - By default, datastore 0 is added to a provision - Sanity checks for nil class
This commit is contained in:
parent
31eead1210
commit
ef333bc870
@ -21,7 +21,6 @@
|
||||
# ------------------------------------------------------------------------------
|
||||
|
||||
name: "aws-cluster"
|
||||
provision: "hybrid+"
|
||||
|
||||
extends:
|
||||
- common.d/defaults.yml
|
||||
@ -69,5 +68,7 @@ cluster:
|
||||
description: 'AWS cluster'
|
||||
reserved_cpu: '0'
|
||||
reserved_mem: '0'
|
||||
datastores:
|
||||
- 0
|
||||
provision:
|
||||
cidr: '10.0.0.0/16'
|
||||
|
@ -22,8 +22,6 @@
|
||||
|
||||
name: "packet-cluster"
|
||||
|
||||
provision: 'hybrid+'
|
||||
|
||||
extends:
|
||||
- common.d/defaults.yml
|
||||
- common.d/resources.yml
|
||||
@ -67,5 +65,7 @@ defaults:
|
||||
cluster:
|
||||
name: "${provision}"
|
||||
description: 'Packet cluster'
|
||||
datastores:
|
||||
- 0
|
||||
reserved_cpu: '0'
|
||||
reserved_mem: '0'
|
||||
|
@ -112,16 +112,19 @@ module OneProvision
|
||||
|
||||
# Get cluster information
|
||||
def cluster
|
||||
return nil unless infrastructure_objects
|
||||
infrastructure_objects['clusters'][0]
|
||||
end
|
||||
|
||||
# Returns provision hosts
|
||||
def hosts
|
||||
return nil unless infrastructure_objects
|
||||
infrastructure_objects['hosts']
|
||||
end
|
||||
|
||||
# Returns provision datastores
|
||||
def datastores
|
||||
return nil unless infrastructure_objects
|
||||
infrastructure_objects['datastores']
|
||||
end
|
||||
|
||||
@ -533,12 +536,20 @@ module OneProvision
|
||||
|
||||
OneProvisionLogger.debug(msg)
|
||||
|
||||
datastores = cfg['cluster'].delete("datastores")
|
||||
|
||||
obj = Cluster.new(nil, cfg['cluster'])
|
||||
|
||||
obj.evaluate_rules(self)
|
||||
|
||||
id = obj.create
|
||||
|
||||
datastores.each do |i|
|
||||
|
||||
obj.adddatastore(i)
|
||||
|
||||
end if datastores
|
||||
|
||||
infrastructure_objects['clusters'] = []
|
||||
infrastructure_objects['clusters'] << { 'id' => id,
|
||||
'name' => obj.one['NAME'] }
|
||||
@ -561,8 +572,9 @@ module OneProvision
|
||||
cfg[r].each do |x|
|
||||
Driver.retry_loop('Failed to create some resources',
|
||||
self) do
|
||||
x['provision']['id'] = @id
|
||||
obj = Resource.object(r, nil, x)
|
||||
|
||||
x['provision'] = {'id' => @id }
|
||||
obj = Resource.object(r, nil, x)
|
||||
|
||||
next if obj.nil?
|
||||
|
||||
@ -877,6 +889,8 @@ module OneProvision
|
||||
# @param resources [Array] Resources names
|
||||
# @param objects [Array] Objects information to delete
|
||||
def delete_objects(resources, objects)
|
||||
return unless objects
|
||||
|
||||
resources.each do |resource|
|
||||
next unless objects[resource]
|
||||
|
||||
|
@ -57,6 +57,14 @@ module OneProvision
|
||||
@one.info(true)
|
||||
end
|
||||
|
||||
# Add datastore to cluster (this method needs to be called after info
|
||||
# or create)
|
||||
#
|
||||
# @param id [Integer] datastore ID
|
||||
def adddatastore(id)
|
||||
@one.adddatastore(id)
|
||||
end
|
||||
|
||||
# Deletes the cluster
|
||||
#
|
||||
# @param tf [Hash] Terraform :conf and :state
|
||||
@ -70,6 +78,11 @@ module OneProvision
|
||||
state, conf = terraform.destroy_cluster(@one.id)
|
||||
end
|
||||
|
||||
# Remove non-provision elements added to the cluster
|
||||
@one.datastore_ids.each { |i| @one.deldatastore(i) }
|
||||
@one.vnet_ids.each { |i| @one.delvnet(i) }
|
||||
@one.host_ids.each { |i| @one.delhost(i) }
|
||||
|
||||
Utils.exception(@one.delete)
|
||||
|
||||
if state && conf
|
||||
|
Loading…
x
Reference in New Issue
Block a user