audiolize / vagrant-softlayer

This is a Vagrant plugin that adds a SoftLayer provider to Vagrant, allowing Vagrant to control and provision SoftLayer CCI instances.
MIT License
42 stars 15 forks source link

Error from SL API: Unable to find image template #0. #58

Open poflynn opened 9 years ago

poflynn commented 9 years ago

Anyone seen this before? Our VagrantFile etc hasn't changed, I just fired up a new machine, installed latest vagrant, latest plug-in etc and am suddenly getting this error. The same VagrantFile continues to work fine on my old machine using slightly older versions of vagrant and this plugin. We are using an image provided by SL ("provider.operating_system = "CENTOS_5_64""), not a custom one.

Any thoughts? I also logged a ticket with SL,

Thanks,

Paul

Bringing machine 'default' up with 'softlayer' provider...
==> default: Creating a new SoftLayer instance...
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
riethm commented 9 years ago

Same issue here. Also have a ticket opened. Appears verifyOrder is not happy with the order template being generated by generateOrderTemplate (bad imageTemplateId in the generated template).

ju2wheels commented 9 years ago

Hi, if you can provide some debug output by setting VAGRANT_LOG=debug in environment variable it would help us figure out if theres something we need to fix here, in upstream, or pass it up to the SoftLayer API side.

cc @SLsthompson looks like its an api bug for now.

riethm commented 9 years ago

Debug output: https://gist.github.com/riethm/367a8339d13699fc183a

ju2wheels commented 9 years ago

Im trying to reproduce this using the upstream softlayer_api alone outside of vagrant-softlayer but my current test on verify_order is passing.

Can you provide the dump for us of your order template stripped of any confidential stuff as needed by doing the following:

  1. Disable the debug log:

    unset VAGRANT_LOG
  2. Edit /home/riethm/.vagrant.d/gems/gems/vagrant-softlayer-0.4.0/lib/vagrant-softlayer/action/create_instance.rb and add a line to dump the order hash so it looks like this:

           def call(env)
             @env = env
    
             @env[:ui].info I18n.t("vagrant_softlayer.vm.creating")
    
             #add this
             pp env[:sl_client]["SoftLayer_Virtual_Guest"].generateOrderTemplate(order_template)
    
             sl_warden { env[:sl_client]["SoftLayer_Product_Order"].verifyOrder(env[:sl_client]["SoftLayer_Virtual_Guest"].generateOrderTemplate(order_template)) }
    
             result = sl_warden { env[:sl_client]["SoftLayer_Virtual_Guest"].createObject(order_template) }
             @env[:machine].id = result["id"].to_s
    
             @app.call(@env)
           end
  3. Rerun test and provide the hash dump.
poflynn commented 9 years ago

Did you really mean to include the "pp" at the beginning of that line? I get:

