<commit_before>#!/usr/bin/env ruby

# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12G Labs S.L                                           #
#                                                                              #
# 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.                                               #
# ---------------------------------------------------------------------------- #

ONE_LOCATION=ENV["ONE_LOCATION"]

if !ONE_LOCATION
   BIN_LOCATION = "/usr/bin" 
   LIB_LOCATION = "/usr/lib/one"
   ETC_LOCATION = "/etc/one/" 
   VAR_LOCATION = "/var/lib/one"
   RUBY_LIB_LOCATION = "/usr/lib/one/ruby"  
else
   LIB_LOCATION = ONE_LOCATION + "/lib"
   BIN_LOCATION = ONE_LOCATION + "/bin" 
   ETC_LOCATION = ONE_LOCATION  + "/etc/"
   VAR_LOCATION = ONE_LOCATION + "/var/"
   RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby" 
end

$: << RUBY_LIB_LOCATION

CONF_FILE   = ETC_LOCATION + "/vmwarerc"

ENV['LANG'] = 'C'

require "scripts_common"
require 'yaml'
require "CommandManager"
require 'OpenNebula'
include OpenNebula

begin
    client = Client.new()
rescue Exception => e
    puts "Error: #{e}"
    exit(-1)
end

# ######################################################################## #
#                          DRIVER HELPER FUNCTIONS                         #
# ######################################################################## #

#Generates an ESX command using ttyexpect
def esx_cmd(command)
    cmd = "#{BIN_LOCATION}/tty_expect -u #{@user} -p #{@pass} #{command}"
end

#Performs a action usgin libvirt
def do_action(cmd)
    rc = LocalCommand.run(esx_cmd(cmd))

    if rc.code == 0
        return [true, rc.stdout]
    else
        err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}"
        OpenNebula.log_error(err)
        return [false, rc.code]
    end
end

def add_info(name, value)
    value = "0" if value.nil? or value.to_s.empty?
    result_str << "#{name}=#{value} "
end

def print_info
    puts result_str
end

# ######################################################################## #
#                          Main Procedure                                  #
# ######################################################################## #

result_str = ""

host       = ARGV[2]

if !host
    exit -1
end<commit_msg>feature #1020: Bug in result_str in vmware im<commit_after>#!/usr/bin/env ruby

# ---------------------------------------------------------------------------- #
# Copyright 2010-2011, C12<NAME> S.L                                           #
#                                                                              #
# 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.                                               #
# ---------------------------------------------------------------------------- #

ONE_LOCATION=ENV["ONE_LOCATION"]

if !ONE_LOCATION
   BIN_LOCATION = "/usr/bin" 
   LIB_LOCATION = "/usr/lib/one"
   ETC_LOCATION = "/etc/one/" 
   VAR_LOCATION = "/var/lib/one"
   RUBY_LIB_LOCATION = "/usr/lib/one/ruby"  
else
   LIB_LOCATION = ONE_LOCATION + "/lib"
   BIN_LOCATION = ONE_LOCATION + "/bin" 
   ETC_LOCATION = ONE_LOCATION  + "/etc/"
   VAR_LOCATION = ONE_LOCATION + "/var/"
   RUBY_LIB_LOCATION = ONE_LOCATION+"/lib/ruby" 
end

$: << RUBY_LIB_LOCATION

CONF_FILE   = ETC_LOCATION + "/vmwarerc"

ENV['LANG'] = 'C'

require "scripts_common"
require 'yaml'
require "CommandManager"
require 'OpenNebula'
include OpenNebula

begin
    client = Client.new()
rescue Exception => e
    puts "Error: #{e}"
    exit(-1)
end

# ######################################################################## #
#                          DRIVER HELPER FUNCTIONS                         #
# ######################################################################## #

#Generates an ESX command using ttyexpect
def esx_cmd(command)
    cmd = "#{BIN_LOCATION}/tty_expect -u #{@user} -p #{@pass} #{command}"
end

#Performs a action usgin libvirt
def do_action(cmd)
    rc = LocalCommand.run(esx_cmd(cmd))

    if rc.code == 0
        return [true, rc.stdout]
    else
        err = "Error executing: #{cmd} err: #{rc.stderr} out: #{rc.stdout}"
        OpenNebula.log_error(err)
        return [false, rc.code]
    end
end

@result_str = ""

def add_info(name, value)
    value = "0" if value.nil? or value.to_s.empty?
    @result_str << "#{name}=#{value} "
end

def print_info
    puts @result_str
end

# ######################################################################## #
#                          Main Procedure                                  #
# ######################################################################## #

host       = ARGV[2]

if !host
    exit -1
end
{'fraction_non_alphanumeric': 0.22720786427778658, 'fraction_numerical': 0.006659267480577136, 'mean_word_length': 1.6163417669017006, 'pattern_counts': {'":': 0, '<': 12, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 32, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6255270', 'n_tokens_mistral': 1677, 'n_tokens_neox': 1587, 'n_words': 439}