mirror of
https://github.com/OpenNebula/one.git
synced 2026-12-02 13:16:48 +09: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:
1 parent
b5f4f81f1e
commit
fc577f8cbb
4 files changed
+33
-5
No files matched your search
@@ -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
|
||||
|
||||
Reference in new issue
Block a user