From: Michal Fojtik <mfoj...@redhat.com> Signed-off-by: Michal fojtik <mfoj...@redhat.com> TrackedAt: http://tracker.deltacloud.org/patch/4f61366999285c2dfbc497bdc0581c8b657d9191 --- server/lib/cimi/collections/address_templates.rb | 8 ++--- server/lib/cimi/collections/addresses.rb | 8 ++--- server/lib/cimi/collections/cloud_entry_point.rb | 2 +- server/lib/cimi/collections/credentials.rb | 4 +-- server/lib/cimi/collections/machine_images.rb | 4 +-- server/lib/cimi/collections/machine_templates.rb | 10 +++--- server/lib/cimi/collections/machines.rb | 36 ++++++++-------------- server/lib/cimi/collections/network_ports.rb | 6 ++-- server/lib/cimi/collections/networks.rb | 4 +-- server/lib/cimi/collections/resource_metadata.rb | 4 +-- server/lib/cimi/collections/system_templates.rb | 10 +++--- server/lib/cimi/collections/systems.rb | 9 +++--- .../lib/cimi/collections/volume_configurations.rb | 8 ++--- server/lib/cimi/collections/volume_images.rb | 6 ++-- server/lib/cimi/collections/volume_templates.rb | 6 ++-- server/lib/cimi/collections/volumes.rb | 4 +-- 16 files changed, 58 insertions(+), 71 deletions(-)
diff --git a/server/lib/cimi/collections/address_templates.rb b/server/lib/cimi/collections/address_templates.rb index 72e167d..99fe745 100644 --- a/server/lib/cimi/collections/address_templates.rb +++ b/server/lib/cimi/collections/address_templates.rb @@ -34,7 +34,7 @@ module CIMI::Collections operation :show do description 'Show a specific AddressTemplate' control do - address_template = CIMI::Model::AddressTemplate.find(params[:id], self) + address_template = AddressTemplate.find(params[:id], self) respond_to do |format| format.xml {address_template.to_xml} format.json {address_template.to_json} @@ -45,8 +45,8 @@ module CIMI::Collections operation :create do description "Create new AddressTemplate" control do - addr_templ = CIMI::Model::AddressTemplateCreate.parse(request.body, request.content_type) - new_address_template = addr_templ.create(self) + addr_templ = AddressTemplateCreate.parse(self) + new_address_template = addr_templ.create headers_for_create new_address_template respond_to do |format| format.json { new_address_template.to_json } @@ -58,7 +58,7 @@ module CIMI::Collections operation :destroy do description "Delete a specified AddressTemplate" control do - CIMI::Model::AddressTemplate.delete!(params[:id], self) + AddressTemplate.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/addresses.rb b/server/lib/cimi/collections/addresses.rb index c34068d..682cce4 100644 --- a/server/lib/cimi/collections/addresses.rb +++ b/server/lib/cimi/collections/addresses.rb @@ -36,7 +36,7 @@ module CIMI::Collections operation :show, :with_capability => :address do description 'Show a specific Address' control do - address = CIMI::Model::Address.find(params[:id], self) + address = Address.find(params[:id], self) respond_to do |format| format.xml {address.to_xml} format.json {address.to_json} @@ -47,8 +47,8 @@ module CIMI::Collections operation :create, :with_capability => :create_address do description "Create a new Address" control do - addr = CIMI::Model::AddressCreate.parse(request.body, request.content_type) - address = addr.create(self) + addr = AddressCreate.parse(self) + address = addr.create respond_to do |format| format.xml { address.to_xml } format.json { address.to_json } @@ -60,7 +60,7 @@ module CIMI::Collections description "Delete a specified Address" param :id, :string, :required control do - CIMI::Model::Address.delete!(params[:id], self) + Address.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/cloud_entry_point.rb b/server/lib/cimi/collections/cloud_entry_point.rb index b1240bc..37b47b2 100644 --- a/server/lib/cimi/collections/cloud_entry_point.rb +++ b/server/lib/cimi/collections/cloud_entry_point.rb @@ -28,7 +28,7 @@ module CIMI::Collections if params[:force_auth] halt 401 unless driver.valid_credentials?(credentials) end - entry_point = CIMI::Model::CloudEntryPoint.create(self) + entry_point = CIMI::Service::CloudEntryPoint.create(self) respond_to do |format| format.xml { entry_point.to_xml } format.json { entry_point.to_json } diff --git a/server/lib/cimi/collections/credentials.rb b/server/lib/cimi/collections/credentials.rb index 8d90be6..0cd44b9 100644 --- a/server/lib/cimi/collections/credentials.rb +++ b/server/lib/cimi/collections/credentials.rb @@ -46,8 +46,8 @@ module CIMI::Collections operation :create, :with_capability => :create_key do description "Show specific machine admin" control do - c = CIMI::Model::CredentialCreate.parse(request.body, request.content_type) - new_admin = c.create(self) + c = CredentialCreate.parse(self) + new_admin = c.create headers_for_create new_admin respond_to do |format| format.json { new_admin.to_json } diff --git a/server/lib/cimi/collections/machine_images.rb b/server/lib/cimi/collections/machine_images.rb index ce9fa6a..66c74c2 100644 --- a/server/lib/cimi/collections/machine_images.rb +++ b/server/lib/cimi/collections/machine_images.rb @@ -46,8 +46,8 @@ module CIMI::Collections operation :create, :with_capability => :create_image do description "Create a new machine image." control do - mi = MachineImageCreate.parse(request.body, request.content_type) - machine_image = mi.create(self) + mi = MachineImageCreate.parse(self) + machine_image = mi.create headers_for_create machine_image respond_to do |format| format.xml { machine_image.to_xml } diff --git a/server/lib/cimi/collections/machine_templates.rb b/server/lib/cimi/collections/machine_templates.rb index 6bdd1f2..fcdafcc 100644 --- a/server/lib/cimi/collections/machine_templates.rb +++ b/server/lib/cimi/collections/machine_templates.rb @@ -23,7 +23,7 @@ module CIMI::Collections operation :index do description "List all machine templates" control do - machine_templates = CIMI::Model::MachineTemplate.list(self).select_by(params['$select']) + machine_templates = MachineTemplate.list(self) respond_to do |format| format.xml { machine_templates.to_xml } format.json { machine_templates.to_json } @@ -34,7 +34,7 @@ module CIMI::Collections operation :show do description "Show specific machine template" control do - machine_template = CIMI::Model::MachineTemplate.find(params[:id], self) + machine_template = MachineTemplate.find(params[:id], self) respond_to do |format| format.xml { machine_template.to_xml } format.json { machine_template.to_json } @@ -45,8 +45,8 @@ module CIMI::Collections operation :create do description "Create new machine template" control do - mt = CIMI::Model::MachineTemplateCreate.parse(request.body, request.content_type) - new_machine_template = mt.create(self) + mt = MachineTemplateCreate.parse(self) + new_machine_template = mt.create headers_for_create new_machine_template respond_to do |format| format.json { new_machine_template.to_json } @@ -58,7 +58,7 @@ module CIMI::Collections operation :destroy do description "Delete a specified machine template" control do - CIMI::Model::MachineTemplate.delete!(params[:id], self) + MachineTemplate.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/machines.rb b/server/lib/cimi/collections/machines.rb index f3cb62a..f74b02b 100644 --- a/server/lib/cimi/collections/machines.rb +++ b/server/lib/cimi/collections/machines.rb @@ -46,8 +46,8 @@ module CIMI::Collections operation :create, :with_capability => :create_instance do description "Create a new Machine entity." control do - mc = MachineCreate.parse(request.body, request.content_type) - new_machine = mc.create(self) + mc = MachineCreate.parse(self) + new_machine = mc.create headers_for_create new_machine respond_to do |format| format.json { new_machine.to_json } @@ -69,12 +69,8 @@ module CIMI::Collections param :id, :string, :required control do machine = Machine.find(params[:id], self) - if current_content_type == :json - action = Action.from_json(request.body.read) - else - action = Action.from_xml(request.body.read) - end - machine.perform(action, self) do |operation| + action = Action.parse(self) + machine.perform(action) do |operation| no_content_with_status(202) if operation.success? # Handle errors using operation.failure? end @@ -86,12 +82,8 @@ module CIMI::Collections param :id, :string, :required control do machine = Machine.find(params[:id], self) - if current_content_type == :json - action = Action.from_json(request.body.read.gsub("restart", "reboot")) - else - action = Action.from_xml(request.body.read.gsub("restart", "reboot")) - end - machine.perform(action, self) do |operation| + action = Action.parse(self) + machine.perform(action) do |operation| no_content_with_status(202) if operation.success? # Handle errors using operation.failure? end @@ -103,12 +95,8 @@ module CIMI::Collections param :id, :string, :required control do machine = Machine.find(params[:id], self) - if current_content_type == :json - action = Action.from_json(request.body.read) - else - action = Action.from_xml(request.body.read) - end - machine.perform(action, self) do |operation| + action = Action.parse(self) + machine.perform(action) do |operation| no_content_with_status(202) if operation.success? # Handle errors using operation.failure? end @@ -119,7 +107,7 @@ module CIMI::Collections description "Retrieve the Machine's DiskCollection" param :id, :string, :required control do - disks = CIMI::Model::Disk.collection_for_instance(params[:id], self) + disks = Disk.collection_for_instance(params[:id], self) respond_to do |format| format.json {disks.to_json} format.xml {disks.to_xml} @@ -133,7 +121,7 @@ module CIMI::Collections operation :index, :with_capability => :storage_volumes do description "Retrieve the Machine's MachineVolumeCollection" control do - volumes = CIMI::Model::MachineVolume.collection_for_instance(params[:id], self) + volumes = MachineVolume.collection_for_instance(params[:id], self) respond_to do |format| format.json {volumes.to_json} format.xml {volumes.to_xml} @@ -144,7 +132,7 @@ module CIMI::Collections operation :show, :with_capability => :storage_volumes do description "Retrieve a Machine's specific MachineVolume" control do - volume = CIMI::Model::MachineVolume.find(params[:id], self, params[:vol_id]) + volume = MachineVolume.find(params[:id], self, params[:vol_id]) respond_to do |format| format.json {volume.to_json} format.xml {volume.to_xml} @@ -155,7 +143,7 @@ module CIMI::Collections operation :destroy, :with_capability => :detach_storage_volume do description "Remove/detach a volume from the Machine's MachineVolumeCollection" control do - machine_volume = CIMI::Model::MachineVolume.find(params[:id], self, params[:vol_id]) + machine_volume = MachineVolume.find(params[:id], self, params[:vol_id]) location = machine_volume.initial_location machine_volumes = Machine.detach_volume(params[:vol_id], location, self) respond_to do |format| diff --git a/server/lib/cimi/collections/network_ports.rb b/server/lib/cimi/collections/network_ports.rb index 28c2df4..021ae7b 100644 --- a/server/lib/cimi/collections/network_ports.rb +++ b/server/lib/cimi/collections/network_ports.rb @@ -48,9 +48,9 @@ module CIMI::Collections description "Create a new NetworkPort" control do if current_content_type == :json - network_port = CIMI::Model::NetworkPort.create(request.body.read, self, :json) + network_port = NetworkPort.create(request.body.read, self, :json) else - network_port = CIMI::Model::NetworkPort.create(request.body.read, self, :xml) + network_port = NetworkPort.create(request.body.read, self, :xml) end respond_to do |format| format.xml { network_port.to_xml } @@ -62,7 +62,7 @@ module CIMI::Collections operation :destroy, :with_capability => :delete_network_port do description "Delete a specified NetworkPort" control do - CIMI::Model::NetworkPort.delete!(params[:id], self) + NetworkPort.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/networks.rb b/server/lib/cimi/collections/networks.rb index 0f32827..f3d6fc9 100644 --- a/server/lib/cimi/collections/networks.rb +++ b/server/lib/cimi/collections/networks.rb @@ -46,8 +46,8 @@ module CIMI::Collections operation :create, :with_capability => :create_network do description "Create a new Network" control do - n = CIMI::Model::NetworkCreate.parse(request.body, request.content_type) - network = n.create(self) + n = NetworkCreate.parse(self) + network = n.create respond_to do |format| format.xml { network.to_xml} format.json { network.to_json } diff --git a/server/lib/cimi/collections/resource_metadata.rb b/server/lib/cimi/collections/resource_metadata.rb index 54de02a..f27ee33 100644 --- a/server/lib/cimi/collections/resource_metadata.rb +++ b/server/lib/cimi/collections/resource_metadata.rb @@ -21,7 +21,7 @@ module CIMI::Collections operation :index do description "List all resource metadata defined for this provider" control do - resource_metadata = CIMI::Model::ResourceMetadata.list(self) + resource_metadata = CIMI::Service::ResourceMetadata.list(self) respond_to do |format| format.xml{resource_metadata.to_xml} format.json{resource_metadata.to_json} @@ -32,7 +32,7 @@ module CIMI::Collections operation :show do description "Get the resource metadata for a specific collection" control do - resource_metadata = CIMI::Model::ResourceMetadata.find(params[:id], self) + resource_metadata = CIMI::Service::ResourceMetadata.find(params[:id], self) respond_to do |format| format.xml{resource_metadata.to_xml} format.json{resource_metadata.to_json} diff --git a/server/lib/cimi/collections/system_templates.rb b/server/lib/cimi/collections/system_templates.rb index 7ab0d3e..fe27cd3 100644 --- a/server/lib/cimi/collections/system_templates.rb +++ b/server/lib/cimi/collections/system_templates.rb @@ -23,7 +23,7 @@ module CIMI::Collections operation :index, :with_capability => :system_templates do description "List all system templates" control do - system_templates = CIMI::Model::SystemTemplate.list(self).select_by(params['$select']) + system_templates = SystemTemplate.list(self).select_by(params['$select']) respond_to do |format| format.xml { system_templates.to_xml } format.json { system_templates.to_json } @@ -34,7 +34,7 @@ module CIMI::Collections operation :show, :with_capability => :system_templates do description "Show specific system template" control do - system_template = CIMI::Model::SystemTemplate.find(params[:id], self) + system_template = SystemTemplate.find(params[:id], self) respond_to do |format| format.xml { system_template.to_xml } format.json { system_template.to_json } @@ -46,9 +46,9 @@ module CIMI::Collections description "Create new system template" control do if grab_content_type(request.content_type, request.body) == :json - new_system_template = CIMI::Model::SystemTemplate.create_from_json(request.body.read, self) + new_system_template = SystemTemplate.create_from_json(request.body.read, self) else - new_system_template = CIMI::Model::SystemTemplate.create_from_xml(request.body.read, self) + new_system_template = SystemTemplate.create_from_xml(request.body.read, self) end headers_for_create new_system_template respond_to do |format| @@ -61,7 +61,7 @@ module CIMI::Collections operation :destroy, :with_capability => :destroy_system_template do description "Delete a specified system template" control do - CIMI::Model::SystemTemplate.delete!(params[:id], self) + SystemTemplate.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/systems.rb b/server/lib/cimi/collections/systems.rb index ded0aa6..a6adb8d 100644 --- a/server/lib/cimi/collections/systems.rb +++ b/server/lib/cimi/collections/systems.rb @@ -72,8 +72,7 @@ module CIMI::Collections param :id, :string, :required control do system = System.find(params[:id], self) - action = Action.parse(request.body, - request.content_type) + action = Action.parse(self) system.perform(action, self) do |operation| no_content_with_status(202) if operation.success? # Handle errors using operation.failure? @@ -155,7 +154,7 @@ module CIMI::Collections operation :index, :with_capability => :storage_volumes do description "Retrieve the System's SystemVolumeCollection" control do - volumes = CIMI::Model::SystemVolume.collection_for_system(params[:id], self) + volumes = SystemVolume.collection_for_system(params[:id], self) respond_to do |format| format.json {volumes.to_json} format.xml {volumes.to_xml} @@ -166,7 +165,7 @@ module CIMI::Collections operation :show, :with_capability => :storage_volumes do description "Retrieve a System's specific SystemVolume" control do - volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id]) + volume = SystemVolume.find(params[:id], self, params[:vol_id]) respond_to do |format| format.json {volume.to_json} format.xml {volume.to_xml} @@ -177,7 +176,7 @@ module CIMI::Collections operation :destroy, :with_capability => :detach_storage_volume do description "Remove/detach a volume from the System's SystemVolumeCollection" control do - system_volume = CIMI::Model::SystemVolume.find(params[:id], self, params[:vol_id]) + system_volume = SystemVolume.find(params[:id], self, params[:vol_id]) location = system_volume.initial_location system_volumes = System.detach_volume(params[:vol_id], location, self) respond_to do |format| diff --git a/server/lib/cimi/collections/volume_configurations.rb b/server/lib/cimi/collections/volume_configurations.rb index 0a33794..45a9d47 100644 --- a/server/lib/cimi/collections/volume_configurations.rb +++ b/server/lib/cimi/collections/volume_configurations.rb @@ -23,7 +23,7 @@ module CIMI::Collections operation :index, :with_capability => :storage_volumes do description "Get list all VolumeConfigurations" control do - volume_configuration = VolumeConfiguration.list(self).select_by(params['$select']) + volume_configuration = VolumeConfiguration.list(self) respond_to do |format| format.xml { volume_configuration.to_xml } format.json { volume_configuration.to_json } @@ -46,9 +46,9 @@ module CIMI::Collections description "Create new VolumeConfiguration" control do if current_content_type == :json - new_config = CIMI::Model::VolumeConfiguration.create_from_json(request.body.read, self) + new_config = VolumeConfiguration.create_from_json(request.body.read, self) else - new_config = CIMI::Model::VolumeConfiguration.create_from_xml(request.body.read, self) + new_config = VolumeConfiguration.create_from_xml(request.body.read, self) end headers_for_create new_config respond_to do |format| @@ -61,7 +61,7 @@ module CIMI::Collections operation :destroy, :with_capability => :destroy_storage_volume do description "Delete a specified VolumeConfiguration" control do - CIMI::Model::VolumeConfiguration.delete!(params[:id], self) + VolumeConfiguration.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/volume_images.rb b/server/lib/cimi/collections/volume_images.rb index 1596e2d..b9970b4 100644 --- a/server/lib/cimi/collections/volume_images.rb +++ b/server/lib/cimi/collections/volume_images.rb @@ -46,8 +46,8 @@ module CIMI::Collections operation :create, :with_capability => :create_storage_snapshot do description "Create a new volume image." control do - img = CIMI::Model::VolumeImageCreate.parse(request.body, request.content_type) - volume_image = img.create(self) + img = VolumeImageCreate.parse(self) + volume_image = img.create headers_for_create volume_image respond_to do |format| format.xml { volume_image.to_xml } @@ -59,7 +59,7 @@ module CIMI::Collections operation :destroy, :with_capability => :destroy_storage_snapshot do description "Delete a specified VolumeImage" control do - CIMI::Model::VolumeImage.delete!(params[:id], self) + VolumeImage.delete!(params[:id], self) no_content_with_status 200 end end diff --git a/server/lib/cimi/collections/volume_templates.rb b/server/lib/cimi/collections/volume_templates.rb index b844ed8..556fe96 100644 --- a/server/lib/cimi/collections/volume_templates.rb +++ b/server/lib/cimi/collections/volume_templates.rb @@ -46,8 +46,8 @@ module CIMI::Collections description "Create new VolumeTemplate" control do puts request.body - vol = CIMI::Model::VolumeTemplateCreate.parse(request.body, request.content_type) - new_template = vol.create(self) + vol = VolumeTemplateCreate.parse(self) + new_template = vol.create headers_for_create new_template respond_to do |format| format.json { new_template.to_json } @@ -59,7 +59,7 @@ module CIMI::Collections operation :destroy, :with_capability => :destroy_storage_volume do description "Delete a specified VolumeTemplate" control do - CIMI::Model::VolumeTemplate.delete!(params[:id], self) + VolumeTemplate.delete!(params[:id], self) no_content_with_status(200) end end diff --git a/server/lib/cimi/collections/volumes.rb b/server/lib/cimi/collections/volumes.rb index 3f46591..49a58b3 100644 --- a/server/lib/cimi/collections/volumes.rb +++ b/server/lib/cimi/collections/volumes.rb @@ -49,8 +49,8 @@ module CIMI::Collections operation :create, :with_capability => :create_storage_volume do description "Create a new Volume." control do - vol = CIMI::Model::VolumeCreate.parse(request.body, request.content_type) - new_volume = vol.create(self) + vol = VolumeCreate.parse(self) + new_volume = vol.create headers_for_create new_volume respond_to do |format| format.json { new_volume.to_json } -- 1.8.1.4