fog / fog-openstack

Fog for OpenStack Platform
MIT License
68 stars 130 forks source link

Issue on openstack update_quota (Mitaka+) #245

Open kensoncheung opened 7 years ago

kensoncheung commented 7 years ago

Hi,

I've been using the fog-openstack gem to manage my Juno version openstack, update_quota is fine with Juno. However, recently when I tried to use Mitaka version, seems like the openstack reports error when I call update_quota.

Error as below:

Expected(200) <=> Actual(400 Bad Request) excon.error.response :body => "{\"badRequest\": {\"message\": \"Invalid input for field/attribute quota_set. Value: {u'injected_file_content_bytes': 10240, u'metadata_items': 128, u'server_group_members': 10, u'server_groups': 10, u'tenant_id': u'0d664fd9e2a2418dbde4ec40d586a04c', u'ram': 96000, u'floating_ips': 10, u'key_pairs': 100, u'instances': 40, u'security_group_rules': 20, u'injected_files': 15, u'cores': 30, u'fixed_ips': -1, u'injected_file_path_bytes': 255, u'security_groups': 10}. Additional properties are not allowed (u'tenant_id' was unexpected)\", \"code\": 400}}" :cookies => [ ] :headers => { "Content-Length" => "545" "Content-Type" => "application/json; charset=UTF-8" "Date" => "Fri, 02 Dec 2016 04:03:14 GMT" "Vary" => "X-OpenStack-Nova-API-Version" "X-Compute-Request-Id" => "req-ce2f1e7a-35be-4a49-b4a6-7b1bf7f5c768" "X-Openstack-Nova-Api-Version" => "2.1" } :host => "192.168.10.201" :local_address => "192.168.10.29" :local_port => 34650 :path => "/v2.1/3c9a0903c107451fb7229482fe0ff0a8//os-quota-sets/0d664fd9e2a2418dbde4ec40d586a04c" :port => 8774 :reason_phrase => "Bad Request" :remote_ip => "192.168.10.201" :status => 400 :status_line => "HTTP/1.1 400 Bad Request\r\n"

It says the tenant_id was unexpected from the quota_set. This was okay for Juno, but seems newer openstack version starts to have stricter validation on the quota_set. I saw that the related method definiton in master branch will merge the tenant_id to quota_set, although quota_set is already part of path. Do you think if it's better to remove the tenant_id from quota_set?

module Fog
  module Compute
    class OpenStack
      class Real
        def update_quota(tenant_id, options = {})
          options['tenant_id'] = tenant_id
          request(
            :body    => Fog::JSON.encode('quota_set' => options),
            :expects => 200,
            :method  => 'PUT',
            :path    => "/os-quota-sets/#{tenant_id}"
          )
        end
      end
    end
  end
end

Similar issues refs.: https://bugzilla.redhat.com/show_bug.cgi?id=1390147

seanhandley commented 7 years ago

See https://github.com/fog/fog-openstack/pull/249