I had some required changes stashed, which caused issue 2.
Unfortunately they didn't affect the error in issue 3, and doesn't clear
up question 1.

Regards,
Dies Koper


> -----Original Message-----
> From: Koper, Dies [mailto:di...@fast.au.fujitsu.com]
> Sent: Wednesday, 13 March 2013 5:26 PM
> To: dev@deltacloud.apache.org
> Subject: RE: [PATCH] added Template subcollections to SystemTemplate
> 
> I'm stuck again. Please try out this patch and give me your comments.
> I have a few questions:
> 
> 1. Several attributes had ':required => true' while according to the
> spec they are not. Was that intentional? Okay to fix them?
> 2. A few weeks ago I had the problem that a system template's inline
> machine template's inline volume template's capacity attribute was not
> returned. David came up with a fix, that I confirmed to work at the
> time, but it's not working anymore:
> 
> curl --user mockuser:mockpassword
> "http://localhost:3001/cimi/system_templates?format=xml";
> ...
>   <componentDescriptor>
>     <name>my second machine</name>
>     <description>another inline mock machine template</description>
>     <type>http://schemas.dmtf.org/cimi/1/Machine</type>
>     <machineTemplate>
>       <name>machine in mock system</name>
>       <description>machine in system</description>
>       <machineConfig href="http://example.com/configs/m1-small"; />
>       <machineImage href="http://example.com/images/img1"; />
>       <volumeTemplate></volumeTemplate>
>     </machineTemplate>
>   </componentDescriptor>
> 
> volumeTemplate should include the capacity attribute.
> I've added unit tests to ensure system template networks (which I just
> added) won't break unnoticed. I'll do the same for this attribute once
> working again.
> 
> 3. When I run this with the fgcp driver, I get:
> 
> E, [2013-03-13T13:37:05.377113 #13112] ERROR -- 500: [NoMethodError]
> undefined method `[]' for nil:NilClass
> 
> d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:285
> :in
> `to_xml'
> d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:390
> :in
> `to_xml'
> ...
> 
> And I'm not sure why. (Again, I believe this used to work.)
> 
> Please help!
> 
> Regards,
> Dies Koper
> 
> 
> > -----Original Message-----
> > From: di...@fast.au.fujitsu.com [mailto:di...@fast.au.fujitsu.com]
> > Sent: Wednesday, 13 March 2013 5:14 PM
> > To: dev@deltacloud.apache.org
> > Subject: [PATCH] added Template subcollections to SystemTemplate
> >
> > From: Dies Koper <di...@fast.au.fujitsu.com>
> >
> > ---
> >  server/lib/cimi/models.rb                          |  4 +-
> >  server/lib/cimi/models/network_template.rb         |  4 +-
> >  server/lib/cimi/models/system.rb                   |  4 +-
> >  server/lib/cimi/models/system_template.rb          | 18 ++++----
> >  server/lib/cimi/models/volume_template.rb          |  4 +-
> >  server/lib/deltacloud/drivers/fgcp/fgcp_client.rb  |  4 ++
> >  .../drivers/fgcp/fgcp_driver_cimi_methods.rb       | 52
> > ++++++++++++++++++++--
> >  .../mock/data/cimi/system_template/template1.json  | 31
> > +++++++++++--
> >  .../drivers/mock/mock_driver_cimi_methods.rb       | 32
> > +++++++++++++
> >  .../cimi/collections/system_templates_test.rb      | 44
> > ++++++++++++++++++
> >  10 files changed, 174 insertions(+), 23 deletions(-)
> >
> > diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb
> > index edfb0e3..a1e4336 100644
> > --- a/server/lib/cimi/models.rb
> > +++ b/server/lib/cimi/models.rb
> > @@ -88,7 +88,7 @@ require_relative
'./models/address_template_create'
> >  require_relative './models/address_create'
> >  require_relative './models/forwarding_group'
> >  require_relative './models/forwarding_group_template'
> > -require_relative './models/system_template'
> > -require_relative './models/system'
> >  require_relative './models/network_template'
> >  require_relative './models/network_create'
> > +require_relative './models/system_template'
> > +require_relative './models/system'
> > diff --git a/server/lib/cimi/models/network_template.rb
> > b/server/lib/cimi/models/network_template.rb
> > index a16c094..0f298bf 100644
> > --- a/server/lib/cimi/models/network_template.rb
> > +++ b/server/lib/cimi/models/network_template.rb
> > @@ -17,8 +17,8 @@ class CIMI::Model::NetworkTemplate <
> CIMI::Model::Base
> >
> >    acts_as_root_entity
> >
> > -  ref :network_config, :required => true
> > -  ref :forwarding_group, :required => true
> > +  ref :network_config, :class => CIMI::Model::NetworkConfiguration
> > +  ref :forwarding_group
> >
> >    array :operations do
> >      scalar :rel, :href
> > diff --git a/server/lib/cimi/models/system.rb
> > b/server/lib/cimi/models/system.rb
> > index e238259..2d5b656 100644
> > --- a/server/lib/cimi/models/system.rb
> > +++ b/server/lib/cimi/models/system.rb
> > @@ -17,7 +17,9 @@ class CIMI::Model::System < CIMI::Model::Base
> >
> >    acts_as_root_entity
> >
> > -  text :state
> > +  resource_attr :system_template, :required => false, :type =>
:href
> > +
> > +  text :state, :required => true
> >
> >  #  collection :systems, :class => CIMI::Model::SystemSystem
> >  #  collection :machines, :class => CIMI::Model::SystemMachine
> > diff --git a/server/lib/cimi/models/system_template.rb
> > b/server/lib/cimi/models/system_template.rb
> > index 09cd9b0..c40eb09 100644
> > --- a/server/lib/cimi/models/system_template.rb
> > +++ b/server/lib/cimi/models/system_template.rb
> > @@ -20,16 +20,16 @@ class CIMI::Model::SystemTemplate <
> > CIMI::Model::Base
> >    array :component_descriptors do
> >      text :name, :description
> >      hash :properties
> > -    text :type
> > +    text :type, :required => true
> >      #component_template, comprises:
> > -#    struct :machine_template, :class =>
> CIMI::Model::MachineTemplate
> > -#    struct :system_template, :class => CIMI::Model::SystemTemplate
> > -#    struct :credential_template, :class =>
> > CIMI::Model::CredentialTemplate
> > -#    struct :volume_template, :class => CIMI::Model::VolumeTemplate
> > -#    struct :network_template, :class =>
> CIMI::Model::NetworkTemplate
> > -#    struct :network_port_template, :class =>
> > CIMI::Model::NetworkPortTemplate
> > -#    struct :forwarding_group_template, :class =>
> > CIMI::Model::ForwardingGroupTemplate
> > -#    struct :address_template, :class =>
> CIMI::Model::AddressTemplate
> > +    ref :machine_template, :class => CIMI::Model::MachineTemplate
> > +    ref :system_template, :class => CIMI::Model::SystemTemplate
> > +    ref :credential_template, :class =>
> > CIMI::Model::CredentialTemplate
> > +    ref :volume_template, :class => CIMI::Model::VolumeTemplate
> > +    ref :network_template, :class => CIMI::Model::NetworkTemplate
> > +    ref :network_port_template, :class =>
> > CIMI::Model::NetworkPortTemplate
> > +    ref :forwarding_group_template, :class =>
> > CIMI::Model::ForwardingGroupTemplate
> > +    ref :address_template, :class => CIMI::Model::AddressTemplate
> >      text :quantity
> >    end
> >
> > diff --git a/server/lib/cimi/models/volume_template.rb
> > b/server/lib/cimi/models/volume_template.rb
> > index 15cbcd0..8321eeb 100644
> > --- a/server/lib/cimi/models/volume_template.rb
> > +++ b/server/lib/cimi/models/volume_template.rb
> > @@ -17,8 +17,8 @@ class CIMI::Model::VolumeTemplate <
> CIMI::Model::Base
> >
> >    acts_as_root_entity
> >
> > -  ref :volume_config, :required => true
> > -  ref :volume_image, :required => true
> > +  ref :volume_config, :required => true, :class =>
> > CIMI::Model::VolumeConfiguration
> > +  ref :volume_image
> >
> >    array :meter_templates do
> >    end
> > diff --git a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
> > b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
> > index fed3b70..9597c13 100644
> > --- a/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
> > +++ b/server/lib/deltacloud/drivers/fgcp/fgcp_client.rb
> > @@ -94,6 +94,10 @@ class FgcpClient
> >      request('ListVSYSDescriptor')
> >    end
> >
> > +  def get_vsys_descriptor_configuration(vsys_descriptor_id)
> > +    request('GetVSYSDescriptorConfiguration', {'vsysDescriptorId'
> =>
> > vsys_descriptor_id})
> > +  end
> > +
> >    def list_vservers(vsys_id)
> >      request('ListVServer', {'vsysId' => vsys_id})
> >    end
> > diff --git
> > a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> > b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> > index b4d31f6..44dc8f6 100644
> > ---
> a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> > +++
> b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb
> > @@ -57,11 +57,57 @@ module Deltacloud::Drivers::Fgcp
> >      def system_templates(credentials, opts={})
> >        safely do
> >          client = new_client(credentials)
> > +        context = opts[:env]
> >          templates =
> >
> client.list_vsys_descriptor['vsysdescriptors'][0]['vsysdescriptor'].
> > collect do |desc|
> > +          conf =
> >
> client.get_vsys_descriptor_configuration(desc['vsysdescriptorId'][0]
> > )['vsysdescriptor'][0]
> > +          components = conf['vservers'][0]['vserver'].collect do
> > |vserver|
> > +            next if vserver['vserverType'][0] == 'firewall'
> > +            volume_templates =
> vserver['vdisks'][0]['vdisk'].collect
> > do |vdisk|
> > +              {
> > +                :volume_config => {:capacity =>
> > "#{vdisk['size'][0].to_i}"}
> > +              }
> > +#
> > {:href=>context.volume_url(snapshot.storage_volume_id)},
> > +#              {
> > +#                :volume_template => "#{vdisk['size'][0].to_i}"
> > +#              }
> > +#              CIMI::Model::VolumeTemplate.new(
> > +#                :volume_config =>
> > CIMI::Model::VolumeConfiguration.new(:capacity =>
> > vdisk['size'][0].to_i)
> > +#              )
> > +            end if vserver['vdisks']
> > +            {
> > +              :name             => desc['vsysdescriptorName'][0],
> > +              :description      => desc['description'][0],
> > +              :type             =>
> > "http://schemas.dmtf.org/cimi/1/Machine";,
> > +              :machine_template =>
> CIMI::Model::MachineTemplate.new(
> > +                :name             => vserver['vserverName'][0],
> > +                :machine_config   =>
> > CIMI::Model::MachineConfiguration.find(vserver['vserverType'][0],
> > context),
> > +                :machine_image    => { :href =>
> > context.machine_image_url(vserver['diskimageId'][0]) },
> > +                :volume_templates => volume_templates
> > +              )
> > +            }
> > +          end
> > +          if conf['vsysdescriptorId'][0] =~ /(1|2|3)-tier Skeleton/
> > +            tiers = ['DMZ', 'Secure1', 'Secure2']
> > +            components += 1.upto($1.to_i).collect do |n|
> > +              {
> > +                :name             => tiers[n],
> > +                :description      => "Network tier #{n}",
> > +                :type             =>
> > "http://schemas.dmtf.org/cimi/1/Network";,
> > +                :network_template =>
> > CIMI::Model::NetworkTemplate.new(
> > +                  :name             => 'Private network',
> > +                  :network_config   =>
> > CIMI::Model::NetworkConfiguration.new(
> > +                    :network_type     => 'PRIVATE',
> > +                    :class_of_service => 'BRONZE'
> > +                  )
> > +                )
> > +              }
> > +            end
> > +          end
> >            CIMI::Model::SystemTemplate.new(
> > -            :id           => desc['vsysdescriptorId'][0],
> > -            :name         => desc['vsysdescriptorName'][0],
> > -            :description  => desc['description'][0]
> > +            :id                    => desc['vsysdescriptorId'][0],
> > +            :name                  =>
> desc['vsysdescriptorName'][0],
> > +            :description           => desc['description'][0],
> > +            :component_descriptors => components.compact
> >            )
> >          end
> >          templates = templates.select { |t| opts[:id] == t[:id] } if
> > opts[:id]
> > diff --git
> >
> a/server/lib/deltacloud/drivers/mock/data/cimi/system_template/templ
> > ate1.json
> >
> b/server/lib/deltacloud/drivers/mock/data/cimi/system_template/templ
> > ate1.json
> > index 495fc24..913252b 100644
> > ---
> >
> a/server/lib/deltacloud/drivers/mock/data/cimi/system_template/templ
> > ate1.json
> > +++
> >
> b/server/lib/deltacloud/drivers/mock/data/cimi/system_template/templ
> > ate1.json
> > @@ -4,20 +4,43 @@
> >    "created": "Fri Feb 08 12:15:15 EET 2013",
> >    "componentDescriptors": [
> >      { "name": "my machine",
> > -      "type": "http://schemas.dmtf.org/cimi/1/Machine";,
> >        "description": "an inline mock machine template",
> > +      "type": "http://schemas.dmtf.org/cimi/1/Machine";,
> >        "machineTemplate": {
> >          "name": "machine in mock system",
> >          "description": "machine in system",
> >          "machineConfig": { "href":
> > "http://example.com/configs/m1-small"; },
> > -        "machineImage": { "href": "http://example.com/images/img1";
}
> > +        "machineImage": { "href":
> "http://example.com/images/img1"; },
> > +        "volumeTemplates": [
> > +     { "href": "http://example.com/volumes/sysvol1"; }
> > +   ]
> >        }
> >      },
> > +    { "name": "my second machine",
> > +      "description": "another inline mock machine template",
> > +      "type": "http://schemas.dmtf.org/cimi/1/Machine";,
> > +      "machineTemplate": {
> > +        "name": "machine in mock system",
> > +        "description": "machine in system",
> > +        "machineConfig": { "href":
> > "http://example.com/configs/m1-small"; },
> > +        "machineImage": { "href":
> "http://example.com/images/img1"; },
> > +        "volumeTemplates": [
> > +     { "volumeConfig": {"capacity": 10485760} }
> > +   ]
> > +      }
> > +    },
> > +    { "name": "my third machine",
> > +      "description": "a reference to a mock machine template",
> > +      "type": "http://schemas.dmtf.org/cimi/1/Machine";,
> > +      "machineTemplate": { "href" :
> > "http://example.com/machine_templates/template1"; }
> > +    },
> >      { "name": "my network",
> > +      "description": "an inline network template",
> >        "type": "http://schemas.dmtf.org/cimi/1/Network";,
> > -      "description": "a reference to an existing mock network
> template",
> >        "networkTemplate": {
> > -        "href":
> > "http://cimi.example.org/network_templates/template1";
> > +        "name": "network in mock system",
> > +        "description": "network in system",
> > +        "networkConfig": { "networkType": "PRIVATE",
> > "classOfService": "GOLD" }
> >        }
> >      }
> >    ],
> > diff --git
> > a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > index b1c57c8..13987f2 100644
> > ---
> a/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > +++
> b/server/lib/deltacloud/drivers/mock/mock_driver_cimi_methods.rb
> > @@ -35,6 +35,38 @@ module Deltacloud::Drivers::Mock
> >        systems.map{|sys|convert_cimi_mock_urls(:system,
> > sys ,opts[:env])}.flatten
> >      end
> >
> > +    def create_system(credentials, opts={})
> > +      check_credentials(credentials)
> > +      id = "#{opts[:env].send("systems_url")}/#{opts[:name]}"
> > +      sys_hsh = { "id"=> id,
> > +                  "name" => opts[:name],
> > +                  "description" => opts[:description],
> > +                  "created" => Time.now,
> > +                  "state" => "STOPPED",
> > +                  "systemTemplate"=> { "href" =>
> > opts[:system_template].id },
> > +                  "operations" => [{"rel"=>"edit", "href"=> id},
> > +                                   {"rel"=>"delete", "href"=>
> > id}]    }
> > +      system =
> CIMI::Model::System.from_json(JSON.generate(sys_hsh))
> > +
> > +      @client.store_cimi(:system, system)
> > +      system
> > +    end
> > +
> > +    def delete_system(credentials, id)
> > +      check_credentials(credentials)
> > +      @client.destroy_cimi(:system, id)
> > +    end
> > +
> > +    def start_system(credentials, id)
> > +      check_credentials(credentials)
> > +      update_object_state(id, "System", "STARTED")
> > +    end
> > +
> > +    def stop_system(credentials, id)
> > +      check_credentials(credentials)
> > +      update_object_state(id, "System", "STOPPED")
> > +    end
> > +
> >      def system_templates(credentials, opts={})
> >        check_credentials(credentials)
> >        if opts[:id].nil?
> > diff --git a/server/tests/cimi/collections/system_templates_test.rb
> > b/server/tests/cimi/collections/system_templates_test.rb
> > index 8c4f1a7..69e159f 100644
> > --- a/server/tests/cimi/collections/system_templates_test.rb
> > +++ b/server/tests/cimi/collections/system_templates_test.rb
> > @@ -38,4 +38,48 @@ describe CIMI::Collections::SystemTemplates do
> >      status.must_equal 404
> >    end
> >
> > +  it 'should allow to retrieve system template\'s machine
template\'s
> > ref details' do
> > +    get root_url '/system_templates/template1'
> > +    (xml/'SystemTemplate/componentDescriptor').each do |c|
> > +      if (c/'name').inner_text == 'my third machine'
> > +        (c/'machineTemplate').wont_be_empty
> > +        (c/'machineTemplate').to_s.must_equal '<machineTemplate
> > href="http://example.com/machine_templates/template1"/>'
> > +      end
> > +    end
> > +  end
> > +
> > +  it 'should allow to retrieve system template\'s machine
template\'s
> > inline details' do
> > +    get root_url '/system_templates/template1'
> > +    (xml/'SystemTemplate/componentDescriptor').each do |c|
> > +      if (c/'name').inner_text == 'my machine'
> > +        (c/'machineTemplate/name').inner_text.must_equal 'machine
> in
> > mock system'
> > +        (c/'machineTemplate/description').inner_text.must_equal
> > 'machine in system'
> > +        (c/'machineTemplate/machineConfig').to_s.must_equal
> > '<machineConfig href="http://example.com/configs/m1-small"/>'
> > +        (c/'machineTemplate/machineImage').to_s.must_equal
> > '<machineImage href="http://example.com/images/img1"/>'
> > +        (c/'machineTemplate/volumeTemplate').to_s.must_equal
> > '<volumeTemplate href="http://example.com/volumes/sysvol1"/>'
> > +      end
> > +    end
> > +  end
> > +
> > +  it 'should allow to retrieve system template\'s machine
template\'s
> > inline volume template' do
> > +    get root_url '/system_templates/template1'
> > +    puts xml.root
> > +    (xml/'SystemTemplate/componentDescriptor').each do |c|
> > +      if (c/'name').inner_text == 'my second machine'
> > +        (c/'machineTemplate/name').inner_text.must_equal 'machine
> in
> > mock system'
> > +#        puts (c/'machineTemplate/volumeTemplate')
> > +      end
> > +    end
> > +  end
> > +
> > +  it 'should allow to retrieve system template\'s network' do
> > +    get root_url '/system_templates/template1'
> > +    (xml/'SystemTemplate/componentDescriptor').each do |c|
> > +      if (c/'name').inner_text == 'network in mock system'
> > +        (c/'networkTemplate').inner_text.must_equal 'my network'
> > +
> >
> (c/'networkTemplate/networkConfig/networkType').inner_text.must_equa
> > l 'GOLD'
> > +      end
> > +    end
> > +  end
> > +
> >  end
> > --
> > 1.8.0.msysgit.0
> >
> >
> 
> 


Reply via email to