<commit_before># -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs        #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

require 'rubygems'
require 'erb'
require 'time'
require 'base64'
require 'uuidtools'
require 'AWS'

require 'CloudServer'
require 'ImageEC2'

require 'ebs'
require 'elastic_ip'
require 'instance'
require 'keypair'

################################################################################
#  Extends the OpenNebula::Error class to include an EC2 render of error
#  messages
################################################################################

module OpenNebula
    EC2_ERROR = %q{
        <Response>
            <RequestId/>
            <Errors>
                <Error>
                    <Code><%= (@ec2_code||'UnsupportedOperation') %></Code>
                    <Message><%= @message %></Message>
                </Error>
            </Errors>
        </Response>
    }

    class Error
        attr_accessor :ec2_code

        def to_ec2
            ERB.new(EC2_ERROR).result(binding)
        end
    end
end

###############################################################################
# The EC2Query Server implements a EC2 compatible server based on the
# OpenNebula Engine
###############################################################################
class EC2QueryServer < CloudServer

    include ElasticIP
    include Keypair
    include EBS
    include Instance

    ############################################################################
    #
    #
    ############################################################################
    def initialize(client, oneadmin_client, config, logger)
        super(config, logger)

        @client          = client
        @oneadmin_client = oneadmin_client

        if config[:ssl_server]
            @base_url=config[:ssl_server]
        else
            @base_url="http://#{config[:server]}:#{config[:port]}"
        end

        @request_id = UUIDTools::UUID.random_create.to_s
    end<commit_msg>bug #1816 regionEndpoint with missing hostname in DescribeRegions, contributed by  <NAME><commit_after># -------------------------------------------------------------------------- #
# Copyright 2002-2013, OpenNebula Project (OpenNebula.org), C12G Labs        #
#                                                                            #
# Licensed under the Apache License, Version 2.0 (the "License"); you may    #
# not use this file except in compliance with the License. You may obtain    #
# a copy of the License at                                                   #
#                                                                            #
# http://www.apache.org/licenses/LICENSE-2.0                                 #
#                                                                            #
# Unless required by applicable law or agreed to in writing, software        #
# distributed under the License is distributed on an "AS IS" BASIS,          #
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.   #
# See the License for the specific language governing permissions and        #
# limitations under the License.                                             #
#--------------------------------------------------------------------------- #

require 'rubygems'
require 'erb'
require 'time'
require 'base64'
require 'uuidtools'
require 'AWS'

require 'CloudServer'
require 'ImageEC2'

require 'ebs'
require 'elastic_ip'
require 'instance'
require 'keypair'

################################################################################
#  Extends the OpenNebula::Error class to include an EC2 render of error
#  messages
################################################################################

module OpenNebula
    EC2_ERROR = %q{
        <Response>
            <RequestId/>
            <Errors>
                <Error>
                    <Code><%= (@ec2_code||'UnsupportedOperation') %></Code>
                    <Message><%= @message %></Message>
                </Error>
            </Errors>
        </Response>
    }

    class Error
        attr_accessor :ec2_code

        def to_ec2
            ERB.new(EC2_ERROR).result(binding)
        end
    end
end

###############################################################################
# The EC2Query Server implements a EC2 compatible server based on the
# OpenNebula Engine
###############################################################################
class EC2QueryServer < CloudServer

    include ElasticIP
    include Keypair
    include EBS
    include Instance

    ############################################################################
    #
    #
    ############################################################################
    def initialize(client, oneadmin_client, config, logger)
        super(config, logger)

        @client          = client
        @oneadmin_client = oneadmin_client

        if config[:ssl_server]
            @base_url=config[:ssl_server]
        else
            @base_url="http://#{config[:host]}:#{config[:port]}"
        end

        @request_id = UUIDTools::UUID.random_create.to_s
    end
{'fraction_non_alphanumeric': 0.26248399487836105, 'fraction_numerical': 0.008962868117797696, 'mean_word_length': 1.7650442477876107, 'pattern_counts': {'":': 0, '<': 32, '<?xml version=': 0, '>': 30, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2253064', 'n_tokens_mistral': 1372, 'n_tokens_neox': 1298, 'n_words': 395}