Hi Michal, > The horrible looking 'uuid' field is SHA1 hash composed from > credentials, driver name and provider string, so different clients will > not override their properties.
This is something I've been wondering about, should these properties be stored per user or per resource? I mean, if I modify an attribute of a machine, which is stored in the persistence layer as the driver doesn't support this modification operation, and my colleague who has his own username but sharing my account lists the machine's attributes, would he see the original attribute or the modified one? I would have preferred the latter but having the credentials in the uuid sounds like you're thinking to do the former? Regards, Dies Koper > -----Original Message----- > From: Michal Fojtik [mailto:[email protected]] > Sent: Tuesday, 13 November 2012 10:54 PM > To: [email protected] > Subject: POC: DataMapper support for CIMI attributes > > Hi, > > I was playing a bit with adding DataMapper to Deltacloud to support > storing certain CIMI attributes that cannot be stored on the provider > side (like 'description', etc.). We were discussing earlier that for > that attributes we will need to create some persistent storage on > Deltacloud side. So I put together a small PoC of how complex (or not > complex) this will be: > > So let say you want to create a new Machine. Currently if you specify > 'description' in JSON body, we ignore this property because there is now > way how to store it on the backend side (using the driver method). > > So you have this JSON: > > ~/code/core/server > cat machine.json > { > "resourceURI": "http://schemas.dmtf.org/cimi/1/MachineCreate", > "name": "myMachine1", > "description": "My very first machine", > "machineTemplate": { > "machineConfig": { "href": > "http://localhost:3001/cimi/machine_configurations/m1-small" }, > "machineImage": { "href": > "http://localhost:3001/cimi/machine_images/img1" } > } > } > > And you create Machine using this curl command: > > curl -v --user "mockuser:mockpassword" -X POST \ > http://localhost:3001/cimi/machines \ > -H "Content-Type: application/json" -d @machine.json > > > With the patch I attached, you will see something like this in > Deltacloud API log: > > <snip> > ~ (0.000047) SELECT "id", "name", "uuid", "entity" FROM > "deltacloud_database_entity_properties" WHERE ("uuid" = > 'f6d93dfa8eaca129d7412a8d58980a5948361ae8' AND "entity" = > 'Instance:inst7' AND "name" = 'description') ORDER BY "id" LIMIT 1 > ~ (0.017038) INSERT INTO "deltacloud_database_entity_properties" > ("name", "uuid", "entity") VALUES ('description', > 'f6d93dfa8eaca129d7412a8d58980a5948361ae8', 'Instance:inst7') > ~ (0.014218) UPDATE "deltacloud_database_entity_properties" SET > "value" = 'My very first machine' WHERE "id" = 4 > ~ (0.000104) SELECT "id", "name", "uuid", "entity" FROM > "deltacloud_database_entity_properties" WHERE ("uuid" = > 'f6d93dfa8eaca129d7412a8d58980a5948361ae8' AND "entity" = > 'Instance:inst7' AND "name" = 'description') ORDER BY "id" LIMIT 1 > ~ (0.000045) SELECT "id", "value" FROM > "deltacloud_database_entity_properties" WHERE "id" = 4 ORDER BY "id" > 127.0.0.1 - - [13/Nov/2012 12:45:03] "POST /cimi/machines HTTP/1.1" 201 > 862 0.2704 > </snip> > > As you can see DataMapper will store the 'description' property for the > 'Instance' model with id 'inst7' (the newly created instance). > > The horrible looking 'uuid' field is SHA1 hash composed from > credentials, driver name and provider string, so different clients will > not override their properties. > > Once this property is stored, I used the 'get_property_value' method, > that require just instance of the Deltacloud model and property name to > get the property value. > > Let me know what you think and if we want to go this way or we need > something more complex. > > The patch is also uploaded in Tracker: > > http://tracker.deltacloud.org/set/123 > > > -- Michal > > > -- > > Michal Fojtik <[email protected]> > Deltacloud API, CloudForms
