DeltaCloud
  1. DeltaCloud
  2. DTACLOUD-122

Unable to create an image when an instance is in Stopped state in VSPHERE

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Component/s: Client (Ruby)
    • Labels:
      None
    • Environment:
      OS- RHEL 6.1, Fedora 15, 16
      Deltacloud API 0.4.1
      Commit - 6391208adab40cc288491f24c2f9f3e16b330611
      VSPHERE version - 4

      Description

      Unable to create an image when an instance is in Stopped state in VSPHERE

      Reproduction Steps:
      ===============
      1. Setup DCloud on VSPHERE configuration
      2. Choose an Image and start the instance
      3. Stop the instance and then click on the "Create image" button once the instance is in Stopped state
      4. Enter the Name and Description and click on the "Create" button

      Expected Result:
      =============
      Should be able to create the image successfully

      Actual Restult:
      ===========
      Throws stack trace in the console as mentioned below.

      Stack Trace:
      ===========
      10.11.11.172 - - [02/Jan/2012 18:31:17] "GET /api/images/new?instance_id=ramesh-test-image HTTP/1.1" 200 2741 0.0239
      ./bin/../lib/deltacloud/server.rb:244: warning: Object#id will be deprecated; use Object#object_id
      ./bin/../views/images/show.html.haml:2: warning: Object#id will be deprecated; use Object#object_id
      NoMethodError - undefined method `name' for #<Array:0x7fbe30504ab0>:
      ./bin/../views/images/show.html.haml:8:in `evaluate_source'
      /usr/lib/ruby/gems/1.8/gems/tilt-1.3.3/lib/tilt/template.rb:144:in `cached_evaluate'
      /usr/lib/ruby/gems/1.8/gems/tilt-1.3.3/lib/tilt/template.rb:127:in `evaluate'
      /usr/lib/ruby/gems/1.8/gems/tilt-1.3.3/lib/tilt/haml.rb:24:in `evaluate'
      /usr/lib/ruby/gems/1.8/gems/tilt-1.3.3/lib/tilt/template.rb:76:in `render'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:625:in `render_without_format'
      ./bin/../lib/sinatra/rack_accept.rb:36:in `render'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:522:in `haml'
      ./bin/../lib/deltacloud/server.rb:248
      ./bin/../lib/sinatra/rack_accept.rb:86:in `call'
      ./bin/../lib/sinatra/rack_accept.rb:86:in `respond_to'
      ./bin/../lib/deltacloud/server.rb:245
      ./bin/../lib/sinatra/rabbit.rb:125:in `instance_eval'
      ./bin/../lib/sinatra/rabbit.rb:125:in `POST /api/images'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:1211:in `call'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:1211:in `compile!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `[]'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `route!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:788:in `route_eval'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:772:in `route!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:821:in `process_route'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `catch'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:819:in `process_route'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:771:in `route!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `each'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:770:in `route!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:886:in `dispatch!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `call!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `invoke'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `catch'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:871:in `invoke'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:706:in `call!'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:692:in `call'
      ./bin/../lib/sinatra/rack_date.rb:31:in `call'
      ./bin/../lib/sinatra/rack_accept.rb:149:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/path_traversal.rb:16:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/json_csrf.rb:17:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/base.rb:47:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/nulllogger.rb:9:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/showexceptions.rb:21:in `call'
      ./bin/../lib/sinatra/rack_driver_select.rb:45:in `call'
      ./bin/../lib/sinatra/rack_matrix_params.rb:106:in `call'
      ./bin/../lib/sinatra/rack_runtime.rb:36:in `call'
      ./bin/../lib/sinatra/rack_etag.rb:41:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-accept-0.4.4/lib/rack/accept/context.rb:22:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/path_traversal.rb:16:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/json_csrf.rb:17:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/base.rb:47:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-protection-1.1.4/lib/rack/protection/xss_header.rb:22:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/logger.rb:15:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/commonlogger.rb:20:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/head.rb:9:in `call'
      /usr/lib/ruby/gems/1.8/gems/rack-1.3.5/lib/rack/methodoverride.rb:24:in `call'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `call'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:1403:in `synchronize'
      /usr/lib/ruby/gems/1.8/gems/sinatra-1.3.1/lib/sinatra/base.rb:1334:in `call'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:84:in `pre_process'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:82:in `catch'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:82:in `pre_process'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1060:in `call'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1060:in `spawn_threadpool'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1057:in `initialize'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1057:in `new'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1057:in `spawn_threadpool'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:1049:in `defer'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:54:in `process'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/connection.rb:42:in `receive_data'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run_machine'
      /usr/lib/ruby/gems/1.8/gems/eventmachine-0.12.10/lib/eventmachine.rb:256:in `run'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/backends/base.rb:61:in `start'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/server.rb:159:in `start'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/controllers/controller.rb:86:in `start'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:185:in `send'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:185:in `run_command'
      /usr/lib/ruby/gems/1.8/gems/thin-1.2.11/lib/thin/runner.rb:151:in `run!'
      ./bin/deltacloudd:235
      10.11.11.172 - - [02/Jan/2012 18:33:05] "POST /api/images HTTP/1.1" 500 124703 38.0339

        Activity

        Hide
        Ronelle Landy added a comment -

        Closing this JIRA ... verified documentation note copied below ...

        Note:

        When you create an image from a stopped instance in vSphere cloud, this particular instance is marked as template and it is also removed from Instances.

        Unlike other providers, vSphere does not support assigning a name and a description to the image when you create an image from a stopped instance. The image created in vSphere ignores these attributes passed to the API during the creation.

        Show
        Ronelle Landy added a comment - Closing this JIRA ... verified documentation note copied below ... Note: When you create an image from a stopped instance in vSphere cloud, this particular instance is marked as template and it is also removed from Instances. Unlike other providers, vSphere does not support assigning a name and a description to the image when you create an image from a stopped instance. The image created in vSphere ignores these attributes passed to the API during the creation.
        Hide
        Dagmar Husarova added a comment -

        Added a note to nanoc site API --> Compute resources --> Images --> Create an image

        Show
        Dagmar Husarova added a comment - Added a note to nanoc site API --> Compute resources --> Images --> Create an image
        Hide
        Ronelle Landy added a comment -

        Moving this JIRA to doc for the next release:

        Copying chat comments:
        <rlandy> mfojtik: do we plan to support assigning a name and description to the image (when creating an image from a stopped instance)?
        <mfojtik> rlandy: I don't think that setting a name and description will be supported any time soon

        Since other providers support assigning name/description and considering that 'create image' in vsphere has a different result in general, assigning this JIRA to doc - to note these differences to users.

        Show
        Ronelle Landy added a comment - Moving this JIRA to doc for the next release: Copying chat comments: <rlandy> mfojtik: do we plan to support assigning a name and description to the image (when creating an image from a stopped instance)? <mfojtik> rlandy: I don't think that setting a name and description will be supported any time soon Since other providers support assigning name/description and considering that 'create image' in vsphere has a different result in general, assigning this JIRA to doc - to note these differences to users.
        Hide
        Ronelle Landy added a comment -

        Marking this JIRA as a blocker because the Vsphere image created does not take the 'name' and 'description' passed to the API during creation.
        If it is not possible/ not desirable to have the user give the image a name and/description in the POST action to create the image, please note and doc this.

        Show
        Ronelle Landy added a comment - Marking this JIRA as a blocker because the Vsphere image created does not take the 'name' and 'description' passed to the API during creation. If it is not possible/ not desirable to have the user give the image a name and/description in the POST action to create the image, please note and doc this.
        Hide
        Ronelle Landy added a comment -

        Comment on previous comments saved: ... Sending this JIRA for 'documentation to be added'.

        'Create Image' operation has different consequences in Vsphere as in Rhevm and ec2:

        Notes from chat conversation with Michal Fojtik:

        <mfojtik> yes that need to be documented... in vsphere when you create an image from the instance... the instance is being marked as 'template'
        <mfojtik> rlandy: mean that the instance is being removed from 'instances'
        <mfojtik> rlandy: we need to document that behavior
        <rlandy> mfojtik: ok ... then what parameters are supported when creating and image from an instance in vsphere?
        <mfojtik> rlandy: name and description are ignored

        <mfojtik> rlandy: there is no way how to achieve that the instance will stay in instances
        <mfojtik> rlandy: find_vm(credentials, opts[:id])[:instance].MarkAsTemplate

        Users need to be aware that when they 'create image' from a stopped instance in Vsphere, it is equivalent to 'marking that instance as a template'. The instance itself will be removed from 'Instances' ( question: along with any user_data.?? )

        Show
        Ronelle Landy added a comment - Comment on previous comments saved: ... Sending this JIRA for 'documentation to be added'. 'Create Image' operation has different consequences in Vsphere as in Rhevm and ec2: Notes from chat conversation with Michal Fojtik: <mfojtik> yes that need to be documented... in vsphere when you create an image from the instance... the instance is being marked as 'template' <mfojtik> rlandy: mean that the instance is being removed from 'instances' <mfojtik> rlandy: we need to document that behavior <rlandy> mfojtik: ok ... then what parameters are supported when creating and image from an instance in vsphere? <mfojtik> rlandy: name and description are ignored <mfojtik> rlandy: there is no way how to achieve that the instance will stay in instances <mfojtik> rlandy: find_vm(credentials, opts [:id] ) [:instance] .MarkAsTemplate Users need to be aware that when they 'create image' from a stopped instance in Vsphere, it is equivalent to 'marking that instance as a template'. The instance itself will be removed from 'Instances' ( question: along with any user_data.?? )
        Hide
        Ronelle Landy added a comment -

        Reopening this issue for three reasons:

        1) When creating an image from a stopped instance, Deltacloud ignores the 'name' parameter and just assigns the image the same name as the instance from which is was created. ( see results copied below)

        curl -X POST -F "instance_id=rlandyInstanceFromGUI" -F "name=rlandyCurlImage2" --user 'uname:password "http://localhost:3010/api/images?format=xml"
        <?xml version='1.0' encoding='utf-8' ?>
        <image href='http://localhost:3010/api/images/rlandyInstanceFromGUI' id='rlandyInstanceFromGUI'>
        <name>rlandyInstanceFromGUI</name>
        <owner_id>Administrator</owner_id>
        <description>Other Linux (64-bit)</description>
        <architecture>x86_64</architecture>
        <state>AVAILABLE</state>
        <hardware_profiles>
        <hardware_profile href='http://localhost:3010/api/hardware_profiles/default' id='default' rel='hardware_profile'></hardware_profile>
        </hardware_profiles>
        <actions>
        <link href='http://localhost:3010/api/instances;image_id=rlandyInstanceFromGUI' method='post' rel='create_instance' />
        </actions>
        </image>

        2) Adding the 'description' parameter errors out

        3) It deletes the instance from which it was created. This is unexpected and imho - not desirable by any user.

        Show
        Ronelle Landy added a comment - Reopening this issue for three reasons: 1) When creating an image from a stopped instance, Deltacloud ignores the 'name' parameter and just assigns the image the same name as the instance from which is was created. ( see results copied below) curl -X POST -F "instance_id=rlandyInstanceFromGUI" -F "name=rlandyCurlImage2" --user 'uname:password "http://localhost:3010/api/images?format=xml" <?xml version='1.0' encoding='utf-8' ?> <image href='http://localhost:3010/api/images/rlandyInstanceFromGUI' id='rlandyInstanceFromGUI'> <name>rlandyInstanceFromGUI</name> <owner_id>Administrator</owner_id> <description>Other Linux (64-bit)</description> <architecture>x86_64</architecture> <state>AVAILABLE</state> <hardware_profiles> <hardware_profile href='http://localhost:3010/api/hardware_profiles/default' id='default' rel='hardware_profile'></hardware_profile> </hardware_profiles> <actions> <link href='http://localhost:3010/api/instances;image_id=rlandyInstanceFromGUI' method='post' rel='create_instance' /> </actions> </image> 2) Adding the 'description' parameter errors out 3) It deletes the instance from which it was created. This is unexpected and imho - not desirable by any user.
        Hide
        Michal Fojtik added a comment -

        Hi the problem was that instead of returning image the create_image call returned array of images (with size == 1

        This patch should fix it

        diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
        index e2e7654..f3aeaa5 100644
        — a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
        +++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb
        @@ -123,7 +123,7 @@ module Deltacloud::Drivers::VSphere
        safely do
        find_vm(credentials, opts[:id])[:instance].MarkAsTemplate
        end

        • images(credentials, :id => opts[:id])
          + image(credentials, :id => opts[:id])
          end
        1. List all datacenters managed by the vSphere or vCenter entrypoint.

        Pushed in 5c9c841894b891150ceff87a3efbff84aba41292

        Show
        Michal Fojtik added a comment - Hi the problem was that instead of returning image the create_image call returned array of images (with size == 1 This patch should fix it diff --git a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb index e2e7654..f3aeaa5 100644 — a/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb +++ b/server/lib/deltacloud/drivers/vsphere/vsphere_driver.rb @@ -123,7 +123,7 @@ module Deltacloud::Drivers::VSphere safely do find_vm(credentials, opts [:id] ) [:instance] .MarkAsTemplate end images(credentials, :id => opts [:id] ) + image(credentials, :id => opts [:id] ) end List all datacenters managed by the vSphere or vCenter entrypoint. Pushed in 5c9c841894b891150ceff87a3efbff84aba41292
        Hide
        Ronelle Landy added a comment -

        Assigning to Michal Fojtik: See comments in DTACLOUD-157.

        Show
        Ronelle Landy added a comment - Assigning to Michal Fojtik: See comments in DTACLOUD-157 .

          People

          • Assignee:
            Dagmar Husarova
            Reporter:
            Ramesh A
          • Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development