Thanks!

> > +++ b/server/lib/cimi/collections/system_templates.rb
> 
> Nothing wrong with what you did here, but I am wondering if there is
> anything we can do to reduce this sort of boilerplate. Most of our
> collections look exactly the same ...

I was planning to suggest the same, after I confirmed the copying and pasting I 
did is actually correct.
I suppose we have two types of models/collections, the ones that are 
implemented directly in the drivers (like system, I suppose also meter and 
eventlog) and the ones that are mapped to Deltacloud's models first 
(machines/instances, images, etc.). Especially in the former case but maybe 
also in the latter case most of the code is the same.
I based this and system.rb on I believe machine.rb and all I did was rename 
machine to system.

> The puts just before the else is where things go wrong: without the
> puts, the value of the if branch is whatever is assigned to systems,
> which in turn is what gets returned from self.find - by inserting the
> puts, you are now returning nil. Put a line 'systems' just after the
> puts, and things look much better (at least, you're getting a valid
> response back instead of a 500, though it had no systems for me)

Thanks, that worked for me. Now both systems and system_templates are returning 
an entry for me:

<Collection xmlns="http://schemas.dmtf.org/cimi/1"; 
resourceURI="http://schemas.dmtf.org/cimi/1/SystemCollection";>
  <id>http://localhost:3001/cimi/systems</id>
  <count>1</count>
  <System>
    <id>http://localhost:3001/cimi/systems/system1</id>
    <name>system1</name>
    <description>the first system</description>
    <created>Fri Feb 08 15:25:41 EET 2013</created>
    <state>STOPPED</state>
    <systems href="http://localhost:3001/cimi/systems/system1/systems"; />
    <machines href="http://cimi.example.org/systems/87654/machines"; />
    <volumes href="http://localhost:3001/cimi/systems/system1/volumes"; />
    <networks href="http://cimi.example.org/systems/87654/networks"; />
    <addresses href="http://localhost:3001/cimi/systems/system1/addresses"; />
    <forwardingGroups 
href="http://localhost:3001/cimi/systems/system1/forwarding_groups"; />
    <operation rel="edit" href="http://localhost:3001/cimi/systems/system1"; />
    <operation rel="delete" href="http://localhost:3001/cimi/systems/system1"; />
  </System>
</Collection>

And

<Collection xmlns="http://schemas.dmtf.org/cimi/1"; 
resourceURI="http://schemas.dmtf.org/cimi/1/SystemTemplateCollection";>
  <id>http://localhost:3001/cimi/system_templates</id>
  <count>1</count>
  <SystemTemplate>
    <id>http://localhost:3001/cimi/system_templates/system template 1</id>
    <name>system template 1</name>
    <description>A mock system template</description>
    <created>Fri Feb 08 12:15:15 EET 2013</created>
    <componentDescriptor>
      <name>my machine</name>
      <description>an inline mock machine template</description>
      <type>http://schemas.dmtf.org/cimi/1/Machine</type>
    </componentDescriptor>
    <componentDescriptor>
      <name>my network</name>
      <description>a reference to an existing mock network 
template</description>
      <type>http://schemas.dmtf.org/cimi/1/Network</type>
    </componentDescriptor>
    <operation rel="edit" 
href="http://localhost:3001/cimi/system_templates/system template 1" />
    <operation rel="delete" 
href="http://localhost:3001/cimi/system_templates/system template 1" />
  </SystemTemplate>
</Collection>

The first time I ran it it didn't work for me because I needed to copy the json 
files from mock/data to my local /var/tmp/... folder. Maybe that's why it 
didn't work for you?

I don't believe this response XML is correct so I'll look at that first.

> As a general comment, try adding as little of the System* objects in one
> patch as possible, again, to make reviewing easier. I haven't looked in
> detail if that makes sense here or not, but it would be nice if it did,
> and there's nothing wrong with a CIMI provider that only has System, but
> none of the other System* collections.

It is my understanding that a System references its components (machines, etc.) 
through System* collections, so without the System* collections all we'd have 
is a System class with a name, description and state, but no containing 
machines, etc.
So I assume leaving them out here doesn't make sense?

Cheers,
Dies Koper

Reply via email to