Return-Path: X-Original-To: apmail-deltacloud-dev-archive@www.apache.org Delivered-To: apmail-deltacloud-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 9367BE73A for ; Fri, 15 Mar 2013 13:53:41 +0000 (UTC) Received: (qmail 92732 invoked by uid 500); 15 Mar 2013 13:53:41 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 92701 invoked by uid 500); 15 Mar 2013 13:53:40 -0000 Mailing-List: contact dev-help@deltacloud.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltacloud.apache.org Delivered-To: mailing list dev@deltacloud.apache.org Received: (qmail 92685 invoked by uid 99); 15 Mar 2013 13:53:40 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Mar 2013 13:53:40 +0000 X-ASF-Spam-Status: No, hits=-0.7 required=5.0 tests=RCVD_IN_DNSWL_LOW,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: local policy) Received: from [116.50.57.190] (HELO cluster-k.mailcontrol.com) (116.50.57.190) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 15 Mar 2013 13:53:34 +0000 Received: from mail2.fujitsu.com.au (mail2.fujitsu.com.au [216.14.192.226]) by rly02k.srv.mailcontrol.com (MailControl) with ESMTP id r2FDr5pG019781 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=FAIL) for ; Fri, 15 Mar 2013 13:53:07 GMT Received: from localhost (localhost.localdomain [127.0.0.1]) by mail2.fujitsu.com.au (Postfix) with ESMTP id 89B062F5095 for ; Sat, 16 Mar 2013 00:53:05 +1100 (EST) X-Virus-Scanned: amavisd-new at mail2.fujitsu.com.au Received: from mail2.fujitsu.com.au ([127.0.0.1]) by localhost (mail2.fujitsu.com.au [127.0.0.1]) (amavisd-new, port 10024) with LMTP id Xgfr8Cofm59E for ; Sat, 16 Mar 2013 00:53:05 +1100 (EST) Received: from SYD0633.au.fujitsu.com (unknown [137.172.78.132]) (using TLSv1 with cipher RC4-MD5 (128/128 bits)) (Client did not present a certificate) by mail2.fujitsu.com.au (Postfix) with ESMTP id 5AE4C2F5092 for ; Sat, 16 Mar 2013 00:53:05 +1100 (EST) Received: from mailfilter2.au.fjanz.com (137.172.19.76) by SYD0633.au.fujitsu.com (137.172.78.132) with Microsoft SMTP Server id 8.3.83.0; Sat, 16 Mar 2013 00:53:02 +1100 Received: from RadwareLoad Balancer (137.172.78.70) [137.172.78.70] by mailfilter2.au.fjanz.com - Websense Email Security (7.0.0); Sat, 16 Mar 2013 00:53:04 +1100 Received: from FALEX03.au.fjanz.com ([137.172.72.104]) by SYD0630.au.fjanz.com with Microsoft SMTPSVC(6.0.3790.4675); Sat, 16 Mar 2013 00:52:54 +1100 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-Class: urn:content-classes:message MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Subject: RE: [PATCH] added Template subcollections to SystemTemplate Date: Sat, 16 Mar 2013 00:52:50 +1100 Message-ID: <434A0ECB689CAF49A3A2321F30F2AB83255042BD@FALEX03.au.fjanz.com> In-Reply-To: <1363354895-9400-1-git-send-email-diesk@fast.au.fujitsu.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: [PATCH] added Template subcollections to SystemTemplate Thread-Index: Ac4hgx4NW0hYrWUITTaeVFzvd8SpVQAADmrQ References: <1363354895-9400-1-git-send-email-diesk@fast.au.fujitsu.com> From: "Koper, Dies" To: X-OriginalArrivalTime: 15 Mar 2013 13:52:54.0202 (UTC) FILETIME=[6445D1A0:01CE2184] X-SEF-Processed: 7_0_0_00239__2013_03_16_00_53_04 X-Scanned-By: MailControl 13381.65 (www.mailcontrol.com) on 10.75.0.112 X-Virus-Checked: Checked by ClamAV on apache.org Hi David, When I run this patch on mock, system templates display fine, even with machineTemplates inline volumeTemplates and networkTemplates. However, when I run on fgcp, I get the following error: E, [2013-03-16T00:36:11.714489 #13212] ERROR -- 500: [NoMethodError] undefined method `[]' for nil:NilClass d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:273:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `block in to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `each' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:150:in `convert_to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:127:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `block in to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `each' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:150:in `convert_to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `block in to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `map' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `block in to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `each' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:150:in `convert_to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `block in to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `map' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:242:in `to_xml' d:/sources/OSS/cloud/deltacloud/server/lib/cimi/models/schema.rb:381:in `block in to_xml' I've printed module and name in schema.rb:273: model: # name: property model: {:name=3D>"Secure1", :description=3D>"Network tier 1", :type=3D>"http://schemas.dmtf.org/cimi/1/Network", :network_template=3D>#nil, :name=3D>"Private network", :description=3D>"", :created=3D>nil, :updated=3D>nil, :property=3D>nil, :n etwork_config=3D>#nil, = :name=3D>nil, :description=3D>nil, :cre ated=3D>nil, :updated=3D>nil, :property=3D>nil, = :network_type=3D>"PRIVATE", :mtu=3D>nil, :class_of_service=3D>"BRONZE", :operations=3D>nil, = :href=3D>nil}>, :forwarding_group=3D># nil, :name=3D>nil, :description=3D>nil, :created=3D>nil, :updated=3D> nil, :property=3D>nil, :networks=3D>nil, :operations=3D>nil, = :href=3D>nil}>, :operations=3D>nil}>} name: properties model: name: property Do you understand what's wrong? Regards, Dies Koper > -----Original Message----- > From: diesk@fast.au.fujitsu.com [mailto:diesk@fast.au.fujitsu.com] > Sent: Saturday, 16 March 2013 12:42 AM > To: dev@deltacloud.apache.org > Subject: [PATCH] added Template subcollections to SystemTemplate >=20 > From: Dies Koper >=20 > --- > server/lib/cimi/models.rb | 4 +- > server/lib/cimi/models/machine_template.rb | 6 +- > server/lib/cimi/models/network_template.rb | 4 +- > server/lib/cimi/models/system.rb | 4 +- > server/lib/cimi/models/system_template.rb | 20 +++-- > server/lib/cimi/models/volume_template.rb | 4 +- > server/lib/deltacloud/drivers/fgcp/fgcp_client.rb | 4 + > .../drivers/fgcp/fgcp_driver_cimi_methods.rb | 94 > +++++++++++++++++----- > .../mock/data/cimi/system_template/template1.json | 31 ++++++- > .../drivers/mock/mock_driver_cimi_methods.rb | 32 ++++++++ > .../cimi/collections/system_templates_test.rb | 47 +++++++++++ > 11 files changed, 207 insertions(+), 43 deletions(-) >=20 > diff --git a/server/lib/cimi/models.rb b/server/lib/cimi/models.rb > index 8eeb96c..e605b42 100644 > --- a/server/lib/cimi/models.rb > +++ b/server/lib/cimi/models.rb > @@ -79,7 +79,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/machine_template.rb > b/server/lib/cimi/models/machine_template.rb > index 68e865b..c167555 100644 > --- a/server/lib/cimi/models/machine_template.rb > +++ b/server/lib/cimi/models/machine_template.rb > @@ -28,10 +28,12 @@ class CIMI::Model::MachineTemplate < > CIMI::Model::Base > scalar :href, :initial_location > end >=20 > - array :volume_templates do > - scalar :href, :initial_location > + class CIMI::Model::VolumeTemplateWithLocation < > CIMI::Model::VolumeTemplate > + text :initial_location > end >=20 > + array :volume_templates, :ref =3D> > CIMI::Model::VolumeTemplateWithLocation > + > array :network_interfaces do > href :vsp > text :hostname, :mac_address, :state, :protocol, :allocation > diff --git a/server/lib/cimi/models/network_template.rb > b/server/lib/cimi/models/network_template.rb > index 4f69f52..301d56a 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 >=20 > acts_as_root_entity >=20 > - ref :network_config, :required =3D> true > - ref :forwarding_group, :required =3D> true > + ref :network_config, :class =3D> CIMI::Model::NetworkConfiguration > + ref :forwarding_group >=20 > array :operations do > scalar :rel, :href > diff --git a/server/lib/cimi/models/system.rb > b/server/lib/cimi/models/system.rb > index 118f9f5..e8a9ad8 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 >=20 > acts_as_root_entity >=20 > - text :state > + href :system_template, :required =3D> false > + > + text :state, :required =3D> true >=20 > # FIXME: Any reason for these comments? >=20 > diff --git a/server/lib/cimi/models/system_template.rb > b/server/lib/cimi/models/system_template.rb > index 82e418b..c60f759 100644 > --- a/server/lib/cimi/models/system_template.rb > +++ b/server/lib/cimi/models/system_template.rb > @@ -20,19 +20,17 @@ class CIMI::Model::SystemTemplate < > CIMI::Model::Base > array :component_descriptors do > text :name, :description > hash_map :properties > - text :type > - > - # FIXME: Any reasons for these comments? > + text :type, :required =3D> true >=20 > #component_template, comprises: > - # struct :machine_template, :class =3D> > CIMI::Model::MachineTemplate > - # struct :system_template, :class =3D> > CIMI::Model::SystemTemplate > - # struct :credential_template, :class =3D> > CIMI::Model::CredentialTemplate > - # struct :volume_template, :class =3D> > CIMI::Model::VolumeTemplate > - # struct :network_template, :class =3D> > CIMI::Model::NetworkTemplate > - # struct :network_port_template, :class =3D> > CIMI::Model::NetworkPortTemplate > - # struct :forwarding_group_template, :class =3D> > CIMI::Model::ForwardingGroupTemplate > - # struct :address_template, :class =3D> > CIMI::Model::AddressTemplate > + ref :machine_template, :class =3D> CIMI::Model::MachineTemplate > + ref :system_template, :class =3D> CIMI::Model::SystemTemplate > + ref :credential_template, :class =3D> > CIMI::Model::CredentialTemplate > + ref :volume_template, :class =3D> CIMI::Model::VolumeTemplate > + ref :network_template, :class =3D> CIMI::Model::NetworkTemplate > + ref :network_port_template, :class =3D> > CIMI::Model::NetworkPortTemplate > + ref :forwarding_group_template, :class =3D> > CIMI::Model::ForwardingGroupTemplate > + ref :address_template, :class =3D> CIMI::Model::AddressTemplate > text :quantity > end >=20 > diff --git a/server/lib/cimi/models/volume_template.rb > b/server/lib/cimi/models/volume_template.rb > index bda4657..43e9c86 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 >=20 > acts_as_root_entity >=20 > - ref :volume_config, :required =3D> true > - ref :volume_image, :required =3D> true > + ref :volume_config, :required =3D> true, :class =3D> > CIMI::Model::VolumeConfiguration > + ref :volume_image >=20 > 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 >=20 > + def get_vsys_descriptor_configuration(vsys_descriptor_id) > + request('GetVSYSDescriptorConfiguration', {'vsysDescriptorId' = =3D> > vsys_descriptor_id}) > + end > + > def list_vservers(vsys_id) > request('ListVServer', {'vsysId' =3D> 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..60f5e84 100644 > --- a/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb > +++ b/server/lib/deltacloud/drivers/fgcp/fgcp_driver_cimi_methods.rb > @@ -29,39 +29,95 @@ module Deltacloud::Drivers::Fgcp > def systems(credentials, opts=3D{}) > safely do > client =3D new_client(credentials) > + xml =3D client.list_vsys['vsyss'] > + return [] if xml.nil? > + context =3D opts[:env] >=20 > - if opts and opts[:id] > - vsys_ids =3D [opts[:id]] > - else > - xml =3D client.list_vsys['vsyss'] > - return [] if xml.nil? > - vsys_ids =3D xml[0]['vsys'].collect { |vsys| > vsys['vsysId'][0] } > - end > - > - vsys_ids.collect do |vsys_id| > - vsys =3D client.get_vsys_configuration(vsys_id)['vsys'][0] > + systems =3D xml[0]['vsys'].collect do |vsys| > + vsys_id =3D vsys['vsysId'][0] > vsys_description_el =3D vsys['description'] > CIMI::Model::System.new( > - :id =3D> vsys['vsysId'][0], > + :id =3D> vsys_id, > :name =3D> vsys['vsysName'][0], > -# :machines =3D> > "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/machines?realm > _id=3D#{vsys['vsysId'][0]}", > -# :volumes =3D> > "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/volumes?realm_ > id=3D#{vsys['vsysId'][0]}", > -# :networks =3D> > "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/networks?realm > _id=3D#{vsys['vsysId'][0]}", > -# :addresses =3D> > "http://cimi.example.org/systems/#{vsys['vsysId'][0]}/addresses?real > m_id=3D#{vsys['vsysId'][0]}", > - :description =3D> vsys_description_el ? > vsys_description_el[0] : nil > + :description =3D> vsys_description_el ? > vsys_description_el[0] : nil, > + :machines =3D> { :href =3D> > context.system_url("#{vsys_id}/machines") }, > + :volumes =3D> { :href =3D> > context.system_url("#{vsys_id}/volumes") }, > + :networks =3D> { :href =3D> > context.system_url("#{vsys_id}/networks") }, > + :addresses =3D> { :href =3D> > context.system_url("#{vsys_id}/addresses") } > ) > end > + systems =3D systems.select { |s| opts[:id] =3D=3D s[:id] } if opts[:id] > + # now add system state > + systems.each do |system| > + xml =3D client.list_vservers(system[:id])['vservers'] > + if xml.nil? > + system[:state] =3D 'MIXED' > + else > + xml[0]['vserver'].each do |vserver| > + state =3D > @@INSTANCE_STATE_MAP[client.get_vserver_status(vserver['vserverId'][ > 0])['vserverStatus'][0]] > + state =3D 'STARTED' if state =3D=3D 'RUNNING' > + system[:state] ||=3D state > + if system[:state] !=3D state > + system[:state] =3D 'MIXED' > + break > + end > + end > + end > + end > + systems > end > end >=20 > def system_templates(credentials, opts=3D{}) > safely do > client =3D new_client(credentials) > + context =3D opts[:env] > templates =3D > client.list_vsys_descriptor['vsysdescriptors'][0]['vsysdescriptor']. > collect do |desc| > + conf =3D > client.get_vsys_descriptor_configuration(desc['vsysdescriptorId'][0] > )['vsysdescriptor'][0] > + components =3D conf['vservers'][0]['vserver'].collect do > |vserver| > + next if vserver['vserverType'][0] =3D=3D 'firewall' > + volume_templates =3D = vserver['vdisks'][0]['vdisk'].collect > do |vdisk| > + CIMI::Model::VolumeTemplateWithLocation.new( > +# :volume_config =3D> {:capacity =3D> > "#{vdisk['size'][0].to_i * 1024 * 1024}"} > + :volume_config =3D> > CIMI::Model::VolumeConfiguration.new(:capacity =3D> > vdisk['size'][0].to_i * 1024 * 1024) > + ) > + end if vserver['vdisks'] > + { > + :name =3D> desc['vsysdescriptorName'][0], > + :description =3D> '', > + :type =3D> > "http://schemas.dmtf.org/cimi/1/Machine", > + :machine_template =3D> = CIMI::Model::MachineTemplate.new( > + :name =3D> vserver['vserverName'][0], > + :description =3D> '', > + :machine_config =3D> > CIMI::Service::MachineConfiguration.find(vserver['vserverType'][0], > context), > + :machine_image =3D> { :href =3D> > context.machine_image_url(vserver['diskimageId'][0]) }, > + :volume_templates =3D> volume_templates > + ) > + } > + end > + if conf['vsysdescriptorId'][0] =3D~ /(1|2|3)-tier Skeleton/ > + tiers =3D ['DMZ', 'Secure1', 'Secure2'] > + components +=3D 1.upto($1.to_i).collect do |n| > + { > + :name =3D> tiers[n], > + :description =3D> "Network tier #{n}", > + :type =3D> > "http://schemas.dmtf.org/cimi/1/Network", > + :network_template =3D> > CIMI::Model::NetworkTemplate.new( > + :name =3D> 'Private network', > + :description =3D> '', > + :network_config =3D> > CIMI::Model::NetworkConfiguration.new( > + :network_type =3D> 'PRIVATE', > + :class_of_service =3D> 'BRONZE' > + ) > + ) > + } > + end > + end > CIMI::Model::SystemTemplate.new( > - :id =3D> desc['vsysdescriptorId'][0], > - :name =3D> desc['vsysdescriptorName'][0], > - :description =3D> desc['description'][0] > + :id =3D> desc['vsysdescriptorId'][0], > + :name =3D> = desc['vsysdescriptorName'][0], > + :description =3D> desc['description'][0], > + :component_descriptors =3D> components.compact > ) > end > templates =3D templates.select { |t| opts[:id] =3D=3D 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 >=20 > + def create_system(credentials, opts=3D{}) > + check_credentials(credentials) > + id =3D "#{opts[:env].send("systems_url")}/#{opts[:name]}" > + sys_hsh =3D { "id"=3D> id, > + "name" =3D> opts[:name], > + "description" =3D> opts[:description], > + "created" =3D> Time.now, > + "state" =3D> "STOPPED", > + "systemTemplate"=3D> { "href" =3D> > opts[:system_template].id }, > + "operations" =3D> [{"rel"=3D>"edit", "href"=3D> = id}, > + {"rel"=3D>"delete", "href"=3D> > id}] } > + system =3D = 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=3D{}) > 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..87488b4 100644 > --- a/server/tests/cimi/collections/system_templates_test.rb > +++ b/server/tests/cimi/collections/system_templates_test.rb > @@ -38,4 +38,51 @@ describe CIMI::Collections::SystemTemplates do > status.must_equal 404 > end >=20 > + 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 =3D=3D 'my third machine' > + (c/'machineTemplate').wont_be_empty > + (c/'machineTemplate').to_s.must_equal ' href=3D"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 =3D=3D 'my machine' > + (c/'machineTemplate').wont_be_empty > + (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 > '' > + (c/'machineTemplate/machineImage').to_s.must_equal > '' > + (c/'machineTemplate/volumeTemplate').to_s.must_equal > '' > + end > + end > + end > + > + it 'should allow to retrieve system template\'s machine template\'s > inline volume template' do > + get root_url '/system_templates/template1' > + (xml/'SystemTemplate/componentDescriptor').each do |c| > + if (c/'name').inner_text =3D=3D 'my second machine' > + (c/'machineTemplate').wont_be_empty > + (c/'machineTemplate/description').inner_text.must_equal > 'another inline mock machine template' > + (c/'machineTemplate/volumeTemplate').wont_be_empty > + > (c/'machineTemplate/volumeTemplate/volumeConfig').wont_be_empty > + > (c/'machineTemplate/volumeTemplate/volumeConfig/capacity').inner_tex > t.must_equal '10485760' > + 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 =3D=3D '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 >=20 >=20