Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using option --boot-volume for server create throws error #9

Closed
jbuchhammer opened this issue Nov 9, 2016 · 1 comment
Closed

Using option --boot-volume for server create throws error #9

jbuchhammer opened this issue Nov 9, 2016 · 1 comment

Comments

@jbuchhammer
Copy link

When creating a server by knife profitbricks server create you may specify option --boot-volume VOLUME_ID to attach an already created volume to the new server.

In fact, his will lead to an error:
ERROR: Excon::Error::BadRequest: [{"errorCode"=>"304", "message"=>"Failed to parse request body. [line: 1, column: 108] Can not instantiate value of type [simple type, class com.profitbricks.api.rest.v1.model.pojo.Volume] from String value ('c309e8cb-45ec-4a27-9165-a4678701b5ae'); no single-String constructor/factory method"}]

How to reproduce

create volume

# knife profitbricks volume create -D '9b43cffa-d348-40f8-88ca-e4d58da5a26e' -N '0e56bd01-a1ca-11e6-addc-525400f64d8d' -P StrengGeheim -S 8 -t HDD

gives

ID: c309e8cb-45ec-4a27-9165-a4678701b5ae
Name:
Size: 8
Bus:
Image: 0e56bd01-a1ca-11e6-addc-525400f64d8d
Type: HDD
Licence Type: LINUX
Zone: AUTO
done

create server

# knife profitbricks server create -D '9b43cffa-d348-40f8-88ca-e4d58da5a26e' -n 'PBnode' -C 1 -r 2048 --boot-volume 'c309e8cb-45ec-4a27-9165-a4678701b5ae'

gives (with debug == true)

Creating server...excon.request
  :body                => "{\"properties\":{\"name\":\"PBnode\",\"cores\":\"1\",\"cpuFamily\":\"AMD_OPTERON\",\"ram\":\"2048\",\"availabilityZone\":\"AUTO\",\"bootVolume\":\"c309e8cb-45ec-4a27-9165-a4678701b5ae\"},\"entities\":{}}"
  :chunk_size          => 1048576
  :ciphers             => "HIGH:!SSLv2:!aNULL:!eNULL:!3DES"
  :connect_timeout     => 60
  :debug               => true
  :debug_request       => true
  :debug_response      => true
  :expects             => 202
  :headers             => {
    "Authorization" => "REDACTED"
    "Content-Type"  => "application/json"
    "Host"          => "api.profitbricks.com"
    "User-Agent"    => "profitbricks-ruby-sdk/3.0.0"
  }
  :host                => "api.profitbricks.com"
  :hostname            => "api.profitbricks.com"
  :idempotent          => false
  :instrumentor        => Excon::StandardInstrumentor
  :instrumentor_name   => "excon"
  :method              => :post
  :middlewares         => [
    Excon::Middleware::ResponseParser
    Excon::Middleware::Expects
    Excon::Middleware::Idempotent
    Excon::Middleware::Instrumentor
    Excon::Middleware::Mock
  ]
  :mock                => false
  :nonblock            => true
  :omit_default_port   => true
  :password            => "REDACTED"
  :path                => "/cloudapi/v3/datacenters/9b43cffa-d348-40f8-88ca-e4d58da5a26e/servers"
  :persistent          => false
  :port                => 443
  :query               => {
    :depth => 1
  }
  :read_timeout        => 60
  :retries_remaining   => 4
  :retry_limit         => 4
  :scheme              => "https"
  :ssl_uri_schemes     => [
    "https"
  ]
  :ssl_verify_peer     => true
  :stubs               => :global
  :tcp_nodelay         => false
  :thread_safe_sockets => true
  :uri_parser          => URI
  :user                => "juergen.buchhammer@profitbricks.com"
  :versions            => "excon/0.53.0 (x86_64-linux) ruby/2.3.1"
  :write_timeout       => 60
excon.error
  :error => #<Excon::Error::BadRequest: Expected(202) <=> Actual(400 Bad Request)
