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-maestrodev-1.15.0.20130927082724 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.15.0.20130829165835 lib/fog/cloudsigma/requests/update_server.rb
fog-1.15.0 lib/fog/cloudsigma/requests/update_server.rb
gapinc-fog-1.14.0 lib/fog/cloudsigma/requests/update_server.rb
fog-maestrodev-1.14.0.20130806165225 lib/fog/cloudsigma/requests/update_server.rb
fog-1.14.0 lib/fog/cloudsigma/requests/update_server.rb
fog-1.13.0 lib/fog/cloudsigma/requests/update_server.rb
gapinc-fog-1.12.1.2 lib/fog/cloudsigma/requests/update_server.rb
gapinc-fog-1.12.1.1 lib/fog/cloudsigma/requests/update_server.rb
gapinc-fog-1.12.1a lib/fog/cloudsigma/requests/update_server.rb
gapinc-fog-1.12.1 lib/fog/cloudsigma/requests/update_server.rb
fog-1.12.1 lib/fog/cloudsigma/requests/update_server.rb
fog-1.12.0 lib/fog/cloudsigma/requests/update_server.rb