diff --git a/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb b/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb index a8dbc44635..cf6abc6727 100644 --- a/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ClusterJSON.rb @@ -20,13 +20,13 @@ module OpenNebulaJSON class ClusterJSON < OpenNebula::Cluster include JSONUtils - def allocate(template_json) + def create(template_json) cluster_hash = parse_json(template_json,'cluster') if OpenNebula.is_error?(cluster_hash) return cluster_hash end - super(cluster_hash['name']) + self.allocate(cluster_hash['name']) end def perform_action(template_json) diff --git a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb index 33f8962f6a..a6086ab99e 100644 --- a/src/sunstone/models/OpenNebulaJSON/HostJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/HostJSON.rb @@ -20,14 +20,16 @@ module OpenNebulaJSON class HostJSON < OpenNebula::Host include JSONUtils - def allocate(template_json) + def create(template_json) host_hash = parse_json(template_json, 'host') if OpenNebula.is_error?(host_hash) return host_hash end - super(host_hash['name'], host_hash['im_mad'], host_hash['vm_mad'], - host_hash['tm_mad']) + self.allocate(host_hash['name'], + host_hash['im_mad'], + host_hash['vm_mad'], + host_hash['tm_mad']) end def delete diff --git a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb index 36ddb98790..13c1230de2 100644 --- a/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/ImageJSON.rb @@ -20,18 +20,19 @@ module OpenNebulaJSON class ImageJSON < OpenNebula::Image include JSONUtils - def allocate(template_json) + def create(template_json) image_hash = parse_json(template_json, 'image') if OpenNebula.is_error?(image_hash) return image_hash end if image_hash['image_raw'] - super(image_hash['image_raw']) + template = image_hash['image_raw'] else template = template_to_str(image_hash) - super(template) end + + OpenNebula::ImageRepository.new.create(self, template) end def perform_action(template_json) diff --git a/src/sunstone/models/OpenNebulaJSON/UserJSON.rb b/src/sunstone/models/OpenNebulaJSON/UserJSON.rb index 1a17e93a6d..3f53ec537f 100644 --- a/src/sunstone/models/OpenNebulaJSON/UserJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/UserJSON.rb @@ -20,14 +20,14 @@ module OpenNebulaJSON class UserJSON < OpenNebula::User include JSONUtils - def allocate(template_json) + def create(template_json) user_hash = parse_json(template_json, 'user') if OpenNebula.is_error?(user_hash) return user_hash end password = Digest::SHA1.hexdigest(user_hash['password']) - super(user_hash['name'], password) + self.allocate(user_hash['name'], password) end def perform_action(template_json) diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb index 92d152a9e9..a548c159b0 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualMachineJSON.rb @@ -20,18 +20,19 @@ module OpenNebulaJSON class VirtualMachineJSON < OpenNebula::VirtualMachine include JSONUtils - def allocate(template_json) + def create(template_json) vm_hash = parse_json(template_json, 'vm') if OpenNebula.is_error?(vm_hash) return vm_hash end if vm_hash['vm_raw'] - super(vm_hash['vm_raw']) + template = vm_hash['vm_raw'] else template = template_to_str(vm_hash) - super(template) end + + self.allocate(template) end def perform_action(template_json) diff --git a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb index b4e7503dbb..16f715eb6f 100644 --- a/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb +++ b/src/sunstone/models/OpenNebulaJSON/VirtualNetworkJSON.rb @@ -20,18 +20,19 @@ module OpenNebulaJSON class VirtualNetworkJSON < OpenNebula::VirtualNetwork include JSONUtils - def allocate(template_json) + def create(template_json) vnet_hash = parse_json(template_json, 'vnet') if OpenNebula.is_error?(vnet_hash) return vnet_hash end if vnet_hash['vnet_raw'] - super(vnet_hash['vnet_raw']) + template = vnet_hash['vnet_raw'] else template = template_to_str(vnet_hash) - super(template) end + + self.allocate(template) end def perform_action(template_json) diff --git a/src/sunstone/models/SunstoneServer.rb b/src/sunstone/models/SunstoneServer.rb index dd02e88264..ea690c33a9 100644 --- a/src/sunstone/models/SunstoneServer.rb +++ b/src/sunstone/models/SunstoneServer.rb @@ -115,7 +115,7 @@ class SunstoneServer return [404, error.to_json] end - rc = resource.allocate(template) + rc = resource.create(template) if OpenNebula.is_error?(rc) return [500, rc.to_json] else