excon.error.request
  :body                => "{\"properties\":{\"name\":\"PBnode\",\"cores\":\"1\",\"cpuFamily\":\"AMD_OPTERON\",\"ram\":\"2048\",\"availabilityZone\":\"AUTO\",\"bootVolume\":\"c309e8cb-45ec-4a27-9165-a4678701b5ae\"},\"entities\":{}}"
  :chunk_size          => 1048576
  :ciphers             => "HIGH:!SSLv2:!aNULL:!eNULL:!3DES"
  :connect_timeout     => 60
  :debug               => true
  :debug_request       => true
  :debug_response      => true
  :expects             => 202
  :headers             => {
    "Authorization"  => "REDACTED"
    "Content-Length" => 175
    "Content-Type"   => "application/json"
    "Host"           => "api.profitbricks.com"
    "User-Agent"     => "profitbricks-ruby-sdk/3.0.0"
  }
  :host                => "api.profitbricks.com"
  :hostname            => "api.profitbricks.com"
  :idempotent          => false
  :instrumentor        => Excon::StandardInstrumentor
  :instrumentor_name   => "excon"
  :method              => :post
  :middlewares         => [
    Excon::Middleware::ResponseParser
    Excon::Middleware::Expects
    Excon::Middleware::Idempotent
    Excon::Middleware::Instrumentor
    Excon::Middleware::Mock
  ]
  :mock                => false
  :nonblock            => true
  :omit_default_port   => true
  :password            => "REDACTED"
  :path                => "/cloudapi/v3/datacenters/9b43cffa-d348-40f8-88ca-e4d58da5a26e/servers"
  :persistent          => false
  :port                => 443
  :query               => {
    :depth => 1
  }
  :read_timeout        => 60
  :retries_remaining   => 4
  :retry_limit         => 4
  :scheme              => "https"
  :ssl_uri_schemes     => [
    "https"
  ]
  :ssl_verify_peer     => true
  :stubs               => :global
  :tcp_nodelay         => false
  :thread_safe_sockets => true
  :uri_parser          => URI
  :user                => "juergen.buchhammer@profitbricks.com"
  :versions            => "excon/0.53.0 (x86_64-linux) ruby/2.3.1"
  :write_timeout       => 60
excon.error.response
  :body          => "{\n  \"httpStatus\" : 400,\n  \"messages\" : [ {\n    \"errorCode\" : \"304\",\n    \"message\" : \"Failed to parse request body. [line: 1, column: 108] Can not instantiate value of type [simple type, class com.profitbricks.api.rest.v1.model.pojo.Volume] from String value ('c309e8cb-45ec-4a27-9165-a4678701b5ae'); no single-String constructor/factory method\"\n  } ]\n}\n"
  :cookies       => [
  ]
  :headers       => {
    "Connection"                => "close"
    "Content-Type"              => "application/json"
    "Date"                      => "Wed, 09 Nov 2016 10:39:46 GMT"
    "Server"                    => "Apache/2.4.10 (Debian)"
    "Strict-Transport-Security" => "max-age=15768000"
    "X-RateLimit-Burst"         => "50"
    "X-RateLimit-Limit"         => "120"
    "X-RateLimit-Remaining"     => "49"
  }
  :host          => "api.profitbricks.com"
  :local_address => "157.97.110.139"
  :local_port    => 43566
  :path          => "/cloudapi/v3/datacenters/9b43cffa-d348-40f8-88ca-e4d58da5a26e/servers"
  :port          => 443
  :reason_phrase => "Bad Request"
  :remote_ip     => "185.48.116.14"
  :status        => 400
  :status_line   => "HTTP/1.1 400 Bad Request\r\n"
>
ERROR: Excon::Error::BadRequest: [{"errorCode"=>"304", "message"=>"Failed to parse request body. [line: 1, column: 108] Can not instantiate value of type [simple type, class com.profitbricks.api.rest.v1.model.pojo.Volume] from String value ('c309e8cb-45ec-4a27-9165-a4678701b5ae'); no single-String constructor/factory method"}]

At a first glance, the sent JSON data seems right. But actually the Cloud API v3 does not expect a simple string value for the boot volume ID in the properties section.
Instead, the API expects a structure like this

   "entities":{
      "volumes":{
         "items":[
            {
               "id":"[existing-storage-volume-id]"
            }
         ]
      }
   }
edevenport added a commit that referenced this issue Dec 5, 2016
Fixed issue with bootVolume and bootCdrom parameters (#9)
@edevenport
Copy link
Contributor

Hello @jbuchhammer - thank you for reporting this issue. Your are correct that the issue is related to the volume (and cdrom) JSON structure.

"properties": {
"name": "test-server"
"cores": 1,
"ram": "2048",
"bootVolume": { "id": "UUID" }
}

The knife command was sending "bootVolume": "UUID". I have fixed this along with the bootCdrom parameter. The fix #11 was released in v1.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants