Sha256: 5b084feb7603467ef4667a88823219ec5453e6558bb89152d2cdb9ca034fbf79

Contents?: true

Size: 1.26 KB

Versions: 53

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

53 entries across 53 versions & 3 rubygems

Version Path
fog-1.22.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.21.0 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.20.0.20140305101839 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.20.0.20140305101305 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140212012611 lib/fog/cloudsigma/requests/update_server.rb
fog-1.20.0 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140110004459 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140110003812 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140109202555 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140107192102 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20140107142106 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.19.0.20131219203941 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131219193542 lib/fog/cloudsigma/requests/update_server.rb
fog-1.19.0 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131219033443 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131219032002 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131219030716 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131219022322 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131218202447 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.18.0.20131209091424 lib/fog/cloudsigma/requests/update_server.rb