.vagrant.d/gems/gems/vagrant-softlayer-0.4.0/lib/vagrant-softlayer/action/create_instance.rb:18:in `call': undefined method `pp' for #<VagrantPlugins::SoftLayer::Action::CreateInstance:0x00000001b1aa48> (NoMethodError)
    from /opt/vagrant/embedded/gems/gems/vagrant-1.7.2/lib/vagrant/action/warden.rb:34:in `call'

So I took the liberty of adding this line instead:

   @env[:sl_client]["SoftLayer_Virtual_Guest"].generateOrderTemplate(order_template)

But I didn't get any extra output. Sorry but I guess my Ruby isn't good enough. Let me know what else I can try. Thanks for your support.

Bringing machine 'default' up with 'softlayer' provider...
==> default: Creating a new SoftLayer instance...
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
ju2wheels commented 9 years ago

Sorry, i thought that was automatically loaded with 2.x, add a require above the pp line:

require 'pp'
pp env[:sl_client]["SoftLayer_Virtual_Guest"].generateOrderTemplate(order_template)
riethm commented 9 years ago

Here it is:

==> default: Creating a new SoftLayer instance...
{"imageTemplateId"=>"",
 "location"=>"37473",
 "packageId"=>46,
 "quantity"=>1,
 "sourceVirtualGuestId"=>"",
 "useHourlyPricing"=>true,
 "complexType"=>"SoftLayer_Container_Product_Order_Virtual_Guest",
 "prices"=>
  [{"hourlyRecurringFee"=>"xx",
    "id"=>1641,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"2 x 2.0 GHz Cores"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>1646,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"4 GB"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>37202,
    "recurringFee"=>"xx",
    "item"=>
     {"description"=>
       "Ubuntu Linux 14.04 LTS Trusty Tahr - Minimal Install (64 bit)"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>13899,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"25 GB (LOCAL)"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>55,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"Host Ping"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>57,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"Email and Ticket"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>58,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"Automated Notification"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>272,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"10 Mbps Public & Private Network Uplinks"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>1800,
    "item"=>{"description"=>"0 GB Bandwidth"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>420,
    "recurringFee"=>"xx",
    "item"=>
     {"description"=>"Unlimited SSL VPN Users & 1 PPTP VPN User per account"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>418,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"Nessus Vulnerability Assessment & Reporting"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>905,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"Reboot / Remote Console"}},
   {"hourlyRecurringFee"=>"xx",
    "id"=>21,
    "recurringFee"=>"xx",
    "item"=>{"description"=>"1 IP Address"}}],
 "sshKeys"=>[{"sshKeyIds"=>[8981]}],
 "virtualGuests"=>
  [{"domain"=>"example.com", "hostname"=>"vagrant-softlayer-test"}]}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.

Aside from the recurringFee (I changed all to 'xx'), this is verbatim

ju2wheels commented 9 years ago

Crap sorry, was looking for the pre converted order hash it should have been this:

require 'pp'
pp order_template
poflynn commented 9 years ago

Here's mine with a few "999999"s thrown in

Bringing machine 'default' up with 'softlayer' provider...
==> default: Creating a new SoftLayer instance...
{"imageTemplateId"=>"",
 "location"=>"18171",
 "packageId"=>46,
 "quantity"=>1,
 "sourceVirtualGuestId"=>"",
 "useHourlyPricing"=>true,
 "complexType"=>"SoftLayer_Container_Product_Order_Virtual_Guest",
 "prices"=>
  [{"hourlyRecurringFee"=>".041",
    "id"=>1641,
    "recurringFee"=>"30",
    "item"=>{"description"=>"2 x 2.0 GHz Cores"}},
   {"hourlyRecurringFee"=>".077",
    "id"=>1646,
    "recurringFee"=>"50.4",
    "item"=>{"description"=>"4 GB"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>13945,
    "recurringFee"=>"0",
    "item"=>{"description"=>"CentOS 6.x - Minimal Install (64 bit)"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>13899,
    "recurringFee"=>"0",
    "item"=>{"description"=>"25 GB (LOCAL)"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>55,
    "recurringFee"=>"0",
    "item"=>{"description"=>"Host Ping"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>57,
    "recurringFee"=>"0",
    "item"=>{"description"=>"Email and Ticket"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>58,
    "recurringFee"=>"0",
    "item"=>{"description"=>"Automated Notification"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>273,
    "recurringFee"=>"0",
    "item"=>{"description"=>"100 Mbps Public & Private Network Uplinks"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>1800,
    "item"=>{"description"=>"0 GB Bandwidth"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>420,
    "recurringFee"=>"0",
    "item"=>
     {"description"=>"Unlimited SSL VPN Users & 1 PPTP VPN User per account"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>418,
    "recurringFee"=>"0",
    "item"=>{"description"=>"Nessus Vulnerability Assessment & Reporting"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>905,
    "recurringFee"=>"0",
    "item"=>{"description"=>"Reboot / Remote Console"}},
   {"hourlyRecurringFee"=>"0",
    "id"=>21,
    "recurringFee"=>"0",
    "item"=>{"description"=>"1 IP Address"}}],
 "provisionScripts"=>
  ["https://999999.com/repos/SoftLayer/softlayerPostInstall.sh"],
 "sshKeys"=>[{"sshKeyIds"=>[999999]}],
 "virtualGuests"=>
  [{"domain"=>"999999.com",
    "hostname"=>"999999",
    "primaryBackendNetworkComponent"=>{"networkVlan"=>{"id"=>999999}},
    "primaryNetworkComponent"=>{"networkVlan"=>{"id"=>999999}}}]}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
riethm commented 9 years ago

How about this?

==> default: Creating a new SoftLayer instance...
{"dedicatedAccountHostOnlyFlag"=>false,
 "domain"=>"example.com",
 "hostname"=>"vagrant-softlayer-test",
 "hourlyBillingFlag"=>true,
 "localDiskFlag"=>true,
 "maxMemory"=>4096,
 "networkComponents"=>[{:maxSpeed=>10}],
 "privateNetworkOnlyFlag"=>false,
 "sshKeys"=>[{:id=>8981}],
 "startCpus"=>2,
 "datacenter"=>{:name=>"wdc01"},
 "operatingSystemReferenceCode"=>"UBUNTU_LATEST"}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
poflynn commented 9 years ago

Or this?

==> default: Creating a new SoftLayer instance...
{"dedicatedAccountHostOnlyFlag"=>false,
 "domain"=>"999999.com",
 "hostname"=>"999999",
 "hourlyBillingFlag"=>true,
 "localDiskFlag"=>true,
 "maxMemory"=>"4096",
 "networkComponents"=>[{:maxSpeed=>100}],
 "privateNetworkOnlyFlag"=>false,
 "sshKeys"=>[{:id=>999999}],
 "startCpus"=>"2",
 "datacenter"=>{:name=>"sea01"},
 "operatingSystemReferenceCode"=>"CENTOS_6_64",
 "postInstallScriptUri"=>
  "https://999999.com/repos/SoftLayer/softlayerPostInstall.sh",
 "primaryBackendNetworkComponent"=>{:networkVlan=>{:id=>999999}},
 "primaryNetworkComponent"=>{:networkVlan=>{:id=>999999}}}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
ju2wheels commented 9 years ago

Looks like you might have hit a validation bug on our end. You dont have disk_capacity defined which is required for using operating_system.

SLsthompson commented 9 years ago

It looks like the "imageTemplateId" field is assigned to the empty string:

Bringing machine 'default' up with 'softlayer' provider...
==> default: Creating a new SoftLayer instance...
{"imageTemplateId"=>"",

If I had to guess I would say this is a variant of the problem where our XMLRPC interface is not able to handle "nil" values properly.

poflynn commented 9 years ago

That's what I get for doing 2 things at once, sorry.

==> default: Creating a new SoftLayer instance...
{"dedicatedAccountHostOnlyFlag"=>false,
 "domain"=>"999999.com",
 "hostname"=>"vault-999999",
 "hourlyBillingFlag"=>true,
 "localDiskFlag"=>"false",
 "maxMemory"=>"4096",
 "networkComponents"=>[{:maxSpeed=>100}],
 "privateNetworkOnlyFlag"=>false,
 "sshKeys"=>[{:id=>999999}],
 "startCpus"=>"2",
 "blockDevices"=>[{"device"=>"0", "diskImage"=>{"capacity"=>"25"}}],
 "datacenter"=>{:name=>"sea01"},
 "operatingSystemReferenceCode"=>"CENTOS_6_64",
 "postInstallScriptUri"=>
  "https://999999.com/repos/SoftLayer/softlayerPostInstall.sh",
 "primaryBackendNetworkComponent"=>{:networkVlan=>{:id=>999999}},
 "primaryNetworkComponent"=>{:networkVlan=>{:id=>999999}}}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
riethm commented 9 years ago

Same for me:

==> default: Creating a new SoftLayer instance...
{"dedicatedAccountHostOnlyFlag"=>false,
 "domain"=>"example.com",
 "hostname"=>"vagrant-softlayer-test",
 "hourlyBillingFlag"=>true,
 "localDiskFlag"=>true,
 "maxMemory"=>4096,
 "networkComponents"=>[{:maxSpeed=>10}],
 "privateNetworkOnlyFlag"=>false,
 "sshKeys"=>[{:id=>8981}],
 "startCpus"=>2,
 "blockDevices"=>[{"device"=>"0", "diskImage"=>{"capacity"=>"25"}}],
 "datacenter"=>{:name=>"wdc01"},
 "operatingSystemReferenceCode"=>"UBUNTU_LATEST"}
Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException
Exception message: Unable to find image template #0.
poflynn commented 9 years ago

We have a few machines using vagrant and this plug-in. It's worth noting that this was working fine on a brand new machine for the last week+ or so and then suddenly started giving this error somewhere between Wed. night and Thurs. morning of this week.

ju2wheels commented 9 years ago

@SLsthompson so our only solution would be not to pipe the generateOrderTemplate output into product verifyOrder as a result of that?:

https://github.com/audiolize/vagrant-softlayer/blob/master/lib/vagrant-softlayer/action/create_instance.rb#L18

Upstream you are just calling generateOrderTemplate for verify, will that basically do the same as verifyOrder in terms of throwing exceptions if the requested order template is wrong?

I guess Im not understanding how this would be an issue now and not before (since we have been on the XMLRPC for a while now with this like that).

ju2wheels commented 9 years ago

@poflynn, @riethm short term fix is probably just to comment out the order verification line for now (untested), I dont see anything wrong with the order options themselves aside for the validation bug we have to fix.

Change it to:

        def call(env)
          @env = env

          @env[:ui].info I18n.t("vagrant_softlayer.vm.creating")

          #sl_warden { env[:sl_client]["SoftLayer_Product_Order"].verifyOrder(env[:sl_client]["SoftLayer_Virtual_Guest"].generateOrderTemplate(order_template)) }

          result = sl_warden { env[:sl_client]["SoftLayer_Virtual_Guest"].createObject(order_template) }
          @env[:machine].id = result["id"].to_s

          @app.call(@env)
        end
SLsthompson commented 9 years ago

verifyOrder can take a block that can change the template. You could add a block that strips out the offending empty field.

Now that the REST interface handles Object Filters... in the long run we could switch all of the softlayer_api back to the REST interface (which does handle nil properly). I've also got an internal ask for the XMLRPC interface to support the extension that allows it to handle nil's properly, but that's having a bit of trouble bubbling up high enough in the priority queue.

ju2wheels commented 9 years ago

We are still using the service calls directly we havent migrated to the upstream VirtualServerOrder instances, which is why I think we are seeing this (I think if we move to VirtualServerOrder we would not see this problem).

ju2wheels commented 9 years ago

OK so based on testing it is the XMLRPC issue with empty string but technically the bug is upstream in the API (im guessing it wants the equivalent of nil and not the empty string since when I delete the imageTemplateId it works, and thats consistent with the API turning the empty string into an int and getting template number 0).

This also highlights a logic problem in upstream softlayer_apis VirtualServerOrder#verify as its only really verifying that you have added the minimum number of required properties to the template when you call SoftLayer_Virtual_Guest#generateOrderTemplate and not that the values provided to that template actually verify to a usable order (I added bad vlan values and it went along its merry way until i sent it SoftLayer_Product_Order#verifyOrder, meaning that if you call VirtualServerOrder#verify before VirtualServerOrder#order you can still end up with a bad order making the verify call useless.

Regardless of the above, it also means something changed in the API this week for this to stop working now because we havent changed this code in months since we moved to XMLRPC.

poflynn commented 9 years ago

I tried to tell SL something must have changed in their API but as always you mention this plug-in and they just reply saying it is unsupported, which I'd expect them to say, but really IMO they should be bending over backwards to help you given the popularity of Vagrant. But I guess that's another battle for another day. I did send them the link to this issue BTW. Thanks again for your efforts.

ju2wheels commented 9 years ago

Par the course, which is why I was trying to do a minimal test without vagrant-softlayer and only with softlayer_api to prove it was on their end, and it absolutely is but we can find a way to work around.

bmpotter commented 9 years ago

BTW, wanted to let you know that i also ran into this problem and found this thread via google. I'm a developer for Gateway as a Service for SoftLayer (https://gateway-as-a-service.com/) and as part of that we order virtual svr instances via the SL API python client. The situation is as you say: the generateOrderTemplate() method returns an order structure with 'imageTemplateId' as a key whose value is the empty string, and the verifyOrder() method can't seem to handle that. (Although the error has been on and off for the last several weeks, and i'm not sure why.)

But the work around is easy: after calling generateOrderTemplate() to get the order structure, remove the imageTemplateId key from it before passing it to verifyOrder.

SLsthompson commented 9 years ago

The fundamental issue causing this is being looked at internally and a fix may be forthcoming. No timelines are available yet.

ghost commented 9 years ago

It appears the fundamental issue is also breaking provisioning with image_guid.

Bringing machine 'default' up with 'softlayer' provider... ==> default: Creating a new SoftLayer instance... {"imageTemplateGlobalIdentifier"=>"5f7b6ca6-14f5-4de1-a19c-d1b72e85c1f4", "imageTemplateId"=>"", "location"=>"449600", "packageId"=>46, "quantity"=>1, "sourceVirtualGuestId"=>"", "useHourlyPricing"=>true, "complexType"=>"SoftLayer_Container_Product_Order_Virtual_Guest", "prices"=> [{"hourlyRecurringFee"=>".016", "id"=>26125, "recurringFee"=>"10.88", "item"=>{"description"=>"1 x 2.0 GHz Core"}}, {"hourlyRecurringFee"=>".015", "id"=>32597, "recurringFee"=>"10.15", "item"=>{"description"=>"1 GB"}}, {"hourlyRecurringFee"=>".004", "id"=>26466, "recurringFee"=>"2.9", "item"=>{"description"=>"100 GB (LOCAL)"}}, {"hourlyRecurringFee"=>"0", "id"=>27023, "recurringFee"=>"0", "item"=>{"description"=>"Host Ping"}}, {"hourlyRecurringFee"=>"0", "id"=>32500, "recurringFee"=>"0", "item"=>{"description"=>"Email and Ticket"}}, {"hourlyRecurringFee"=>"0", "id"=>32627, "recurringFee"=>"0", "item"=>{"description"=>"Automated Notification"}}, {"hourlyRecurringFee"=>"0", "id"=>22829, "recurringFee"=>"0", "item"=>{"description"=>"10 Mbps Public & Private Network Uplinks"}}, {"hourlyRecurringFee"=>"0", "id"=>34183, "item"=>{"description"=>"0 GB Bandwidth"}}, {"hourlyRecurringFee"=>"0", "id"=>33483, "recurringFee"=>"0", "item"=> {"description"=>"Unlimited SSL VPN Users & 1 PPTP VPN User per account"}}, {"hourlyRecurringFee"=>"0", "id"=>35310, "recurringFee"=>"0", "item"=>{"description"=>"Nessus Vulnerability Assessment & Reporting"}}, {"hourlyRecurringFee"=>"0", "id"=>23070, "recurringFee"=>"0", "item"=>{"description"=>"Reboot / Remote Console"}}, {"hourlyRecurringFee"=>"0", "id"=>34807, "recurringFee"=>"0", "item"=>{"description"=>"1 IP Address"}}], "sshKeys"=>[{"sshKeyIds"=>[230443]}], "virtualGuests"=>[{"domain"=>"siqcloud.com", "hostname"=>"awctest"}]} Vagrant returned an exception while calling the SoftLayer API.

Exception class: XMLRPC::FaultException Exception message: Order is missing the following category: Operating System.

underscorephil commented 9 years ago

Howdy!

We pushed out a release that should resolve this issue. @ju2wheels did some initial testing and it is looking good. Please try again and let us know if anything is wonky.

poflynn commented 9 years ago

It appears to work! Awesome, thanks everyone.