# File lib/fog/profitbricks/requests/compute/create_server.rb, line 135
        def create_server(datacenter_id, properties = {}, entities = {})
          if properties[:cores] == nil
            raise Excon::Error::HTTPStatus, "Attribute 'cores' is required"
          end

          server_id = Fog::UUID.uuid

          volume_id = if entities[:volumes] && entities[:volumes]['items'] && entities[:volumes]['items'][0] && entities[:volumes]['items'][0]['id']
                        entities[:volumes]['items'][0]['id']
                      else
                        Fog::UUID.uuid
                      end

          server = {
            'id'    => server_id,
            'type'  => 'server',
            'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}",
            'datacenter_id' => datacenter_id,
            'metadata' => {
              'createdDate'       => '2014-10-20T21:20:46Z',
              'createdBy'         => 'test@stackpointcloud.com',
              'etag'              => '0018832d7a7ba455db74ac41ae9f11fe',
              'lastModifiedDate'  => '2015-03-18T21:31:10Z',
              'lastModifiedBy'    => 'test@stackpointcloud.com',
              'state'             => 'AVAILABLE'
            },
            'properties' => {
              'name'              => properties[:name],
              'cores'             => properties[:cores],
              'ram'               => properties[:ram],
              'availabilityZone'  => properties[:availabilityZone],
              'vmState'           => 'RUNNING',
              'cpuFamily' => properties[:cpuFamily],
              'bootVolume' => properties[:bootVolume]
            }
          }

          if entities[:volumes]
            server['entities'] = {
              'volumes' => {
                'id'    => "#{server_id}/volumes",
                'type'  => 'collection',
                'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/volumes",
                'items' =>
                [
                  {
                    'id'          => volume_id,
                    'type'        => 'volume',
                    'href'        => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/volumes/#{volume_id}",
                    'metadata'    => {
                      'createdDate'       => '2015-03-18T19=>00=>51Z',
                      'createdBy'         => 'test@stackpointcloud.com',
                      'etag'              => 'c4a2fde6ba91a038ff953b939cc21efe',
                      'lastModifiedDate'  => '2015-03-18T19=>00=>51Z',
                      'lastModifiedBy'    => 'test@stackpointcloud.com',
                      'state'             => 'AVAILABLE'
                    },
                    'properties' => {
                      'name'                => 'FogRestTestVolume',
                      'type'                => 'HDD',
                      'size'                => 5,
                      'image'               => '4f363db0-4955-11e4-b362-52540066fee9',
                      'bus'                 => 'VIRTIO',
                      'licenceType'         => 'OTHER',
                      'cpuHotPlug'          => 'true',
                      'cpuHotUnplug'        => 'false',
                      'ramHotPlug'          => 'false',
                      'ramHotUnplug'        => 'false',
                      'nicHotPlug'          => 'true',
                      'nicHotUnplug'        => 'true',
                      'discVirtioHotPlug'   => 'true',
                      'discVirtioHotUnplug' => 'true',
                      'discScsiHotPlug'     => 'false',
                      'discScsiHotUnplug'   => 'false',
                      'deviceNumber'        => 1
                    }
                  }
                ]
              }
            }
          end

          if entities[:cdroms]
            server['entities']['cdroms'] = {
              'id'    => "#{server_id}/cdroms",
              'type'  => 'collection',
              'href'  => "https=>//api.profitbricks.com/rest/v2/datacenters/#{datacenter_id}/servers/#{server_id}/cdroms",
              'items' =>
              [
                {
                  'id'        => 'dfcb40db-28b5-11e6-9336-52540005ab80',
                  'type'      => 'image',
                  'href'      => 'https=>//api.profitbricks.com/rest/v2/images/dfcb40db-28b5-11e6-9336-52540005ab80',
                  'metadata'  => {
                    'createdDate'       => '2016-06-02T11:33:49Z',
                    'createdBy'         => 'System',
                    'etag'              => '9909709d99655c6f31aca789998d7d89',
                    'lastModifiedDate'  => '2016-06-02T11:33:49Z',
                    'lastModifiedBy'    => 'System',
                    'state'             => 'AVAILABLE'
                  },
                  'properties' => {
                    'name'                => 'CentOS-6.8-x86_64-netinstall.iso',
                    'description'         => '',
                    'location'            => 'us/las',
                    'size'                => 0.23,
                    'cpuHotPlug'          => 'true',
                    'cpuHotUnplug'        => 'false',
                    'ramHotPlug'          => 'true',
                    'ramHotUnplug'        => 'false',
                    'nicHotPlug'          => 'true',
                    'nicHotUnplug'        => 'true',
                    'discVirtioHotPlug'   => 'true',
                    'discVirtioHotUnplug' => 'true',
                    'discScsiHotPlug'     => 'false',
                    'discScsiHotUnplug'   => 'false',
                    'licenceType'         => 'LINUX',
                    'imageType'           => 'CDROM',
                    'public'              => 'true'
                  }
                }
              ]
            }
          end

          data[:servers]['items'] << server

          response = Excon::Response.new
          response.status = 202
          response.body = server

          response
        end