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 A4B08D771 for ; Mon, 20 May 2013 07:03:08 +0000 (UTC) Received: (qmail 47298 invoked by uid 500); 20 May 2013 07:03:08 -0000 Delivered-To: apmail-deltacloud-dev-archive@deltacloud.apache.org Received: (qmail 47143 invoked by uid 500); 20 May 2013 07:03:06 -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 47097 invoked by uid 99); 20 May 2013 07:03:04 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 07:03:04 +0000 X-ASF-Spam-Status: No, hits=-5.0 required=5.0 tests=RCVD_IN_DNSWL_HI,SPF_HELO_PASS,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of mandreou@redhat.com designates 209.132.183.28 as permitted sender) Received: from [209.132.183.28] (HELO mx1.redhat.com) (209.132.183.28) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 20 May 2013 07:03:00 +0000 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r4K72cwi023071 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 20 May 2013 03:02:39 -0400 Received: from [10.36.112.17] (ovpn-112-17.ams2.redhat.com [10.36.112.17]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r4K72arc005788; Mon, 20 May 2013 03:02:37 -0400 Message-ID: <5199CA8B.7000805@redhat.com> Date: Mon, 20 May 2013 10:02:35 +0300 From: "marios@redhat.com" User-Agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130402 Thunderbird/17.0.5 MIME-Version: 1.0 To: dev@deltacloud.apache.org CC: "Koper, Dies" Subject: Re: how does create_xxx_url work? References: <434A0ECB689CAF49A3A2321F30F2AB83265245C0@FALEX03.au.fjanz.com> In-Reply-To: <434A0ECB689CAF49A3A2321F30F2AB83265245C0@FALEX03.au.fjanz.com> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-Virus-Checked: Checked by ClamAV on apache.org On 20/05/13 07:45, Koper, Dies wrote: > Hi Michal, all > > I've started on the implementation of system import/export, advertising > the operations on the collections and resources. > The export operation seems to work: I can expose the url in a system, it > shows up when I retrieve the system, and when I do a POST on that url, > my driver's export_system method is invoked. > > https://github.com/dkoper/deltacloud-core/commit/e93def6de7b1a088d230b32 > 842a349059f12e88c > had a quick look - some comments inline: > I'm having problems with the import operation. > I'm following the add operation as example. > be careful with your namings+copy/paste - like https://github.com/dkoper/deltacloud-core/commit/e93def6de7b1a088d230b32842a349059f12e88c#L6L-1 you are defining 'import' for class CIMI::Service::SystemTemplateExport > The add operation seems to be processed in two locations: > Base.rb: > def self.list(ctx) > ... > params[:add_url] = create_url(ctx) > if model_class == CIMI::Model::System > params[:system] = id > end > model_class.list(id, entries, > params).select_by(ctx.params['$select']).filter_by(ctx.params['$filter'] > ) > > with create_url: > def self.create_url(ctx) > cimi_create = "create_#{model_name}_url" > dcloud_create = ctx.deltacloud_create_method_for(model_name) > if(ctx.respond_to?(cimi_create) && > ctx.driver.respond_to?(dcloud_create)) || provides?(model_name) > ctx.send(cimi_create) > end > end > > Collections.rb: > ... > params[:entries] = entries > params[:count] = params[:entries].size > if params[:add_url] > params[:operations] ||= [] > params[:operations] << { :rel => "add", :href => > params.delete(:add_url) } > end > collection_class.new(params) > ... > > > So I have added similar code for import (see url above), but > ctx.respond_to?(cimi_import) in my self.import_url returns nil for me. > Should I be doing this differently? Or do I need to add other code > elsewhere for this operation to work? I can't see where 'cimi_import' is being defined in that commit. More generally, are you sure you want/need to define new Service classes for the import/export? Can't these just be added to the System and SystemTemplate Service classes? There may well be a legitimate reason but it's Monday morning here so please help me out ;) (edit: see below - I think it does make sense, actually) This is the reason you're getting the error below from the require_relative on the Service class. The code in lib/cimi/service/base.rb (which is where you're getting explosions) is trying to determine the corresponding Model class - for CIMI::Service::SystemTemplateImport for example as it says: uninitialized constant CIMI::Model::SystemTemplateImport because the code is doing something like: 33 def model_class$ 34 CIMI::Model.const_get(name.split('::').last)$ 35 end$ So, either you define a CIMI::Model::SystemTemplateImport, but I'm not sure yet if we need that. This is the same question as above, i.e. "are you sure you want/need to define new Service classes for the import/export?". I can see how that would make sense though, in the same way we have a 'MachineCreate' Model and 'MachineCreate' Service. So you need to determine the attributes of the SystemImport model (like 'source' ?) and continue in that way (yes, I think I just convinced myself that creating stand-alone SystemImport model makes sense... :) ) hope it helps, marios > > ... > I just noticed that I didn't require_relative the import and export > classes in service.rb. When I add that, I get an error: > > 18 cloud providers loaded. > d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:34: > in `const_get': uninitialized constant CIMI::Model::SystemTemplateImport > (NameError) > from > d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:34: > in `model_class' > from > d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/base.rb:47: > in `inherited' > from > d:/sources/OSS/cloud/deltacloud-core/server/lib/cimi/service/system_temp > late_import.rb:16:in `' > > What am I missing? > > Thanks, > Dies Koper > > >