You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltacloud.apache.org by mf...@apache.org on 2012/05/22 22:19:38 UTC
[43/50] [abbrv] CIMI: Moved code from CIMI server.rb and split it to
smaller collections like in Deltacloud
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/entity_metadata.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/entity_metadata.rb b/server/lib/cimi/model/entity_metadata.rb
deleted file mode 100644
index bc20ff3..0000000
--- a/server/lib/cimi/model/entity_metadata.rb
+++ /dev/null
@@ -1,83 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-
-class CIMI::Model::EntityMetadata < CIMI::Model::Base
-
-text :type_uri
-
- array :attributes do
- scalar :name
- scalar :namespace
- scalar :type
- scalar :required
- scalar :constraints
- end
-
- array :operations do
- scalar :name
- scalar :uri
- scalar :description
- scalar :method
- scalar :input_message
- scalar :output_message
- end
-
- def self.find(id, context)
- entity_metadata = []
- if id == :all
- CIMI::Model.root_entities.each do |entity|
- entity_class = CIMI::Model.const_get("#{entity.singularize}")
- entity_metadata << entity_class.create_entity_metadata(context) if entity_class.respond_to?(:create_entity_metadata)
- end
- return entity_metadata
- else
- entity_class = CIMI::Model.const_get("#{id.camelize}")
- if entity_class.respond_to?(:create_entity_metadata)
- entity_class.create_entity_metadata(context)
- end
- end
- end
-
- def self.metadata_from_deltacloud_features(cimi_entity, dcloud_entity, context)
- deltacloud_features = context.driver.features(dcloud_entity)
- metadata_attributes = deltacloud_features.map{|f| attributes_from_feature(f)}
- from_feature(cimi_entity, context, metadata_attributes.flatten!)
- end
-
- def includes_attribute?(attribute)
- self.attributes.any?{|attr| attr[:name] == attribute}
- end
-
- private
-
- def self.attributes_from_feature(feature)
- feature.operations.first.params.inject([]) do |result, param|
- result << {
- :name=>(feature.name == :user_name ? :name : param[0]),
- :type=> "xs:string",
- :required=> (param[1] and param[1].optional?) ? "false" : "true",
- :constraints=> (feature.constraints.empty? ? (feature.description.nil? ? "" : feature.description): feature.constraints)
- }
- end
- end
-
- def self.from_feature(cimi_entity, context, metadata_attributes)
- self.new(:name => cimi_entity, :uri=>"#{context.entity_metadata_url}/#{cimi_entity.underscore}",
- :type_uri=> context.send("#{cimi_entity.pluralize.underscore}_url"),
- :attributes => metadata_attributes)
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/entity_metadata_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/entity_metadata_collection.rb b/server/lib/cimi/model/entity_metadata_collection.rb
deleted file mode 100644
index 63db7f7..0000000
--- a/server/lib/cimi/model/entity_metadata_collection.rb
+++ /dev/null
@@ -1,31 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::EntityMetadataCollection < CIMI::Model::Base
-
- array :entity_metadata do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.entity_metadata_url,
- :name => 'default',
- :created => Time.now,
- :entity_metadata => EntityMetadata.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/errors.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/errors.rb b/server/lib/cimi/model/errors.rb
deleted file mode 100644
index 7c090ed..0000000
--- a/server/lib/cimi/model/errors.rb
+++ /dev/null
@@ -1,48 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-module CIMI::Model
-
- class NotFound < StandardError
- attr_accessor :code
-
- def initialize
- super("Requested Entity Not Found")
- self.code = 404
- end
-
- end
-
- class BadRequest < StandardError
- attr_accessor :code
- def initialize(msg="")
- super(msg)
- self.code=400
- end
- end
-
- class NotImplemented < StandardError
- attr_accessor :code
-
- def initialize
- super("Requested operation is not implemented by backend provider")
- self.code = 501
- end
-
- end
-
-end
-
-
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine.rb b/server/lib/cimi/model/machine.rb
deleted file mode 100644
index 939629a..0000000
--- a/server/lib/cimi/model/machine.rb
+++ /dev/null
@@ -1,229 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-require 'deltacloud/models/instance_address'
-
-class CIMI::Model::Machine < CIMI::Model::Base
-
- text :state
- text :cpu
-
- struct :memory do
- scalar :quantity
- scalar :units
- end
-
- href :event_log
-
- array :disks do
- struct :capacity do
- scalar :quantity
- scalar :units
- end
- scalar :format
- scalar :attachment_point
- end
-
- array :volumes do
- scalar :href
- scalar :protocol
- scalar :attachment_point
- end
-
- array :network_interfaces do
- href :vsp
- text :hostname, :mac_address, :state, :protocol, :allocation
- text :address, :default_gateway, :dns, :max_transmission_unit
- end
-
- array :meters do
- scalar :href
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- instances = []
- if id == :all
- instances = context.driver.instances(context.credentials)
- instances.map { |instance| from_instance(instance, context) }.compact
- else
- instance = context.driver.instance(context.credentials, :id => id)
- raise CIMI::Model::NotFound unless instance
- from_instance(instance, context)
- end
- end
-
- def self.create_from_json(body, context)
- json = JSON.parse(body)
- hardware_profile_id = xml['machineTemplate']['machineConfig']["href"].split('/').last
- image_id = xml['machineTemplate']['machineImage']["href"].split('/').last
- instance = context.create_instance(context.credentials, image_id, { :hwp_id => hardware_profile_id })
- from_instance(instance, context)
- end
-
- def self.create_from_xml(body, context)
- xml = XmlSimple.xml_in(body)
- machine_template = xml['machineTemplate'][0]
- hardware_profile_id = machine_template['machineConfig'][0]["href"].split('/').last
- image_id = machine_template['machineImage'][0]["href"].split('/').last
- additional_params = {}
- additional_params[:name] =xml['name'][0] if xml['name']
- if machine_template.has_key? 'machineAdmin'
- additional_params[:keyname] = machine_template['machineAdmin'][0]["href"].split('/').last
- end
- instance = context.driver.create_instance(context.credentials, image_id, {
- :hwp_id => hardware_profile_id
- }.merge(additional_params))
- from_instance(instance, context)
- end
-
- def perform(action, context, &block)
- begin
- if context.driver.send(:"#{action.name}_instance", context.credentials, self.name)
- block.callback :success
- else
- raise "Operation failed to execute on given Machine"
- end
- rescue => e
- block.callback :failure, e.message
- end
- end
-
- def self.delete!(id, context)
- context.driver.destroy_instance(context.credentials, id)
- end
-
- def self.create_entity_metadata(context)
- cimi_entity = self.name.split("::").last
- metadata = EntityMetadata.metadata_from_deltacloud_features(cimi_entity, :instances, context)
- unless metadata.includes_attribute?(:name)
- metadata.attributes << {:name=>"name", :required=>"false",
- :constraints=>"Determined by the cloud provider", :type=>"xs:string"}
- end
- metadata
- end
-
- def self.attach_volumes(volumes, context)
- volumes.each do |vol|
- context.driver.attach_storage_volume(context.credentials,
- {:id=>vol[:volume].name, :instance_id=>context.params[:id], :device=>vol[:attachment_point]})
- end
- self.find(context.params[:id], context)
- end
-
- def self.detach_volumes(volumes, context)
- volumes.each do |vol|
- context.driver.detach_storage_volume(context.credentials, {:id=>vol[:volume].name, :instance_id => context.params[:id]})
- end
- self.find(context.params[:id], context)
- end
-
- private
-
- def self.from_instance(instance, context)
- cpu = memory = disks = (instance.instance_profile.id == "opaque")? "n/a" : nil
- self.new(
- :name => instance.id,
- :description => instance.name,
- :created => instance.launch_time,
- :id => context.machine_url(instance.id),
- :state => convert_instance_state(instance.state),
- :cpu => cpu || convert_instance_cpu(instance.instance_profile, context),
- :memory => memory || convert_instance_memory(instance.instance_profile, context),
- :disks => disks || convert_instance_storage(instance.instance_profile, context),
- :network_interfaces => convert_instance_addresses(instance),
- :operations => convert_instance_actions(instance, context),
- :volumes=>convert_storage_volumes(instance, context),
- :property => convert_instance_properties(instance, context)
- )
- end
-
- # FIXME: This will convert 'RUNNING' state to 'STARTED'
- # which is defined in CIMI (p65)
- #
- def self.convert_instance_state(state)
- ('RUNNING' == state) ? 'STARTED' : state
- end
-
- def self.convert_instance_properties(instance, context)
- properties = []
- properties << { :name => :machine_image, :value => context.machine_image_url(instance.image_id) }
- if instance.respond_to? :keyname
- properties << { :name => :machine_admin, :value => context.machine_admin_url(instance.keyname) }
- end
- properties
- end
-
- def self.convert_instance_cpu(profile, context)
- cpu_override = profile.overrides.find { |p, v| p == :cpu }
- if cpu_override.nil?
- MachineConfiguration.find(profile.id, context).cpu
- else
- cpu_override[1]
- end
- end
-
- def self.convert_instance_memory(profile, context)
- machine_conf = MachineConfiguration.find(profile.name, context)
- memory_override = profile.overrides.find { |p, v| p == :memory }
- {
- :quantity => memory_override.nil? ? machine_conf.memory[:quantity] : memory_override[1],
- :units => machine_conf.memory[:units]
- }
- end
-
- def self.convert_instance_storage(profile, context)
- machine_conf = MachineConfiguration.find(profile.name, context)
- storage_override = profile.overrides.find { |p, v| p == :storage }
- [
- { :capacity => {
- :quantity => storage_override.nil? ? machine_conf.disks.first[:capacity][:quantity] : storage_override[1],
- :units => machine_conf.disks.first[:capacity][:units]
- }
- }
- ]
- end
-
- def self.convert_instance_addresses(instance)
- (instance.public_addresses + instance.private_addresses).collect do |address|
- {
- :hostname => address.is_hostname? ? address : nil,
- :mac_address => address.is_mac? ? address : nil,
- :state => 'Active',
- :protocol => 'IPv4',
- :address => address.is_ipv4? ? address : nil,
- :allocation => 'Static'
- }
- end
- end
-
- def self.convert_instance_actions(instance, context)
- instance.actions.collect do |action|
- action = :destroy if action == :delete # In CIMI destroy operation become delete
- action = :restart if action == :reboot # In CIMI reboot operation become restart
- { :href => context.send(:"#{action}_machine_url", instance.id), :rel => "http://www.dmtf.org/cimi/action/#{action}" }
- end
- end
-
- def self.convert_storage_volumes(instance, context)
- instance.storage_volumes ||= [] #deal with nilpointers
- instance.storage_volumes.map{|vol| {:href=>context.volume_url(vol.keys.first),
- :attachment_point=>vol.values.first} }
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_admin.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_admin.rb b/server/lib/cimi/model/machine_admin.rb
deleted file mode 100644
index fed7c80..0000000
--- a/server/lib/cimi/model/machine_admin.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineAdmin < CIMI::Model::Base
-
- text :username
- text :password
- text :key
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id == :all
- keys = context.driver.keys(context.credentials)
- keys.map { |key| from_key(key, context) }
- else
- key = context.driver.key(context.credentials, :id => id)
- from_key(key, context)
- end
- end
-
- def self.create_from_xml(body, context)
- machine_admin = MachineAdmin.from_xml(body)
- key = context.driver.create_key(context.credentials, :key_name => machine_admin.name)
- from_key(key, context)
- end
-
- def self.delete!(id, context)
- context.driver.destroy_key(context.credentials, :id => id)
- end
-
- private
-
- def self.from_key(key, context)
- self.new(
- :name => key.id,
- :username => key.username,
- :password => key.is_password? ? key.password : key.fingerprint,
- :key => key.is_key? ? key.pem_rsa_key : nil,
- :id => context.machine_admin_url(key.id),
- :created => Time.now
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_admin_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_admin_collection.rb b/server/lib/cimi/model/machine_admin_collection.rb
deleted file mode 100644
index fd76a52..0000000
--- a/server/lib/cimi/model/machine_admin_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineAdminCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_admin
-
- array :machine_admins do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machine_admins_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineAdminCollection",
- :machine_admins => MachineAdmin.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_collection.rb b/server/lib/cimi/model/machine_collection.rb
deleted file mode 100644
index 27aa61b..0000000
--- a/server/lib/cimi/model/machine_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineCollection < CIMI::Model::Base
-
- act_as_root_entity :machine
-
- array :machines do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machines_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineCollection",
- :machines => Machine.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_configuration.rb b/server/lib/cimi/model/machine_configuration.rb
deleted file mode 100644
index f9d98f2..0000000
--- a/server/lib/cimi/model/machine_configuration.rb
+++ /dev/null
@@ -1,70 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineConfiguration < CIMI::Model::Base
-
- struct :memory do
- scalar :quantity
- scalar :units
- end
-
- text :cpu
-
- array :disks do
- struct :capacity do
- scalar :quantity
- scalar :units
- end
- scalar :format
- scalar :attachment_point
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- profiles = []
- if id == :all
- profiles = context.driver.hardware_profiles(context.credentials)
- profiles.map { |profile| from_hardware_profile(profile, context) }.compact
- else
- profile = context.driver.hardware_profile(context.credentials, id)
- from_hardware_profile(profile, context)
- end
- end
-
- private
-
- def self.from_hardware_profile(profile, context)
- # We accept just profiles with all properties set
- return unless profile.memory or profile.cpu or profile.storage
- memory = profile.memory.value || profile.memory.default
- cpu = profile.cpu.value || profile.cpu.default
- storage = profile.storage.value || profile.storage.default
- machine_hash = {
- :name => profile.name,
- :description => "Machine Configuration with #{memory} #{profile.memory.unit} "+
- "of memory and #{cpu} CPU",
- :cpu => cpu,
- :created => Time.now.to_s, # FIXME: DC hardware_profile has no mention about created_at
- :memory => { :quantity => profile.memory.value || profile.memory.default, :units => profile.memory.unit },
- :disks => [ { :capacity => { :quantity => profile.storage.value || profile.storage.default, :units => profile.storage.unit } } ],
- :id => context.machine_configuration_url(profile.name)
- }
- self.new(machine_hash)
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_configuration_collection.rb b/server/lib/cimi/model/machine_configuration_collection.rb
deleted file mode 100644
index 171acac..0000000
--- a/server/lib/cimi/model/machine_configuration_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineConfigurationCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_configuration
-
- array :machine_configurations do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machine_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineConfigurationCollection",
- :machine_configurations => MachineConfiguration.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_image.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_image.rb b/server/lib/cimi/model/machine_image.rb
deleted file mode 100644
index 7389475..0000000
--- a/server/lib/cimi/model/machine_image.rb
+++ /dev/null
@@ -1,46 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineImage < CIMI::Model::Base
-
- href :image_location
- text :image_data
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- images = []
- if id == :all
- images = context.driver.images(context.credentials)
- images.map { |image| from_image(image, context) }
- else
- image = context.driver.image(context.credentials, :id => id)
- from_image(image, context)
- end
- end
-
- def self.from_image(image, context)
- self.new(
- :name => image.id,
- :id => context.machine_image_url(image.id),
- :description => image.description,
- :created => Time.now.to_s,
- :image_location => { :href => "#{context.driver.name}://#{image.id}" } # FIXME
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_image_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_image_collection.rb b/server/lib/cimi/model/machine_image_collection.rb
deleted file mode 100644
index b02ede7..0000000
--- a/server/lib/cimi/model/machine_image_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineImageCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_image
-
- array :machine_images do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machine_images_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineImageCollection",
- :machine_images => MachineImage.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_template.rb b/server/lib/cimi/model/machine_template.rb
deleted file mode 100644
index 8a88052..0000000
--- a/server/lib/cimi/model/machine_template.rb
+++ /dev/null
@@ -1,41 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineTemplate < CIMI::Model::Base
-
- href :machine_config
- href :machine_image
- href :machine_admin
-
- array :volumes do
- scalar :href
- scalar :protocol
- scalar :attachment_point
- end
-
- array :volume_templates do
- scalar :href, :attachment_point, :protocol
- end
-
- array :network_interfaces do
- href :vsp
- text :hostname, :mac_address, :state, :protocol, :allocation
- text :address, :default_gateway, :dns, :max_transmission_unit
- end
-
- array :operations do
- scalar :rel, :href
- end
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/machine_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/machine_template_collection.rb b/server/lib/cimi/model/machine_template_collection.rb
deleted file mode 100644
index e1e8d30..0000000
--- a/server/lib/cimi/model/machine_template_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::MachineTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :machine_template
-
- array :machine_templates do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.machine_template_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} MachineTemplateCollection",
- :machine_templates => MachineTemplate.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network.rb b/server/lib/cimi/model/network.rb
deleted file mode 100644
index cbfbae0..0000000
--- a/server/lib/cimi/model/network.rb
+++ /dev/null
@@ -1,106 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::Network < CIMI::Model::Base
-
- text :state
-
- text :access
-
- text :bandwidth_limit
-
- text :traffic_priority
-
- text :max_traffic_delay
-
- text :max_traffic_loss
-
- text :max_traffic_jitter
-
- href :routing_group
-
- href :event_log
-
- array :meters do
- scalar :href
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- networks=[]
- if id==:all
- networks = context.driver.networks(context.credentials, {:env=>context})
- else
- networks = context.driver.networks(context.credentials, {:id=>id, :env=>context})
- end
- networks
- end
-
- def self.create(request_body, context, type)
- input = (type == :xml)? XmlSimple.xml_in(request_body, {"ForceArray"=>false,"NormaliseSpace"=>2}) : JSON.parse(request_body)
- if input["networkTemplate"]["href"] #template by reference
- network_config, routing_group = get_by_reference(input, context)
- else
- if input["networkTemplate"]["networkConfig"]["href"] # configuration by reference
- network_config = NetworkConfiguration.find(context.href_id(input["networkTemplate"]["networkConfig"]["href"],:network_configurations), context)
- else #configuration by value
- network_config = get_by_value(request_body, type)
- end
- routing_group = RoutingGroup.find(context.href_id(input["networkTemplate"]["routingGroup"]["href"], :routing_groups), context)
- end
- params = {:network_config => network_config, :routing_group => routing_group, :name=>input["name"], :description=>input["description"], :env=>context}
- raise CIMI::Model::BadRequest.new("Bad request - missing required parameters. Client sent: #{request_body} which produced #{params.inspect}") if params.has_value?(nil)
- context.driver.create_network(context.credentials, params)
- end
-
- def self.delete!(id, context)
- context.driver.delete_network(context.credentials, id)
- end
-
- def perform(action, context, &block)
- begin
- if context.driver.send(:"#{action.name}_network", context.credentials, self.name)
- block.callback :success
- else
- raise "Operation #{action.name} failed to execute on the Network #{self.name} "
- end
- rescue => e
- block.callback :failure, e.message
- end
- end
-
- private
-
- def self.get_by_reference(input, context)
- network_template = NetworkTemplate.find(context.href_id(input["networkTemplate"]["href"], :network_templates), context)
- network_config = NetworkConfiguration.find(context.href_id(network_template.network_config.href, :network_configurations), context)
- routing_group = RoutingGroup.find(context.href_id(network_template.routing_group.href, :routing_groups), context)
- return network_config, routing_group
- end
-
- def self.get_by_value(request_body, type)
- if type == :xml
- xml_arrays = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
- network_config = NetworkConfiguration.from_xml(XmlSimple.xml_out(xml_arrays["networkTemplate"][0]["networkConfig"][0]))
- else
- json = JSON.parse(request_body)
- network_config = NetworkConfiguration.from_json(JSON.generate(json["networkTemplate"]["networkConfig"]))
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_collection.rb b/server/lib/cimi/model/network_collection.rb
deleted file mode 100644
index 836d8e8..0000000
--- a/server/lib/cimi/model/network_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::NetworkCollection < CIMI::Model::Base
-
- act_as_root_entity :network
-
- array :networks do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.networks_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkCollection",
- :networks => Network.all(context).map { |c| { :href => c.id } }
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_configuration.rb b/server/lib/cimi/model/network_configuration.rb
deleted file mode 100644
index 1b04548..0000000
--- a/server/lib/cimi/model/network_configuration.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::NetworkConfiguration < CIMI::Model::Base
-
- text :access
-
- text :bandwidth_limit
-
- text :traffic_priority
-
- text :max_traffic_delay
-
- text :max_traffic_loss
-
- text :max_traffic_jitter
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- network_configs = []
- if id==:all
- network_configs = context.driver.network_configurations(context.credentials, {:env=>context})
- else
- network_configs = context.driver.network_configurations(context.credentials, {:env=>context, :id=>id})
- end
- network_configs
- end
-
- def self.create_from_xml(request_body, context)
- end
-
- def self.create_from_json(request_body, context)
- end
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_configuration_collection.rb b/server/lib/cimi/model/network_configuration_collection.rb
deleted file mode 100644
index fd70047..0000000
--- a/server/lib/cimi/model/network_configuration_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::NetworkConfigurationCollection < CIMI::Model::Base
-
- act_as_root_entity :network_configuration
-
- array :network_configurations do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.network_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkConfigurationCollection",
- :network_configurations => NetworkConfiguration.all(context).map { |c| { :href => c.id } }
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_template.rb b/server/lib/cimi/model/network_template.rb
deleted file mode 100644
index ce3b990..0000000
--- a/server/lib/cimi/model/network_template.rb
+++ /dev/null
@@ -1,36 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::NetworkTemplate < CIMI::Model::Base
-
- href :network_config
-
- href :routing_group
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- network_templates = []
- if id==:all
- network_templates = context.driver.network_templates(context.credentials, {:env=>context})
- else
- network_templates = context.driver.network_templates(context.credentials, {:env=>context, :id=>id})
- end
- network_templates
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/network_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/network_template_collection.rb b/server/lib/cimi/model/network_template_collection.rb
deleted file mode 100644
index 6b97b6e..0000000
--- a/server/lib/cimi/model/network_template_collection.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-
-class CIMI::Model::NetworkTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :network_template
-
- array :network_templates do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.network_templates_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} NetworkTemplateCollection",
- :network_templates => NetworkTemplate.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/routing_group.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group.rb b/server/lib/cimi/model/routing_group.rb
deleted file mode 100644
index d26f4d7..0000000
--- a/server/lib/cimi/model/routing_group.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::RoutingGroup < CIMI::Model::Base
-
- array :networks do
- scalar :href
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id==:all
- context.driver.routing_groups(context.credentials, {:env=>context})
- else
- context.driver.routing_groups(context.credentials, {:env=>context, :id=>id})
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/routing_group_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group_collection.rb b/server/lib/cimi/model/routing_group_collection.rb
deleted file mode 100644
index 1546c80..0000000
--- a/server/lib/cimi/model/routing_group_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::RoutingGroupCollection < CIMI::Model::Base
-
- act_as_root_entity :routing_group
-
- array :routing_groups do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.routing_groups_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} RoutingGroupCollection",
- :routing_groups => RoutingGroup.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/routing_group_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group_template.rb b/server/lib/cimi/model/routing_group_template.rb
deleted file mode 100644
index 204a353..0000000
--- a/server/lib/cimi/model/routing_group_template.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::RoutingGroupTemplate < CIMI::Model::Base
-
- array :networks do
- scalar :href
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id==:all
- context.driver.routing_group_templates(context.credentials, {:env=>context})
- else
- context.driver.routing_group_templates(context.credentials, {:env=>context, :id=>id})
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/routing_group_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/routing_group_template_collection.rb b/server/lib/cimi/model/routing_group_template_collection.rb
deleted file mode 100644
index 5e7a9ba..0000000
--- a/server/lib/cimi/model/routing_group_template_collection.rb
+++ /dev/null
@@ -1,35 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-
-class CIMI::Model::RoutingGroupTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :routing_group_template
-
- array :routing_group_templates do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.routing_group_templates_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} RoutingGroupTemplateCollection",
- :routing_group_templates => RoutingGroupTemplate.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/schema.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/schema.rb b/server/lib/cimi/model/schema.rb
deleted file mode 100644
index f301b69..0000000
--- a/server/lib/cimi/model/schema.rb
+++ /dev/null
@@ -1,277 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-#
-
-# The smarts of converting from XML and JSON into internal objects
-class CIMI::Model::Schema
-
- #
- # Attributes describe how we extract values from XML/JSON
- #
- class Attribute
- attr_reader :name, :xml_name, :json_name
-
- def initialize(name, opts = {})
- @name = name
- @xml_name = (opts[:xml_name] || name).to_s.camelize(true)
- @json_name = (opts[:json_name] || name).to_s.camelize(true)
- end
-
- def from_xml(xml, model)
- model[@name] = xml[@xml_name].first if xml.has_key?(@xml_name)
- end
-
- def from_json(json, model)
- model[@name] = json[@json_name]
- end
-
- def to_xml(model, xml)
- xml[@xml_name] = [model[@name]] if model[@name]
- end
-
- def to_json(model, json)
- json[@json_name] = model[@name] if model and model[@name]
- end
- end
-
- class Scalar < Attribute
- def initialize(name, opts)
- @text = opts[:text]
- if ! [nil, :nested, :direct].include?(@text)
- raise "text option for scalar must be :nested or :direct"
- end
- super(name, opts)
- end
-
- def text?; @text; end
-
- def nested_text?; @text == :nested; end
-
- def from_xml(xml, model)
- case @text
- when :nested then model[@name] = xml[@xml_name].first["content"] if xml[@xml_name]
- when :direct then model[@name] = xml["content"]
- else model[@name] = xml[@xml_name]
- end
- end
-
- def to_xml(model, xml)
- return unless model
- return unless model[@name]
- case @text
- when :nested then xml[@xml_name] = [{ "content" => model[@name] }]
- when :direct then xml["content"] = model[@name]
- else xml[@xml_name] = model[@name]
- end
- end
- end
-
- class Struct < Attribute
- def initialize(name, opts, &block)
- content = opts[:content]
- super(name, opts)
- @schema = CIMI::Model::Schema.new
- @schema.instance_eval(&block) if block_given?
- @schema.scalar(content, :text => :direct) if content
- end
-
- def from_xml(xml, model)
- xml = xml.has_key?(xml_name) ? xml[xml_name].first : {}
- model[name] = convert_from_xml(xml)
- end
-
- def from_json(json, model)
- json = json.has_key?(json_name) ? json[json_name] : {}
- model[name] = convert_from_json(json)
- end
-
- def to_xml(model, xml)
- conv = convert_to_xml(model[name])
- xml[xml_name] = [conv] unless conv.empty?
- end
-
- def to_json(model, json)
- conv = convert_to_json(model[name])
- json[json_name] = conv unless conv.empty?
- end
-
- def convert_from_xml(xml)
- sub = struct.new
- @schema.from_xml(xml, sub)
- sub
- end
-
- def convert_from_json(json)
- sub = struct.new
- @schema.from_json(json, sub)
- sub
- end
-
- def convert_to_xml(model)
- xml = {}
- @schema.to_xml(model, xml)
- xml
- end
-
- def convert_to_json(model)
- json = {}
- @schema.to_json(model, json)
- json
- end
-
- private
- def struct
- cname = "CIMI_#{json_name.upcase_first}"
- if ::Struct.const_defined?(cname)
- ::Struct.const_get(cname)
- else
- ::Struct.new("CIMI_#{json_name.upcase_first}",
- *@schema.attribute_names)
- end
- end
- end
-
- class Array < Attribute
- # For an array :things, we collect all <thing/> elements (XmlSimple
- # actually does the collecting)
- def initialize(name, opts = {}, &block)
- opts[:xml_name] = name.to_s.singularize unless opts[:xml_name]
- super(name, opts)
- @struct = Struct.new(name, opts, &block)
- end
-
- def from_xml(xml, model)
- model[name] = (xml[xml_name] || []).map { |elt| @struct.convert_from_xml(elt) }
- end
-
- def from_json(json, model)
- model[name] = (json[json_name] || []).map { |elt| @struct.convert_from_json(elt) }
- end
-
- def to_xml(model, xml)
- ary = (model[name] || []).map { |elt| @struct.convert_to_xml(elt) }
- xml[xml_name] = ary unless ary.empty?
- end
-
- def to_json(model, json)
- ary = (model[name] || []).map { |elt| @struct.convert_to_json(elt) }
- json[json_name] = ary unless ary.empty?
- end
- end
-
- class Hash < Attribute
-
- def initialize(name, opts = {}, &block)
- opts[:json_name] = name.to_s.pluralize unless opts[:json_name]
- super(name, opts)
- @struct = Struct.new(name, opts, &block)
- end
-
- def from_xml(xml, model)
- model[name] = (xml[xml_name] || []).map { |elt| @struct.convert_from_xml(elt) }
- end
-
- def from_json(json, model)
- model[name] = (json[json_name] || {}).inject([]) do |result,item|
- result << @struct.convert_from_json({ 'name' => item[0], 'value' => item[1] })
- end
- end
-
- def to_xml(model, xml)
- ary = (model[name] || []).map { |elt| @struct.convert_to_xml(elt) }
- xml[xml_name] = ary unless ary.empty?
- end
-
- def to_json(model, json)
- ary = (model[name] || []).map { |elt| @struct.convert_to_json(elt) }
- json[json_name] = ary.inject({}) { |result, item| result[item['name']] = item['value']; result } unless ary.empty?
- end
- end
-
- #
- # The actual Schema class
- #
- def initialize
- @attributes = []
- end
-
- def from_xml(xml, model = {})
- @attributes.freeze
- @attributes.each { |attr| attr.from_xml(xml, model) }
- model
- end
-
- def from_json(json, model = {})
- @attributes.freeze
- @attributes.each { |attr| attr.from_json(json, model) }
- model
- end
-
- def to_xml(model, xml = {})
- @attributes.freeze
- @attributes.each { |attr| attr.to_xml(model, xml) }
- xml
- end
-
- def to_json(model, json = {})
- @attributes.freeze
- @attributes.each { |attr| attr.to_json(model, json) }
- json
- end
-
- def attribute_names
- @attributes.map { |a| a.name }
- end
-
- #
- # The DSL
- #
- # Requires that the class into which this is included has a
- # +add_attributes!+ method
- module DSL
- def href(*args)
- args.each { |arg| struct(arg) { scalar :href } }
- end
-
- def text(*args)
- args.expand_opts!(:text => :nested)
- scalar(*args)
- end
-
- def scalar(*args)
- add_attributes!(args, Scalar)
- end
-
- def array(name, opts={}, &block)
- add_attributes!([name, opts], Array, &block)
- end
-
- def struct(name, opts={}, &block)
- add_attributes!([name, opts], Struct, &block)
- end
-
- def hash(name, opts={}, &block)
- add_attributes!([name, opts], Hash, &block)
- end
- end
-
- include DSL
-
- def add_attributes!(args, attr_klass, &block)
- raise "The schema has already been used to convert objects" if @attributes.frozen?
- opts = args.extract_opts!
- args.each { |arg| @attributes << attr_klass.new(arg, opts, &block) }
- end
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume.rb b/server/lib/cimi/model/volume.rb
deleted file mode 100644
index 0a232d5..0000000
--- a/server/lib/cimi/model/volume.rb
+++ /dev/null
@@ -1,103 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::Volume < CIMI::Model::Base
-
- struct :capacity do
- scalar :quantity
- scalar :units
- end
- text :bootable
- text :supports_snapshots
- array :snapshots do
- scalar :ref
- end
- text :guest_interface
- array :meters do
- scalar :ref
- end
- href :eventlog
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- volumes = []
- opts = ( id == :all ) ? {} : { :id => id }
- volumes = self.driver.storage_volumes(context.credentials, opts)
- volumes.collect!{ |volume| from_storage_volume(volume, context) }
- return volumes.first unless volumes.length > 1
- return volumes
- end
-
- def self.all(context); find(:all, context); end
-
- def self.create_from_json(json_in, context)
- json = JSON.parse(json_in)
- volume_config_id = json["volumeTemplate"]["volumeConfig"]["href"].split("/").last
- volume_image_id = (json["volumeTemplate"].has_key?("volumeImage") ?
- json["volumeTemplate"]["volumeImage"]["href"].split("/").last : nil)
- create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
- end
-
- def self.create_from_xml(xml_in, context)
- xml = XmlSimple.xml_in(xml_in)
- volume_config_id = xml["volumeTemplate"][0]["volumeConfig"][0]["href"].split("/").last
- volume_image_id = (xml["volumeTemplate"][0].has_key?("volumeImage") ?
- xml["volumeTemplate"][0]["volumeImage"][0]["href"].split("/").last : nil)
- create_volume({:volume_config_id=>volume_config_id, :volume_image_id=>volume_image_id}, context)
- end
-
- def self.delete!(id, context)
- context.driver.destroy_storage_volume(context.credentials, {:id=>id} )
- end
-
- def self.find_to_attach_from_json(json_in, context)
- json = JSON.parse(json_in)
- volumes = json["volumes"].map{|v| {:volume=>self.find(v["volume"]["href"].split("/volumes/").last, context),
- :attachment_point=>v["attachmentPoint"] }}
- end
-
- def self.find_to_attach_from_xml(xml_in, context)
- xml = XmlSimple.xml_in(xml_in)
- volumes = xml["volume"].map{|v| {:volume => self.find(v["href"].split("/volumes/").last, context),
- :attachment_point=>v["attachmentPoint"] }}
- end
-
- private
-
- def self.create_volume(params, context)
- volume_config = VolumeConfiguration.find(params[:volume_config_id], context)
- opts = {:capacity=>volume_config.capacity[:quantity], :snapshot_id=>params[:volume_image_id] }
- storage_volume = self.driver.create_storage_volume(context.credentials, opts)
- from_storage_volume(storage_volume, context)
- end
-
- def self.from_storage_volume(volume, context)
- self.new( { :name => volume.id,
- :description => volume.id,
- :created => volume.created,
- :id => context.volume_url(volume.id),
- :capacity => { :quantity=>volume.capacity, :units=>"gibibyte" }, #FIXME... units will vary
- :bootable => "false", #fixme ... will vary... ec2 doesn't expose this
- :supports_snapshots => "true", #fixme, will vary (true for ec2)
- :snapshots => [], #fixme...
- :guest_interface => "",
- :eventlog => {:href=> "http://eventlogs"},#FIXME
- :meters => []
- } )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_collection.rb b/server/lib/cimi/model/volume_collection.rb
deleted file mode 100644
index d5053c7..0000000
--- a/server/lib/cimi/model/volume_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeCollection < CIMI::Model::Base
-
- act_as_root_entity :volume
-
- array :volumes do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.volumes_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeCollection",
- :volumes => Volume.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_configuration.rb b/server/lib/cimi/model/volume_configuration.rb
deleted file mode 100644
index 75b37ea..0000000
--- a/server/lib/cimi/model/volume_configuration.rb
+++ /dev/null
@@ -1,60 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeConfiguration < CIMI::Model::Base
-
- text :format
- struct :capacity do
- scalar :quantity
- scalar :units
- end
- text :supports_snapshots
- text :guest_interface
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- volume_configs = []
- if id == :all
- #ec2 ebs volumes can 1gb..1tb
- (1..1000).each do |size|
- volume_configs << create(size, context)
- end
- else
- volume_configs << create(id, context)
- return volume_configs.first
- end
- return volume_configs
- end
-
-
- def self.all(context); find(:all, context); end
-
- private
-
- def self.create(size, context)
- self.new( {
- :id => context.volume_configuration_url(size),
- :name => size,
- :description => "volume configuration with #{size} GiB",
- :created => Time.now.to_s,
- :capacity => {:quantity=>size, :units=>"gibibytes"},
- :supports_snapshots => "true"
- # FIXME :guest_interface => "NFS"
- } )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_configuration_collection.rb b/server/lib/cimi/model/volume_configuration_collection.rb
deleted file mode 100644
index ace31bf..0000000
--- a/server/lib/cimi/model/volume_configuration_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeConfigurationCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_configuration
-
- array :volume_configurations do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.volume_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeConfigurationCollection",
- :volume_configurations => VolumeConfiguration.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_image.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_image.rb b/server/lib/cimi/model/volume_image.rb
deleted file mode 100644
index 03cc7fd..0000000
--- a/server/lib/cimi/model/volume_image.rb
+++ /dev/null
@@ -1,49 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeImage < CIMI::Model::Base
-
- href :image_location
- text :image_data
- text :bootable
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- storage_snapshots = []
- opts = ( id==:all ) ? {} : { :id=>id }
- storage_snapshots = self.driver.storage_snapshots(context.credentials, opts)
- storage_snapshots.collect!{ |snapshot| from_storage_snapshot(snapshot, context) }
- return storage_snapshots.first unless storage_snapshots.length > 1
- return storage_snapshots
- end
-
- def self.all(context); find(:all, context); end
-
- private
-
- def self.from_storage_snapshot(snapshot, context)
- self.new( {
- :name => snapshot.id,
- :description => snapshot.id,
- :created => snapshot.created,
- :id => context.volume_image_url(snapshot.id),
- :image_location => {:href=>context.volume_url(snapshot.storage_volume_id)},
- :bootable => "false" #FIXME
- } )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_image_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_image_collection.rb b/server/lib/cimi/model/volume_image_collection.rb
deleted file mode 100644
index 0172c04..0000000
--- a/server/lib/cimi/model/volume_image_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeImageCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_image
-
- array :volume_images do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.volume_images_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeImageCollection",
- :volume_images => VolumeImage.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_template.rb b/server/lib/cimi/model/volume_template.rb
deleted file mode 100644
index b9c82db..0000000
--- a/server/lib/cimi/model/volume_template.rb
+++ /dev/null
@@ -1,23 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeTemplate < CIMI::Model::Base
-
- href :volume_config
- href :volume_image
- array :operations do
- scalar :rel, :href
- end
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/volume_template_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/volume_template_collection.rb b/server/lib/cimi/model/volume_template_collection.rb
deleted file mode 100644
index 6b6e4ac..0000000
--- a/server/lib/cimi/model/volume_template_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VolumeTemplateCollection < CIMI::Model::Base
-
- act_as_root_entity :volume_template
-
- array :volume_templates do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.volume_template_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VolumeTemplateCollection",
- :volume_templates => VolumeTemplate.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/vsp.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/vsp.rb b/server/lib/cimi/model/vsp.rb
deleted file mode 100644
index 40a526f..0000000
--- a/server/lib/cimi/model/vsp.rb
+++ /dev/null
@@ -1,102 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VSP < CIMI::Model::Base
-
- text :state
-
- href :network
-
- text :bandwidth_reservation
-
- text :traffic_priority
-
- text :max_traffic_delay
-
- text :max_traffic_loss
-
- text :max_traffic_jitter
-
- href :event_log
-
- array :meters do
- scalar :href
- end
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id==:all
- context.driver.vsps(context.credentials, {:env=>context})
- else
- context.driver.vsps(context.credentials, {:id=>id, :env=>context})
- end
- end
-
- def self.create(request_body, context, type)
- input = (type == :xml)? XmlSimple.xml_in(request_body, {"ForceArray"=>false, "NormaliseSpace"=>2}) : JSON.parse(request_body)
- if input["vspTemplate"]["href"] #template by reference
- vsp_config, network = get_by_reference(input, context)
- else
- if input["vspTemplate"]["vspConfig"]["href"] # configuration by reference
- vsp_config = VSPConfiguration.find(context.href_id(input["vspTemplate"]["vspConfig"]["href"],:vsp_configurations), context)
- else #configuration by value
- vsp_config = get_by_value(request_body, type)
- end
- network = Network.find(context.href_id(input["vspTemplate"]["network"]["href"], :networks), context)
- end
- params = {:vsp_config => vsp_config, :network => network, :name=>input["name"], :description=>input["description"], :env=>context}
- raise CIMI::Model::BadRequest.new("Bad request - missing required parameters. Client sent: #{request_body} which produced #{params.inspect}") if params.has_value?(nil)
- context.driver.create_vsp(context.credentials, params)
- end
-
- def self.delete!(id, context)
- context.driver.delete_vsp(context.credentials, id)
- end
-
- def perform(action, context, &block)
- begin
- if context.driver.send(:"#{action.name}_vsp", context.credentials, self.name)
- block.callback :success
- else
- raise "Operation #{action.name} failed to execute on the VSP #{self.name} "
- end
- rescue => e
- block.callback :failure, e.message
- end
- end
-
-
- private
-
- def self.get_by_reference(input, context)
- vsp_template = VSPTemplate.find(context.href_id(input["vspTemplate"]["href"], :vsp_templates), context)
- vsp_config = VSPConfiguration.find(context.href_id(vsp_template.vsp_config.href, :vsp_configurations), context)
- network = Network.find(context.href_id(vsp_template.network.href, :networks), context)
- return vsp_config, network
- end
-
- def self.get_by_value(request_body, type)
- if type == :xml
- xml_arrays = XmlSimple.xml_in(request_body, {"NormaliseSpace"=>2})
- vsp_config = VSPConfiguration.from_xml(XmlSimple.xml_out(xml_arrays["vspTemplate"][0]["vspConfig"][0]))
- else
- json = JSON.parse(request_body)
- vsp_config = VSPConfiguration.from_json(JSON.generate(json["vspTemplate"]["vspConfig"]))
- end
- end
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/vsp_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/vsp_collection.rb b/server/lib/cimi/model/vsp_collection.rb
deleted file mode 100644
index 6f659e1..0000000
--- a/server/lib/cimi/model/vsp_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VSPCollection < CIMI::Model::Base
-
- CIMI::Model.register_as_root_entity! "VSPs"
-
- array :vsps do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.vsps_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VSPCollection",
- :vsps => VSP.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/vsp_configuration.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/vsp_configuration.rb b/server/lib/cimi/model/vsp_configuration.rb
deleted file mode 100644
index c9a9bf3..0000000
--- a/server/lib/cimi/model/vsp_configuration.rb
+++ /dev/null
@@ -1,40 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VSPConfiguration < CIMI::Model::Base
-
- text :bandwidth_reservation
-
- text :traffic_priority
-
- text :max_traffic_delay
-
- text :max_traffic_loss
-
- text :max_traffic_jitter
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id==:all
- context.driver.vsp_configurations(context.credentials, {:env=>context})
- else
- context.driver.vsp_configurations(context.credentials, {:env=>context, :id=>id})
- end
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/vsp_configuration_collection.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/vsp_configuration_collection.rb b/server/lib/cimi/model/vsp_configuration_collection.rb
deleted file mode 100644
index addff1c..0000000
--- a/server/lib/cimi/model/vsp_configuration_collection.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VSPConfigurationCollection < CIMI::Model::Base
-
- CIMI::Model.register_as_root_entity! "VSPConfigurations"
-
- array :vsp_configurations do
- scalar :href
- end
-
- def self.default(context)
- self.new(
- :id => context.vsp_configurations_url,
- :name => 'default',
- :created => Time.now,
- :description => "#{context.driver.name.capitalize} VSPConfigurationCollection",
- :vsp_configurations => VSPConfiguration.all_uri(context)
- )
- end
-
-end
http://git-wip-us.apache.org/repos/asf/deltacloud/blob/a8a53bc6/server/lib/cimi/model/vsp_template.rb
----------------------------------------------------------------------
diff --git a/server/lib/cimi/model/vsp_template.rb b/server/lib/cimi/model/vsp_template.rb
deleted file mode 100644
index f1b8078..0000000
--- a/server/lib/cimi/model/vsp_template.rb
+++ /dev/null
@@ -1,34 +0,0 @@
-# Licensed to the Apache Software Foundation (ASF) under one or more
-# contributor license agreements. See the NOTICE file distributed with
-# this work for additional information regarding copyright ownership. The
-# ASF licenses this file to you 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.
-
-class CIMI::Model::VSPTemplate < CIMI::Model::Base
-
- href :network
-
- href :vsp_config
-
- array :operations do
- scalar :rel, :href
- end
-
- def self.find(id, context)
- if id==:all
- context.driver.vsp_templates(context.credentials, {:env=>context})
- else
- context.driver.vsp_templates(context.credentials, {:env=>context, :id=>id})
- end
- end
-
-end