Sha256: 2d20a8eeb523859df041bf242d1b8da2f68c18c775d4814f708fce7bbce34ef1

Contents?: true

Size: 1.26 KB

Versions: 43

Compression:

Stored size: 1.26 KB

Contents

require 'set'

module Fog
  module Compute
    class CloudSigma
      class Real
        def update_server(server_id, data)
          update_request("servers/#{server_id}/", data)
        end
      end

      class Mock
        def update_server(server_id, data)
          mock_update(data, :servers, 200, server_id) do |old_data, new_data|
            old_nics = old_data['nics']
            new_nics = new_data['nics']

            old_nics_macs = old_nics.map { |nic| nic['mac'] }.compact
            new_nics_macs = new_nics.map { |nic| nic['mac'] }.compact

            newly_created_macs = Set.new(new_nics_macs) - old_nics_macs
            unless newly_created_macs.empty?
              mac_err = <<-EOS
              MAC(s) #{newly_created_macs.to_a} not specified on guest #{server_id}. Nic MACs are automatically assigned at
              creation time and cannot be changed. Do not specify MAC to create a new NIC or specify existing MAC to
              update existing NIC.
              EOS
              raise Fog::CloudSigma::Errors::RequestError.new(mac_err, 'permission')
            end

            new_nics.each { |nic| nic['mac'] ||= Fog::Compute::CloudSigma::Mock.random_mac }

            old_data.merge(new_data)
          end
        end
      end
    end
  end
end

Version data entries

43 entries across 41 versions & 6 rubygems

Version Path
fog-2.3.0 lib/fog/cloudsigma/requests/update_server.rb
fog-ifeel-2.2.0 lib/fog/cloudsigma/requests/update_server.rb
fog-2.2.0 lib/fog/cloudsigma/requests/update_server.rb
fog-2.1.0 lib/fog/cloudsigma/requests/update_server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.4.0/gems/fog-1.42.1/lib/fog/cloudsigma/requests/update_server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.3.0/gems/fog-1.42.1/lib/fog/cloudsigma/requests/update_server.rb
vagrant-packet-0.1.1 vendor/bundle/ruby/2.5.0/gems/fog-1.42.1/lib/fog/cloudsigma/requests/update_server.rb
fog-1.42.1 lib/fog/cloudsigma/requests/update_server.rb
fog-2.0.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.42.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.41.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.40.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.39.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.38.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.37.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.36.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.35.0 lib/fog/cloudsigma/requests/update_server.rb
fog-2.0.0.pre.0 lib/fog/cloudsigma/requests/update_server.rb
vagrant-cloudstack-1.2.0 vendor/bundle/gems/fog-1.32.0/lib/fog/cloudsigma/requests/update_server.rb
fog-1.34.0 lib/fog/cloudsigma/requests/update_server.rb