mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-30 22:50:10 +03:00
Merge branch 'master' into feature-200
Conflicts: include/VirtualNetwork.h src/vm/VirtualMachine.cc
This commit is contained in:
commit
2d9d78a03a
@ -616,24 +616,6 @@ public:
|
||||
*/
|
||||
int parse_template_attribute(const string& attribute,
|
||||
string& parsed);
|
||||
|
||||
/**
|
||||
* Parse a string and substitute variables (e.g. $NAME) using the VM
|
||||
* template values (blocking-free version for cross references):
|
||||
* @param vm_id ID of the VM used to substitute the variables
|
||||
* @param attribute, the string to be parsed
|
||||
* @param parsed, the resulting parsed string
|
||||
* @param error_msg, string describing the syntax error
|
||||
* @return 0 on success.
|
||||
*/
|
||||
static int parse_template_attribute(int vm_id,
|
||||
const string& attribute,
|
||||
string& parsed,
|
||||
char ** error_msg)
|
||||
{
|
||||
return parse_attribute(0,vm_id,attribute,parsed,error_msg);
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// States
|
||||
// ------------------------------------------------------------------------
|
||||
@ -980,22 +962,24 @@ private:
|
||||
static pthread_mutex_t lex_mutex;
|
||||
|
||||
/**
|
||||
* Parse a string and substitute variables (e.g. $NAME) using template
|
||||
* values:
|
||||
* @param vm pointer to VirtualMachine if not 0 the template of that VM
|
||||
* will be used.
|
||||
* @param vm_id ID of the VM used to substitute the variables, used if vm
|
||||
* is 0
|
||||
* @param attribute, the string to be parsed
|
||||
* @param parsed, the resulting parsed string
|
||||
* @param error_msg, string describing the syntax error
|
||||
* @return 0 on success.
|
||||
* Parse the "CONTEXT" attribute of the template by substituting
|
||||
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
|
||||
* @return 0 on success
|
||||
*/
|
||||
static int parse_attribute(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
const string& attribute,
|
||||
string& parsed,
|
||||
char ** error_msg);
|
||||
int parse_context();
|
||||
|
||||
/**
|
||||
* Parse the "REQUIREMENTS" attribute of the template by substituting
|
||||
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
|
||||
* @return 0 on success
|
||||
*/
|
||||
int parse_requirements();
|
||||
|
||||
/**
|
||||
* Parse the "GRAPHICS" attribute and generates a default PORT if not
|
||||
* defined
|
||||
*/
|
||||
void parse_graphics();
|
||||
|
||||
protected:
|
||||
|
||||
|
@ -143,20 +143,6 @@ public:
|
||||
int dump(ostringstream& oss, const string& where);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Generate context file to be sourced upon VM booting
|
||||
* @param vm_id, ID of the VM to generate context for
|
||||
* @param attr, the template CONTEXT attribute (the first one)
|
||||
*/
|
||||
void generate_context(int vm_id, Attribute * attr);
|
||||
|
||||
/**
|
||||
* Generate a parsed requirements string
|
||||
* @param vm_id, ID of the VM to generate context for
|
||||
* @param attr, the template REQUIREMENTS attribute (the first one)
|
||||
*/
|
||||
void generate_requirements(int vm_id, Attribute * attr);
|
||||
|
||||
/**
|
||||
* Factory method to produce VM objects
|
||||
* @return a pointer to the new VM
|
||||
|
@ -155,6 +155,63 @@ public:
|
||||
*/
|
||||
int nic_attribute(VectorAttribute * nic, int vid);
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Template
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the values of a template attribute
|
||||
* @param name of the attribute
|
||||
* @param values of the attribute
|
||||
* @return the number of values
|
||||
*/
|
||||
int get_template_attribute(
|
||||
string& name,
|
||||
vector<const Attribute*>& values) const
|
||||
{
|
||||
return vn_template.get(name,values);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the values of a template attribute
|
||||
* @param name of the attribute
|
||||
* @param values of the attribute
|
||||
* @return the number of values
|
||||
*/
|
||||
int get_template_attribute(
|
||||
const char *name,
|
||||
vector<const Attribute*>& values) const
|
||||
{
|
||||
string str=name;
|
||||
return vn_template.get(str,values);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a string based VN attribute
|
||||
* @param name of the attribute
|
||||
* @param value of the attribute (a string), will be "" if not defined
|
||||
*/
|
||||
void get_template_attribute(
|
||||
const char * name,
|
||||
string& value) const
|
||||
{
|
||||
string str=name;
|
||||
vn_template.get(str,value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string based VN attribute
|
||||
* @param name of the attribute
|
||||
* @param value of the attribute (an int), will be 0 if not defined
|
||||
*/
|
||||
void get_template_attribute(
|
||||
const char * name,
|
||||
int& value) const
|
||||
{
|
||||
string str=name;
|
||||
vn_template.get(str,value);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
@ -267,62 +324,7 @@ private:
|
||||
*/
|
||||
int vn_drop(SqlDB * db);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Template
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Gets the values of a template attribute
|
||||
* @param name of the attribute
|
||||
* @param values of the attribute
|
||||
* @return the number of values
|
||||
*/
|
||||
int get_template_attribute(
|
||||
string& name,
|
||||
vector<const Attribute*>& values) const
|
||||
{
|
||||
return vn_template.get(name,values);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets the values of a template attribute
|
||||
* @param name of the attribute
|
||||
* @param values of the attribute
|
||||
* @return the number of values
|
||||
*/
|
||||
int get_template_attribute(
|
||||
const char *name,
|
||||
vector<const Attribute*>& values) const
|
||||
{
|
||||
string str=name;
|
||||
return vn_template.get(str,values);
|
||||
};
|
||||
|
||||
/**
|
||||
* Gets a string based VN attribute
|
||||
* @param name of the attribute
|
||||
* @param value of the attribute (a string), will be "" if not defined
|
||||
*/
|
||||
void get_template_attribute(
|
||||
const char * name,
|
||||
string& value) const
|
||||
{
|
||||
string str=name;
|
||||
vn_template.get(str,value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets a string based VN attribute
|
||||
* @param name of the attribute
|
||||
* @param value of the attribute (an int), will be 0 if not defined
|
||||
*/
|
||||
void get_template_attribute(
|
||||
const char * name,
|
||||
int& value) const
|
||||
{
|
||||
string str=name;
|
||||
vn_template.get(str,value);
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the template of a VNW, adding a new attribute (replacing it if
|
||||
|
@ -22,6 +22,9 @@
|
||||
# passwd : (mysql) the password for user
|
||||
# db_name : (mysql) the database name
|
||||
#
|
||||
# VNC_BASE_PORT: VNC ports for VMs can be automatically set to VNC_BASE_PORT +
|
||||
# VMID
|
||||
#
|
||||
# DEBUG_LEVEL: 0 = ERROR, 1 = WARNING, 2 = INFO, 3 = DEBUG
|
||||
#*******************************************************************************
|
||||
|
||||
@ -42,6 +45,8 @@ DB = [ backend = "sqlite" ]
|
||||
# passwd = "oneadmin",
|
||||
# db_name = "opennebula" ]
|
||||
|
||||
VNC_BASE_PORT = 5000
|
||||
|
||||
DEBUG_LEVEL=3
|
||||
|
||||
#*******************************************************************************
|
||||
|
@ -88,11 +88,11 @@ RAW = [ # Optional, KVM, XEN
|
||||
|
||||
#---------------------------------------
|
||||
# Context for the VM
|
||||
# values can be:
|
||||
# values can use:
|
||||
# $<template_variable>
|
||||
# $<template_variable>[<attribute>]
|
||||
# $<template_variable>[<attribute>, <attribute2>=<value2>]
|
||||
# $<vm_id>.<context_var>
|
||||
# $NETWORK[<vnet_attribute>, NAME=<vnet_name>]
|
||||
#---------------------------------------
|
||||
|
||||
CONTEXT = [ # Optional, KVM, XEN
|
||||
@ -102,7 +102,11 @@ CONTEXT = [ # Optional, KVM, XEN
|
||||
target= "device to attach the context device" ]
|
||||
|
||||
#---------------------------------------
|
||||
# Scheduler
|
||||
# Scheduler
|
||||
# Requirements expressions can use:
|
||||
# $<template_variable>
|
||||
# $<template_variable>[<attribute>]
|
||||
# $<template_variable>[<attribute>, <attribute2>=<value2>]
|
||||
#---------------------------------------
|
||||
|
||||
REQUIREMENTS = "Bool_expression_for_reqs" #Optional
|
||||
|
@ -16,7 +16,7 @@
|
||||
# --access-key <id>, -K <id>:
|
||||
# The username of the user
|
||||
#
|
||||
# --secret-key <key>, -K <key>:
|
||||
# --secret-key <key>, -S <key>:
|
||||
# The password of the user
|
||||
#
|
||||
# --url <url>, -U <url>:
|
||||
|
@ -68,6 +68,7 @@ opts = GetoptLong.new(
|
||||
['--secret-key', '-S',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--url', '-U',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--type', '-t',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--user-data', '-d',GetoptLong::REQUIRED_ARGUMENT],
|
||||
['--headers', '-H',GetoptLong::NO_ARGUMENT]
|
||||
)
|
||||
|
||||
@ -77,6 +78,7 @@ access = nil
|
||||
secret = nil
|
||||
auth = nil
|
||||
type = nil
|
||||
user_data = nil
|
||||
|
||||
begin
|
||||
opts.each do |opt, arg|
|
||||
@ -93,6 +95,8 @@ begin
|
||||
type = arg
|
||||
when '--headers'
|
||||
headers = true
|
||||
when '--user-data'
|
||||
user_data = arg
|
||||
end
|
||||
end
|
||||
rescue Exception => e
|
||||
@ -119,7 +123,7 @@ rescue Exception => e
|
||||
exit -1
|
||||
end
|
||||
|
||||
rc = ec2_client.run_instances(image_id,type)
|
||||
rc = ec2_client.run_instances(image_id,type, user_data)
|
||||
|
||||
if CloudClient::is_error?(rc)
|
||||
puts "#{cmd_name}: #{rc.message}"
|
||||
|
@ -15,7 +15,7 @@
|
||||
# --access-key <id>, -K <id>:
|
||||
# The username of the user
|
||||
#
|
||||
# --secret-key <key>, -K <key>:
|
||||
# --secret-key <key>, -S <key>:
|
||||
# The password of the user
|
||||
#
|
||||
# --url <url>, -U <url>:
|
||||
|
@ -16,7 +16,7 @@
|
||||
# --access-key <id>, -K <id>:
|
||||
# The username of the user
|
||||
#
|
||||
# --secret-key <key>, -K <key>:
|
||||
# --secret-key <key>, -S <key>:
|
||||
# The password of the user
|
||||
#
|
||||
# --url <url>, -U <url>:
|
||||
|
@ -1,23 +1,29 @@
|
||||
|
||||
NAME = eco-vm
|
||||
|
||||
#Adjust Capacity for this instance type
|
||||
CPU = 0.2
|
||||
MEMORY = 256
|
||||
|
||||
OS = [ kernel = /vmlinuz,
|
||||
initrd = /initrd.img,
|
||||
root = sda1,
|
||||
kernel_cmd = "ro xencons=tty console=tty1"]
|
||||
#Put here specific OS configurations for the cloud hypervisors
|
||||
#OS = [ kernel = /vmlinuz,
|
||||
# initrd = /initrd.img,
|
||||
# root = sda1,
|
||||
# kernel_cmd = "ro xencons=tty console=tty1"]
|
||||
|
||||
DISK = [ source = <%= erb_vm_info[:img_path] %>,
|
||||
clone = no,
|
||||
target = sda1,
|
||||
readonly = no]
|
||||
|
||||
|
||||
NIC=[NETWORK="Public EC2"]
|
||||
|
||||
|
||||
IMAGE_ID = <%= erb_vm_info[:img_id] %>
|
||||
INSTANCE_TYPE = <%= erb_vm_info[:instance_type ]%>
|
||||
|
||||
|
||||
<% if erb_vm_info[:user_data] %>
|
||||
CONTEXT = [
|
||||
EC2_USER_DATA="<%= erb_vm_info[:user_data] %>",
|
||||
TARGET="hdc"
|
||||
]
|
||||
<% end %>
|
||||
|
@ -97,13 +97,15 @@ module EC2QueryClient
|
||||
# :image_id
|
||||
# :instance_type
|
||||
######################################################################
|
||||
def run_instances(ami_id, type)
|
||||
def run_instances(ami_id, type, user_data=nil)
|
||||
begin
|
||||
response = @ec2_connection.run_instances(
|
||||
:image_id => ami_id,
|
||||
:min_count => 1,
|
||||
:max_count => 1,
|
||||
:instance_type => type
|
||||
:image_id => ami_id,
|
||||
:min_count => 1,
|
||||
:max_count => 1,
|
||||
:instance_type => type,
|
||||
:user_data => user_data,
|
||||
:base64_encoded => true
|
||||
)
|
||||
rescue Exception => e
|
||||
error = CloudClient::Error.new(e.message)
|
||||
|
@ -20,6 +20,8 @@ require 'erb'
|
||||
require 'time'
|
||||
require 'AWS'
|
||||
require 'CloudServer'
|
||||
require 'base64'
|
||||
|
||||
###############################################################################
|
||||
# The EC2Query Server implements a EC2 compatible server based on the
|
||||
# OpenNebula Engine
|
||||
@ -69,6 +71,8 @@ class EC2QueryServer < CloudServer
|
||||
@server_host=@config[:server]
|
||||
end
|
||||
|
||||
@server_port=@config[:port]
|
||||
|
||||
print_configuration
|
||||
end
|
||||
|
||||
@ -79,19 +83,65 @@ class EC2QueryServer < CloudServer
|
||||
# EC2 protocol authentication function
|
||||
# params:: of the request
|
||||
# [return] true if authenticated
|
||||
def authenticate?(params)
|
||||
def authenticate?(params,env)
|
||||
user = get_user(params['AWSAccessKeyId'])
|
||||
return false if !user
|
||||
|
||||
|
||||
signature = case params['SignatureVersion']
|
||||
when "1" then signature_version_1(params.clone, user[:password])
|
||||
when "2" then signature_version_2(params,
|
||||
user[:password],
|
||||
env,
|
||||
false)
|
||||
end
|
||||
|
||||
return params['Signature']==signature
|
||||
end
|
||||
|
||||
# Calculates signature version 1
|
||||
def signature_version_1(params, secret_key, digest='sha1')
|
||||
params.delete('Signature')
|
||||
req_desc = params.sort {|x,y| x[0].downcase <=> y[0].downcase}.to_s
|
||||
|
||||
digest_generator = OpenSSL::Digest::Digest.new(digest)
|
||||
digest = OpenSSL::HMAC.digest(digest_generator,
|
||||
secret_key,
|
||||
req_desc)
|
||||
b64sig = Base64.b64encode(digest)
|
||||
return b64sig.strip
|
||||
end
|
||||
|
||||
# Calculates signature version 2
|
||||
def signature_version_2(params, secret_key, env, urlencode=true)
|
||||
signature_params = params.reject { |key,value|
|
||||
key=='Signature' or key=='file' }
|
||||
|
||||
signature = AWS.encode(
|
||||
user[:password],
|
||||
AWS.canonical_string(signature_params, @server_host),
|
||||
false)
|
||||
|
||||
return params['Signature']==signature
|
||||
|
||||
server_str = @server_host
|
||||
server_str = server_str + ":" + @server_port unless %w{2008-12-01 2009-11-30}.include? params["Version"]
|
||||
|
||||
canonical_str = AWS.canonical_string(signature_params,
|
||||
server_str,
|
||||
env['REQUEST_METHOD'])
|
||||
|
||||
|
||||
# Use the correct signature strength
|
||||
sha_strength = case params['SignatureMethod']
|
||||
when "HmacSHA1" then 'sha1'
|
||||
when "HmacSHA256" then 'sha256'
|
||||
else 'sha1'
|
||||
end
|
||||
|
||||
digest = OpenSSL::Digest::Digest.new(sha_strength)
|
||||
b64hmac =
|
||||
Base64.encode64(
|
||||
OpenSSL::HMAC.digest(digest, secret_key, canonical_str)).gsub("\n","")
|
||||
|
||||
if urlencode
|
||||
return CGI::escape(b64hmac)
|
||||
else
|
||||
return b64hmac
|
||||
end
|
||||
end
|
||||
|
||||
###########################################################################
|
||||
@ -103,6 +153,7 @@ class EC2QueryServer < CloudServer
|
||||
|
||||
image = add_image(user[:id],params["file"][:tempfile])
|
||||
erb_img_id = image.id
|
||||
erb_version = params['Version']
|
||||
|
||||
response = ERB.new(File.read(@config[:views]+"/register_image.erb"))
|
||||
return response.result(binding), 200
|
||||
@ -113,22 +164,25 @@ class EC2QueryServer < CloudServer
|
||||
image = get_image(params['ImageLocation'])
|
||||
|
||||
if !image
|
||||
return OpenNebula::Error.new('Image not found'), 404
|
||||
return OpenNebula::Error.new('InvalidAMIID.NotFound'), 400
|
||||
elsif user[:id] != image[:owner]
|
||||
return OpenNebula::Error.new('Not permited to use image'), 401
|
||||
return OpenNebula::Error.new('AuthFailure'), 400
|
||||
end
|
||||
|
||||
erb_img_id=image.id
|
||||
erb_version = params['Version']
|
||||
|
||||
response = ERB.new(File.read(@config[:views]+"/register_image.erb"))
|
||||
return response.result(binding), 200
|
||||
end
|
||||
|
||||
def describe_images(params)
|
||||
erb_user = get_user(params['AWSAccessKeyId'])
|
||||
erb_images = Image.filter(:owner => erb_user[:id])
|
||||
erb_user = get_user(params['AWSAccessKeyId'])
|
||||
erb_images = Image.filter(:owner => erb_user[:id])
|
||||
erb_version = params['Version']
|
||||
|
||||
response = ERB.new(File.read(@config[:views]+"/describe_images.erb"))
|
||||
|
||||
return response.result(binding), 200
|
||||
end
|
||||
|
||||
@ -141,12 +195,13 @@ class EC2QueryServer < CloudServer
|
||||
instance_type_name = params['InstanceType']
|
||||
instance_type = @instance_types[instance_type_name]
|
||||
|
||||
return OpenNebula::Error.new('Bad instance type'),400 if !instance_type
|
||||
return OpenNebula::Error.new('Unsupported'),400 if !instance_type
|
||||
|
||||
# Get the image
|
||||
image = get_image(params['ImageId'])
|
||||
tmp, img=params['ImageId'].split('-')
|
||||
image = get_image(img.to_i)
|
||||
|
||||
return OpenNebula::Error.new('Bad image id'),400 if !image
|
||||
return OpenNebula::Error.new('InvalidAMIID.NotFound'),400 if !image
|
||||
|
||||
# Get the user
|
||||
user = get_user(params['AWSAccessKeyId'])
|
||||
@ -156,24 +211,30 @@ class EC2QueryServer < CloudServer
|
||||
# Build the VM
|
||||
erb_vm_info=Hash.new
|
||||
|
||||
|
||||
erb_vm_info[:img_path] = image.path
|
||||
erb_vm_info[:img_id] = params['ImageId']
|
||||
erb_vm_info[:instance_type] = instance_type_name
|
||||
erb_vm_info[:template] = @config[:template_location] +
|
||||
"/#{instance_type['TEMPLATE']}"
|
||||
erb_vm_info[:user_data] = params['UserData']
|
||||
|
||||
template = ERB.new(File.read(erb_vm_info[:template]))
|
||||
template_text = template.result(binding)
|
||||
|
||||
#Start the VM.
|
||||
vm = VirtualMachine.new(VirtualMachine.build_xml, one_client)
|
||||
|
||||
rc = vm.allocate(template_text)
|
||||
|
||||
return rc, 401 if OpenNebula::is_error?(rc)
|
||||
return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc)
|
||||
|
||||
vm.info
|
||||
|
||||
erb_vm_info[:vm_id]=vm.id
|
||||
erb_vm_info[:vm]=vm
|
||||
|
||||
erb_version = params['Version']
|
||||
|
||||
response = ERB.new(File.read(@config[:views]+"/run_instances.erb"))
|
||||
return response.result(binding), 200
|
||||
@ -195,8 +256,11 @@ class EC2QueryServer < CloudServer
|
||||
|
||||
erb_vmpool = VirtualMachinePool.new(one_client, user_flag)
|
||||
erb_vmpool.info
|
||||
|
||||
erb_version = params['Version']
|
||||
|
||||
response = ERB.new(File.read(@config[:views]+"/describe_instances.erb"))
|
||||
|
||||
return response.result(binding), 200
|
||||
end
|
||||
|
||||
@ -204,13 +268,16 @@ class EC2QueryServer < CloudServer
|
||||
# Get the user
|
||||
user = get_user(params['AWSAccessKeyId'])
|
||||
one_client = one_client_user(user)
|
||||
|
||||
|
||||
vmid=params['InstanceId.1']
|
||||
vmid=params['InstanceId.01'] if !vmid
|
||||
|
||||
tmp, vmid=vmid.split('-') if vmid[0]==?i
|
||||
|
||||
erb_vm = VirtualMachine.new(VirtualMachine.build_xml(vmid),one_client)
|
||||
rc = erb_vm.info
|
||||
|
||||
return rc, 401 if OpenNebula::is_error?(rc)
|
||||
return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc)
|
||||
|
||||
if erb_vm.status == 'runn'
|
||||
rc = erb_vm.shutdown
|
||||
@ -218,7 +285,9 @@ class EC2QueryServer < CloudServer
|
||||
rc = erb_vm.finalize
|
||||
end
|
||||
|
||||
return rc, 401 if OpenNebula::is_error?(rc)
|
||||
return OpenNebula::Error.new('Unsupported'),400 if OpenNebula::is_error?(rc)
|
||||
|
||||
erb_version = params['Version']
|
||||
|
||||
response =ERB.new(File.read(@config[:views]+"/terminate_instances.erb"))
|
||||
return response.result(binding), 200
|
||||
|
@ -59,12 +59,47 @@ set :port, $econe_server.config[:port]
|
||||
##############################################################################
|
||||
|
||||
before do
|
||||
if !$econe_server.authenticate?(params)
|
||||
halt 401, 'Invalid credentials'
|
||||
if !$econe_server.authenticate?(params,env)
|
||||
error 400, error_xml("AuthFailure", 0)
|
||||
end
|
||||
end
|
||||
|
||||
helpers do
|
||||
def error_xml(code,id)
|
||||
message = ''
|
||||
|
||||
case code
|
||||
when 'AuthFailure'
|
||||
message = 'User not authorized'
|
||||
when 'InvalidAMIID.NotFound'
|
||||
message = 'Specified AMI ID does not exist'
|
||||
when 'Unsupported'
|
||||
message = 'The instance type or feature is not supported in your requested Availability Zone.'
|
||||
else
|
||||
message = code
|
||||
end
|
||||
|
||||
xml = "<Response><Errors><Error><Code>"+
|
||||
code +
|
||||
"</Code><Message>" +
|
||||
message +
|
||||
"</Message></Error></Errors><RequestID>" +
|
||||
id.to_s +
|
||||
"</RequestID></Response>"
|
||||
|
||||
return xml
|
||||
end
|
||||
end
|
||||
|
||||
post '/' do
|
||||
do_http_request(params)
|
||||
end
|
||||
|
||||
get '/' do
|
||||
do_http_request(params)
|
||||
end
|
||||
|
||||
def do_http_request(params)
|
||||
case params['Action']
|
||||
when 'UploadImage'
|
||||
result,rc = $econe_server.upload_image(params)
|
||||
@ -79,10 +114,12 @@ post '/' do
|
||||
when 'TerminateInstances'
|
||||
result,rc = $econe_server.terminate_instances(params)
|
||||
end
|
||||
|
||||
|
||||
if OpenNebula::is_error?(result)
|
||||
halt rc, result.message
|
||||
error rc, error_xml(result.message, 0)
|
||||
end
|
||||
|
||||
result
|
||||
headers['Content-Type'] = 'application/xml'
|
||||
|
||||
result
|
||||
end
|
||||
|
@ -1,9 +1,10 @@
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
|
||||
<?xml version="1.0"?>
|
||||
<DescribeImagesResponse xmlns="http://ec2.amazonaws.com/doc/<%= erb_version %>/">
|
||||
<imagesSet>
|
||||
<% for image in erb_images %>
|
||||
<item>
|
||||
<imageId><%= image.id %></imageId>
|
||||
<imageLocation><%= image.path %></imageLocation>
|
||||
<imageId>ami-<%= sprintf('%08i', image.id) %></imageId>
|
||||
<imageLocation><%= image.path.gsub(/^\//,'') %></imageLocation>
|
||||
<imageState>available</imageState>
|
||||
<imageOwnerId><%= erb_user[:name] %></imageOwnerId>
|
||||
<isPublic>false</isPublic>
|
||||
|
@ -1,4 +1,6 @@
|
||||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
|
||||
<?xml version="1.0"?>
|
||||
<DescribeInstancesResponse xmlns="http://ec2.amazonaws.com/doc/<%= erb_version %>/">
|
||||
<requestId>4ac62eaf-e266-4058-a970-2c01568cd417</requestId>
|
||||
<reservationSet>
|
||||
<item>
|
||||
<reservationId>default</reservationId>
|
||||
@ -12,7 +14,7 @@
|
||||
<% erb_vmpool.each do |vm| %>
|
||||
<% vm.info %>
|
||||
<item>
|
||||
<instanceId><%= vm.id %></instanceId>
|
||||
<instanceId>i-<%= vm.id %></instanceId>
|
||||
<imageId><%= vm['TEMPLATE/IMAGE_ID'] %></imageId>
|
||||
<instanceState>
|
||||
<%= render_state(vm) %>
|
||||
@ -21,11 +23,19 @@
|
||||
<dnsName><%= vm["TEMPLATE/NIC/IP"] %></dnsName>
|
||||
<keyName>default</keyName>
|
||||
<amiLaunchIndex>0</amiLaunchIndex>
|
||||
<productCodes/>
|
||||
<instanceType><%= vm['TEMPLATE/INSTANCE_TYPE'] %></instanceType>
|
||||
<%= render_launch_time(vm) %>
|
||||
<placement>
|
||||
<availabilityZone>default</availabilityZone>
|
||||
</placement>
|
||||
|
||||
<kernelId>eki-EA801065</kernelId>
|
||||
<ramdiskId>eri-1FEE1144</ramdiskId>
|
||||
<monitoring>
|
||||
<state>false</state>
|
||||
</monitoring>
|
||||
|
||||
</item>
|
||||
<% end %>
|
||||
</instancesSet>
|
||||
|
@ -1,3 +1,3 @@
|
||||
<RegisterImageResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
|
||||
<RegisterImageResponse xmlns="http://ec2.amazonaws.com/doc/<%= erb_version %>/">
|
||||
<imageId><%= erb_img_id %></imageId>
|
||||
</RegisterImageResponse>
|
||||
|
@ -1,4 +1,4 @@
|
||||
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
|
||||
<RunInstancesResponse xmlns="http://ec2.amazonaws.com/doc/<%= erb_version %>/">
|
||||
<reservationId>r-47a5402e</reservationId>
|
||||
<ownerId><%= erb_user_name %></ownerId>
|
||||
<groupSet>
|
||||
@ -8,7 +8,7 @@
|
||||
</groupSet>
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId><%= erb_vm_info[:vm_id] %></instanceId>
|
||||
<instanceId>i-<%= erb_vm_info[:vm_id] %></instanceId>
|
||||
<imageId><%= erb_vm_info[:img_id] %></imageId>
|
||||
<instanceState>
|
||||
<code>0</code>
|
||||
|
@ -1,7 +1,7 @@
|
||||
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/2009-04-04/">
|
||||
<TerminateInstancesResponse xmlns="http://ec2.amazonaws.com/doc/<%= erb_version %>/">
|
||||
<instancesSet>
|
||||
<item>
|
||||
<instanceId><%= erb_vm.id %></instanceId>
|
||||
<instanceId>i-<%= erb_vm.id %></instanceId>
|
||||
<shutdownState>
|
||||
<code>32</code>
|
||||
<name>shutting-down</name>
|
||||
|
@ -235,6 +235,11 @@ class OCCIServer < CloudServer
|
||||
network_info['NETWORK'],
|
||||
@config[:bridge])
|
||||
rc = network.allocate(vntemplate)
|
||||
|
||||
if OpenNebula::is_error?(rc)
|
||||
return rc, 404
|
||||
end
|
||||
|
||||
network.info
|
||||
network_xml = network.to_occi
|
||||
return network_xml, 201
|
||||
|
@ -20,24 +20,6 @@ Import('env')
|
||||
|
||||
lib_name='nebula_host'
|
||||
|
||||
if env['parsers']=='yes':
|
||||
# LEX
|
||||
parser=env.Lex(
|
||||
source='host_parser.l'
|
||||
)
|
||||
env.NoClean(parser)
|
||||
|
||||
# BISON
|
||||
parser=env.Bison(
|
||||
source='host_requirements.y'
|
||||
)
|
||||
env.NoClean(parser)
|
||||
|
||||
parser=env.Bison(
|
||||
source='host_rank.y'
|
||||
)
|
||||
env.NoClean(parser)
|
||||
|
||||
# Sources to generate the library
|
||||
source_files=[
|
||||
'Host.cc',
|
||||
|
@ -74,6 +74,12 @@ NebulaTemplate::NebulaTemplate(string& etc_location, string& var_location)
|
||||
|
||||
attribute = new SingleAttribute("NETWORK_SIZE",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//NETWORK_SIZE
|
||||
value = "5900";
|
||||
|
||||
attribute = new SingleAttribute("VNC_BASE_PORT",value);
|
||||
conf_default.insert(make_pair(attribute->name(),attribute));
|
||||
|
||||
//DEBUG_LEVEL
|
||||
value = Log::WARNING;
|
||||
|
@ -16,6 +16,7 @@
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
||||
#include <getopt.h>
|
||||
|
||||
#include <TestFixture.h>
|
||||
#include <TestAssert.h>
|
||||
@ -35,6 +36,7 @@ using namespace std;
|
||||
|
||||
/* ************************************************************************* */
|
||||
/* ************************************************************************* */
|
||||
bool mysql;
|
||||
|
||||
class PoolTest : public CppUnit::TestFixture
|
||||
{
|
||||
@ -65,7 +67,7 @@ public:
|
||||
{
|
||||
string db_name = "testdb";
|
||||
|
||||
if (true)
|
||||
if (mysql)
|
||||
{
|
||||
db = new MySqlDB("localhost","oneadmin","oneadmin",NULL);
|
||||
|
||||
@ -236,10 +238,59 @@ public:
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
CppUnit::TextUi::TestRunner runner;
|
||||
// Option flags
|
||||
bool sqlite_flag = true;
|
||||
bool log_flag = false;
|
||||
|
||||
// Long options
|
||||
const struct option long_opt[] =
|
||||
{
|
||||
{ "sqlite", 0, NULL, 's'},
|
||||
{ "mysql", 0, NULL, 'm'},
|
||||
{ "log", 0, NULL, 'l'},
|
||||
{ "help", 0, NULL, 'h'}
|
||||
};
|
||||
|
||||
int c;
|
||||
while ((c = getopt_long (argc, argv, "smlh", long_opt, NULL)) != -1)
|
||||
switch (c)
|
||||
{
|
||||
case 'm':
|
||||
sqlite_flag = false;
|
||||
break;
|
||||
case 'l':
|
||||
log_flag = true;
|
||||
break;
|
||||
case 'h':
|
||||
cout << "Options:\n";
|
||||
cout << " -h --help Show this help\n"
|
||||
" -s --sqlite Run Sqlite tests (default)\n"
|
||||
" -m --mysql Run MySQL tests\n"
|
||||
" -l --log Keep the log file, test.log\n";
|
||||
return 0;
|
||||
}
|
||||
|
||||
NebulaLog::init_log_system(NebulaLog::FILE, Log::ERROR, "test.log");
|
||||
|
||||
if (sqlite_flag)
|
||||
{
|
||||
mysql = false;
|
||||
NebulaLog::log("Test", Log::INFO, "Running Sqlite tests...");
|
||||
cout << "\nRunning Sqlite tests...\n";
|
||||
}
|
||||
else
|
||||
{
|
||||
mysql = true;
|
||||
NebulaLog::log("Test", Log::INFO, "Running MySQL tests...");
|
||||
cout << "\nRunning MySQL tests...\n";
|
||||
}
|
||||
|
||||
runner.addTest( PoolTest::suite() );
|
||||
runner.run();
|
||||
|
||||
if (!log_flag)
|
||||
remove("test.log");
|
||||
|
||||
NebulaLog::finalize_log_system();
|
||||
|
||||
return 0;
|
||||
|
@ -254,6 +254,7 @@ public:
|
||||
vector<float> priorities;
|
||||
int hid;
|
||||
int rc;
|
||||
map<int, int> host_vms;
|
||||
|
||||
CPPUNIT_ASSERT( vmp != 0 );
|
||||
|
||||
@ -267,7 +268,7 @@ public:
|
||||
vm = vmp->get(0);
|
||||
CPPUNIT_ASSERT( vm != 0 );
|
||||
|
||||
rc = vm->get_host(hid, hpool);
|
||||
rc = vm->get_host(hid, hpool,host_vms,1);
|
||||
CPPUNIT_ASSERT( rc == -1 );
|
||||
|
||||
// get_host will iterate in reverse order the available hosts, and
|
||||
@ -278,7 +279,7 @@ public:
|
||||
vm->add_host( 2 );
|
||||
vm->add_host( 1 );
|
||||
|
||||
rc = vm->get_host(hid, hpool);
|
||||
rc = vm->get_host(hid, hpool,host_vms,1);
|
||||
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
CPPUNIT_ASSERT( hid == 4 );
|
||||
@ -293,7 +294,7 @@ public:
|
||||
|
||||
vm->set_priorities(priorities);
|
||||
|
||||
rc = vm->get_host(hid, hpool);
|
||||
rc = vm->get_host(hid, hpool,host_vms,1);
|
||||
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
CPPUNIT_ASSERT( hid == 5 );
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton implementation for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +45,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "2.4.1"
|
||||
#define YYBISON_VERSION "2.4.2"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -109,7 +108,7 @@ static string& unescape (string &str);
|
||||
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
#line 113 "template_syntax.cc"
|
||||
#line 112 "template_syntax.cc"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@ -161,7 +160,7 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 165 "template_syntax.cc"
|
||||
#line 164 "template_syntax.cc"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@ -186,7 +185,7 @@ typedef struct YYLTYPE
|
||||
|
||||
|
||||
/* Line 264 of yacc.c */
|
||||
#line 190 "template_syntax.cc"
|
||||
#line 189 "template_syntax.cc"
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -236,7 +235,7 @@ typedef short int yytype_int16;
|
||||
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
||||
|
||||
#ifndef YY_
|
||||
# if YYENABLE_NLS
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
||||
@ -576,9 +575,18 @@ static const yytype_uint8 yystos[] =
|
||||
|
||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||
to ease the transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
Once GCC version 2 has supplanted version 1, this can go. However,
|
||||
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
|
||||
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||
discussed. */
|
||||
|
||||
#define YYFAIL goto yyerrlab
|
||||
#if defined YYFAIL
|
||||
/* This is here to suppress warnings from the GCC cpp's
|
||||
-Wunused-macros. Normally we don't worry about that warning, but
|
||||
some users do, and we want to make it easy for users to remove
|
||||
YYFAIL uses, which will produce warnings from Bison 2.5. */
|
||||
#endif
|
||||
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
|
||||
@ -635,7 +643,7 @@ while (YYID (0))
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if YYLTYPE_IS_TRIVIAL
|
||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
fprintf (File, "%d.%d-%d.%d", \
|
||||
(Loc).first_line, (Loc).first_column, \
|
||||
@ -1231,7 +1239,7 @@ YYLTYPE yylloc;
|
||||
yyvsp = yyvs;
|
||||
yylsp = yyls;
|
||||
|
||||
#if YYLTYPE_IS_TRIVIAL
|
||||
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
/* Initialize the default location before parsing starts. */
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = 1;
|
||||
@ -1421,7 +1429,7 @@ yyreduce:
|
||||
{
|
||||
case 4:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 76 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1439,7 +1447,7 @@ yyreduce:
|
||||
|
||||
case 5:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 89 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1458,7 +1466,7 @@ yyreduce:
|
||||
|
||||
case 6:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 103 "template_syntax.y"
|
||||
{
|
||||
Attribute * pattr;
|
||||
@ -1475,7 +1483,7 @@ yyreduce:
|
||||
|
||||
case 7:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 117 "template_syntax.y"
|
||||
{
|
||||
map<string,string>* vattr;
|
||||
@ -1496,7 +1504,7 @@ yyreduce:
|
||||
|
||||
case 8:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 133 "template_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(3) - (5)].val_str));
|
||||
@ -1517,8 +1525,8 @@ yyreduce:
|
||||
|
||||
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 1522 "template_syntax.cc"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 1530 "template_syntax.cc"
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
@ -1736,7 +1744,7 @@ yyreturn:
|
||||
|
||||
|
||||
|
||||
/* Line 1675 of yacc.c */
|
||||
/* Line 1684 of yacc.c */
|
||||
#line 149 "template_syntax.y"
|
||||
|
||||
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -55,7 +54,7 @@
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 51 "template_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
@ -63,8 +62,8 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 68 "template_syntax.hh"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 67 "template_syntax.hh"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
@ -314,6 +314,26 @@ int VirtualMachine::insert(SqlDB * db)
|
||||
goto error_images;
|
||||
}
|
||||
|
||||
// -------------------------------------------------------------------------
|
||||
// Parse the context & requirements
|
||||
// -------------------------------------------------------------------------
|
||||
|
||||
rc = parse_context();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_context;
|
||||
}
|
||||
|
||||
rc = parse_requirements();
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
goto error_requirements;
|
||||
}
|
||||
|
||||
parse_graphics();
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Insert the template first, so we get a valid template ID. Then the VM
|
||||
// ------------------------------------------------------------------------
|
||||
@ -353,6 +373,173 @@ error_images:
|
||||
NebulaLog::log("ONE",Log::ERROR, "Could not get disk image for VM");
|
||||
release_disk_images();
|
||||
return -1;
|
||||
|
||||
error_context:
|
||||
NebulaLog::log("ONE",Log::ERROR, "Could not parse CONTEXT for VM");
|
||||
release_network_leases();
|
||||
return -1;
|
||||
|
||||
error_requirements:
|
||||
NebulaLog::log("ONE",Log::ERROR, "Could not parse REQUIREMENTS for VM");
|
||||
release_network_leases();
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_context()
|
||||
{
|
||||
int rc, num;
|
||||
|
||||
vector<Attribute *> array_context;
|
||||
VectorAttribute * context;
|
||||
|
||||
string * str;
|
||||
string parsed;
|
||||
|
||||
num = vm_template.remove("CONTEXT", array_context);
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
context = dynamic_cast<VectorAttribute *>(array_context[0]);
|
||||
|
||||
if ( context == 0 )
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR, "Wrong format for CONTEXT attribute");
|
||||
return -1;
|
||||
}
|
||||
|
||||
str = context->marshall(" @^_^@ ");
|
||||
|
||||
if (str == 0)
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR, "Can not marshall CONTEXT");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = parse_template_attribute(*str,parsed);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
VectorAttribute * context_parsed;
|
||||
|
||||
context_parsed = new VectorAttribute("CONTEXT");
|
||||
context_parsed->unmarshall(parsed," @^_^@ ");
|
||||
|
||||
vm_template.set(context_parsed);
|
||||
}
|
||||
|
||||
/* --- Delete old context attributes --- */
|
||||
|
||||
for (int i = 0; i < num ; i++)
|
||||
{
|
||||
if (array_context[i] != 0)
|
||||
{
|
||||
delete array_context[i];
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachine::parse_graphics()
|
||||
{
|
||||
int num;
|
||||
|
||||
vector<Attribute *> array_graphics;
|
||||
VectorAttribute * graphics;
|
||||
|
||||
num = vm_template.get("GRAPHICS", array_graphics);
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
graphics = dynamic_cast<VectorAttribute * >(array_graphics[0]);
|
||||
|
||||
if ( graphics == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
string port = graphics->vector_value("PORT");
|
||||
|
||||
if ( port.empty() )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
ostringstream oss;
|
||||
istringstream iss;
|
||||
|
||||
int base_port;
|
||||
string base_port_s;
|
||||
|
||||
nd.get_configuration_attribute("VNC_BASE_PORT",base_port_s);
|
||||
iss.str(base_port_s);
|
||||
iss >> base_port;
|
||||
|
||||
oss << ( base_port + oid );
|
||||
graphics->replace("PORT", oss.str());
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_requirements()
|
||||
{
|
||||
int rc, num;
|
||||
|
||||
vector<Attribute *> array_reqs;
|
||||
SingleAttribute * reqs;
|
||||
|
||||
string parsed;
|
||||
|
||||
num = vm_template.remove("REQUIREMENTS", array_reqs);
|
||||
|
||||
if ( num == 0 )
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
reqs = dynamic_cast<SingleAttribute *>(array_reqs[0]);
|
||||
|
||||
if ( reqs == 0 )
|
||||
{
|
||||
NebulaLog::log("ONE",Log::ERROR,"Wrong format for REQUIREMENTS");
|
||||
return -1;
|
||||
}
|
||||
|
||||
rc = parse_template_attribute(reqs->value(),parsed);
|
||||
|
||||
if ( rc == 0 )
|
||||
{
|
||||
SingleAttribute * reqs_parsed;
|
||||
|
||||
reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed);
|
||||
vm_template.set(reqs_parsed);
|
||||
}
|
||||
|
||||
/* --- Delete old requirements attributes --- */
|
||||
|
||||
for (int i = 0; i < num ; i++)
|
||||
{
|
||||
if (array_reqs[i] != 0)
|
||||
{
|
||||
delete array_reqs[i];
|
||||
}
|
||||
}
|
||||
|
||||
return rc;
|
||||
>>>>>>> master
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------------------ */
|
||||
@ -834,28 +1021,6 @@ int VirtualMachine::generate_context(string &files)
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_template_attribute(const string& attribute,
|
||||
string& parsed)
|
||||
{
|
||||
int rc;
|
||||
char * err = 0;
|
||||
|
||||
rc = parse_attribute(this,-1,attribute,parsed,&err);
|
||||
|
||||
if ( rc != 0 && err != 0 )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Error parsing: " << attribute << ". " << err;
|
||||
log("VM",Log::ERROR,oss);
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
pthread_mutex_t VirtualMachine::lex_mutex = PTHREAD_MUTEX_INITIALIZER;
|
||||
|
||||
extern "C"
|
||||
@ -863,7 +1028,6 @@ extern "C"
|
||||
typedef struct yy_buffer_state * YY_BUFFER_STATE;
|
||||
|
||||
int vm_var_parse (VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream * parsed,
|
||||
char ** errmsg);
|
||||
|
||||
@ -876,18 +1040,14 @@ extern "C"
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachine::parse_attribute(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
const string& attribute,
|
||||
string& parsed,
|
||||
char ** error_msg)
|
||||
int VirtualMachine::parse_template_attribute(const string& attribute,
|
||||
string& parsed)
|
||||
{
|
||||
YY_BUFFER_STATE str_buffer = 0;
|
||||
const char * str;
|
||||
int rc;
|
||||
ostringstream oss_parsed;
|
||||
|
||||
*error_msg = 0;
|
||||
char * error_msg = 0;
|
||||
|
||||
pthread_mutex_lock(&lex_mutex);
|
||||
|
||||
@ -899,7 +1059,7 @@ int VirtualMachine::parse_attribute(VirtualMachine * vm,
|
||||
goto error_yy;
|
||||
}
|
||||
|
||||
rc = vm_var_parse(vm,vm_id,&oss_parsed,error_msg);
|
||||
rc = vm_var_parse(this,&oss_parsed,&error_msg);
|
||||
|
||||
vm_var__delete_buffer(str_buffer);
|
||||
|
||||
@ -907,12 +1067,22 @@ int VirtualMachine::parse_attribute(VirtualMachine * vm,
|
||||
|
||||
pthread_mutex_unlock(&lex_mutex);
|
||||
|
||||
if ( rc != 0 && error_msg != 0 )
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << "Error parsing: " << attribute << ". " << error_msg;
|
||||
log("VM",Log::ERROR,oss);
|
||||
|
||||
free(error_msg);
|
||||
}
|
||||
|
||||
parsed = oss_parsed.str();
|
||||
|
||||
return rc;
|
||||
|
||||
error_yy:
|
||||
*error_msg=strdup("Error setting scan buffer");
|
||||
log("VM",Log::ERROR,"Error setting scan buffer");
|
||||
pthread_mutex_unlock(&lex_mutex);
|
||||
return -1;
|
||||
}
|
||||
@ -922,9 +1092,9 @@ error_yy:
|
||||
|
||||
ostream& operator<<(ostream& os, const VirtualMachine& vm)
|
||||
{
|
||||
string vm_str;
|
||||
string vm_str;
|
||||
|
||||
os << vm.to_xml(vm_str);
|
||||
os << vm.to_xml(vm_str);
|
||||
|
||||
return os;
|
||||
};
|
||||
@ -933,49 +1103,51 @@ ostream& operator<<(ostream& os, const VirtualMachine& vm)
|
||||
|
||||
string& VirtualMachine::to_xml(string& xml) const
|
||||
{
|
||||
string template_xml;
|
||||
|
||||
string template_xml;
|
||||
string history_xml;
|
||||
|
||||
ostringstream oss;
|
||||
ostringstream oss;
|
||||
|
||||
oss << "<VM>"
|
||||
<< "<ID>" << oid << "</ID>"
|
||||
<< "<UID>" << uid << "</UID>"
|
||||
<< "<NAME>" << name << "</NAME>"
|
||||
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
|
||||
<< "<STATE>" << state << "</STATE>"
|
||||
<< "<LCM_STATE>" << lcm_state << "</LCM_STATE>"
|
||||
<< "<STIME>" << stime << "</STIME>"
|
||||
<< "<ETIME>" << etime << "</ETIME>"
|
||||
<< "<DEPLOY_ID>" << deploy_id << "</DEPLOY_ID>"
|
||||
<< "<MEMORY>" << memory << "</MEMORY>"
|
||||
<< "<CPU>" << cpu << "</CPU>"
|
||||
<< "<NET_TX>" << net_tx << "</NET_TX>"
|
||||
<< "<NET_RX>" << net_rx << "</NET_RX>"
|
||||
<< "<LAST_SEQ>" << last_seq << "</LAST_SEQ>"
|
||||
<< vm_template.to_xml(template_xml);
|
||||
oss << "<VM>"
|
||||
<< "<ID>" << oid << "</ID>"
|
||||
<< "<UID>" << uid << "</UID>"
|
||||
<< "<NAME>" << name << "</NAME>"
|
||||
<< "<LAST_POLL>" << last_poll << "</LAST_POLL>"
|
||||
<< "<STATE>" << state << "</STATE>"
|
||||
<< "<LCM_STATE>" << lcm_state << "</LCM_STATE>"
|
||||
<< "<STIME>" << stime << "</STIME>"
|
||||
<< "<ETIME>" << etime << "</ETIME>"
|
||||
<< "<DEPLOY_ID>" << deploy_id << "</DEPLOY_ID>"
|
||||
<< "<MEMORY>" << memory << "</MEMORY>"
|
||||
<< "<CPU>" << cpu << "</CPU>"
|
||||
<< "<NET_TX>" << net_tx << "</NET_TX>"
|
||||
<< "<NET_RX>" << net_rx << "</NET_RX>"
|
||||
<< "<LAST_SEQ>" << last_seq << "</LAST_SEQ>"
|
||||
<< vm_template.to_xml(template_xml);
|
||||
|
||||
if ( hasHistory() )
|
||||
{
|
||||
oss << history->to_xml(history_xml);
|
||||
}
|
||||
oss << "</VM>";
|
||||
|
||||
xml = oss.str();
|
||||
oss << "</VM>";
|
||||
|
||||
return xml;
|
||||
xml = oss.str();
|
||||
|
||||
return xml;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
string& VirtualMachine::to_str(string& str) const
|
||||
{
|
||||
string template_str;
|
||||
string template_str;
|
||||
string history_str;
|
||||
|
||||
ostringstream oss;
|
||||
ostringstream oss;
|
||||
|
||||
oss<< "ID : " << oid << endl
|
||||
oss<< "ID : " << oid << endl
|
||||
<< "UID : " << uid << endl
|
||||
<< "NAME : " << name << endl
|
||||
<< "STATE : " << state << endl
|
||||
@ -996,9 +1168,9 @@ string& VirtualMachine::to_str(string& str) const
|
||||
oss << "Last History Record" << endl << history->to_str(history_str);
|
||||
}
|
||||
|
||||
str = oss.str();
|
||||
str = oss.str();
|
||||
|
||||
return str;
|
||||
return str;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -158,10 +158,7 @@ int VirtualMachinePool::allocate (
|
||||
VirtualMachine * vm;
|
||||
|
||||
char * error_msg;
|
||||
int rc, num_context, num_reqs;
|
||||
|
||||
vector<Attribute *> context;
|
||||
vector<Attribute *> reqs;
|
||||
int rc;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Build a new Virtual Machine object
|
||||
@ -180,7 +177,7 @@ int VirtualMachinePool::allocate (
|
||||
vm->uid = uid;
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parse template and keep CONTEXT apart
|
||||
// Parse template
|
||||
// ------------------------------------------------------------------------
|
||||
rc = vm->vm_template.parse(stemplate,&error_msg);
|
||||
|
||||
@ -197,9 +194,6 @@ int VirtualMachinePool::allocate (
|
||||
return -2;
|
||||
}
|
||||
|
||||
num_context = vm->vm_template.remove("CONTEXT",context);
|
||||
num_reqs = vm->vm_template.remove("REQUIREMENTS",reqs);
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Insert the Object in the pool
|
||||
// ------------------------------------------------------------------------
|
||||
@ -211,40 +205,6 @@ int VirtualMachinePool::allocate (
|
||||
return -1;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Insert parsed context in the VM template and clean-up
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( num_context > 0)
|
||||
{
|
||||
generate_context(*oid,context[0]);
|
||||
|
||||
for (int i = 0; i < num_context ; i++)
|
||||
{
|
||||
if (context[i] != 0)
|
||||
{
|
||||
delete context[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------------------
|
||||
// Parse the Requirements
|
||||
// ------------------------------------------------------------------------
|
||||
|
||||
if ( num_reqs > 0 )
|
||||
{
|
||||
generate_requirements(*oid,reqs[0]);
|
||||
|
||||
for (int i = 0; i < num_reqs ; i++)
|
||||
{
|
||||
if (reqs[i] != 0)
|
||||
{
|
||||
delete reqs[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return *oid;
|
||||
}
|
||||
|
||||
@ -285,131 +245,6 @@ int VirtualMachinePool::get_pending(
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachinePool::generate_context(int vm_id, Attribute * attr)
|
||||
{
|
||||
VirtualMachine * vm;
|
||||
VectorAttribute * context_parsed;
|
||||
VectorAttribute * context;
|
||||
|
||||
string * str;
|
||||
string parsed;
|
||||
|
||||
int rc;
|
||||
|
||||
char * error_msg;
|
||||
|
||||
context = dynamic_cast<VectorAttribute *>(attr);
|
||||
|
||||
if (context == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
str = context->marshall(" @^_^@ ");
|
||||
|
||||
if (str == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rc = VirtualMachine::parse_template_attribute(vm_id,*str,parsed,&error_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
if (error_msg != 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << error_msg << ": " << *str;
|
||||
free(error_msg);
|
||||
|
||||
NebulaLog::log("ONE", Log::ERROR, oss);
|
||||
}
|
||||
|
||||
delete str;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
delete str;
|
||||
|
||||
context_parsed = new VectorAttribute("CONTEXT");
|
||||
context_parsed->unmarshall(parsed," @^_^@ ");
|
||||
|
||||
vm = get(vm_id,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
delete context_parsed;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vm->insert_template_attribute(db,context_parsed) != 0 )
|
||||
{
|
||||
delete context_parsed;
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void VirtualMachinePool::generate_requirements(int vm_id, Attribute * attr)
|
||||
{
|
||||
SingleAttribute * reqs;
|
||||
string parsed;
|
||||
char * error_msg;
|
||||
int rc;
|
||||
|
||||
SingleAttribute * reqs_parsed;
|
||||
VirtualMachine * vm;
|
||||
|
||||
reqs = dynamic_cast<SingleAttribute *>(attr);
|
||||
|
||||
if (reqs == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
rc = VirtualMachine::parse_template_attribute(vm_id,reqs->value(),
|
||||
parsed,&error_msg);
|
||||
|
||||
if ( rc != 0 )
|
||||
{
|
||||
if (error_msg != 0)
|
||||
{
|
||||
ostringstream oss;
|
||||
|
||||
oss << error_msg << ": " << reqs->value();
|
||||
free(error_msg);
|
||||
|
||||
NebulaLog::log("ONE", Log::ERROR, oss);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
reqs_parsed = new SingleAttribute("REQUIREMENTS",parsed);
|
||||
|
||||
vm = get(vm_id,true);
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
delete reqs_parsed;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vm->insert_template_attribute(db,reqs_parsed) != 0 )
|
||||
{
|
||||
delete reqs_parsed;
|
||||
}
|
||||
|
||||
vm->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
int VirtualMachinePool::dump_cb(void * _oss,int num,char **values,char **names)
|
||||
{
|
||||
ostringstream * oss;
|
||||
@ -454,3 +289,6 @@ int VirtualMachinePool::dump(ostringstream& oss, const string& where)
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
@ -69,42 +69,13 @@ const string xmls[] =
|
||||
|
||||
// This xml dump result has the STIMEs modified to 0000000000
|
||||
const string xml_dump =
|
||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one"
|
||||
"</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><ST"
|
||||
"IME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</ME"
|
||||
"MORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX></VM><VM><ID>1</ID><U"
|
||||
"ID>2</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</L"
|
||||
"AST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME>"
|
||||
"<ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_"
|
||||
"TX>0</NET_TX><NET_RX>0</NET_RX></VM></VM_POOL>";
|
||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM><VM><ID>1</ID><UID>2</UID><USERNAME>B user</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM></VM_POOL>";
|
||||
|
||||
const string xml_dump_where =
|
||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one"
|
||||
"</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><ST"
|
||||
"IME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</ME"
|
||||
"MORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX></VM></VM_POOL>";
|
||||
"<VM_POOL><VM><ID>0</ID><UID>1</UID><USERNAME>A user</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM></VM_POOL>";
|
||||
|
||||
const string xml_history_dump =
|
||||
"<VM_POOL><VM><ID>0</ID><UID>0</UID><USERNAME>one_user_test</USERNAME>"
|
||||
"<NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>"
|
||||
"0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID>"
|
||||
"</DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>"
|
||||
"0</NET_RX></VM><VM><ID>1</ID><UID>0</UID><USERNAME>"
|
||||
"one_user_test</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL>"
|
||||
"<STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME>"
|
||||
"<ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU>"
|
||||
"<NET_TX>0</NET_TX><NET_RX>0</NET_RX><HISTORY><SEQ>0</SEQ><HOSTNAME>"
|
||||
"A_hostname</HOSTNAME><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>"
|
||||
"0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>"
|
||||
"0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2"
|
||||
"</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME>"
|
||||
"<LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>"
|
||||
"0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0"
|
||||
"</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><HISTORY><SEQ>1"
|
||||
"</SEQ><HOSTNAME>C_hostname</HOSTNAME><HID>2</HID><STIME>0</STIME><ETIME>0"
|
||||
"</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0"
|
||||
"</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY>"
|
||||
"</VM></VM_POOL>";
|
||||
"<VM_POOL><VM><ID>0</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>1</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>-1</LAST_SEQ></VM><VM><ID>1</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>Second VM</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>0</LAST_SEQ><HISTORY><SEQ>0</SEQ><HOSTNAME>A_hostname</HOSTNAME><HID>0</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM><VM><ID>2</ID><UID>0</UID><USERNAME>one_user_test</USERNAME><NAME>VM one</NAME><LAST_POLL>0</LAST_POLL><STATE>2</STATE><LCM_STATE>0</LCM_STATE><STIME>0000000000</STIME><ETIME>0</ETIME><DEPLOY_ID></DEPLOY_ID><MEMORY>0</MEMORY><CPU>0</CPU><NET_TX>0</NET_TX><NET_RX>0</NET_RX><LAST_SEQ>1</LAST_SEQ><HISTORY><SEQ>1</SEQ><HOSTNAME>C_hostname</HOSTNAME><HID>2</HID><STIME>0</STIME><ETIME>0</ETIME><PSTIME>0</PSTIME><PETIME>0</PETIME><RSTIME>0</RSTIME><RETIME>0</RETIME><ESTIME>0</ESTIME><EETIME>0</EETIME><REASON>0</REASON></HISTORY></VM></VM_POOL>";
|
||||
|
||||
const string replacement = "0000000000";
|
||||
|
||||
@ -271,11 +242,11 @@ public:
|
||||
|
||||
rc = vmp->dump(oss, "");
|
||||
CPPUNIT_ASSERT(rc == 0);
|
||||
cout << endl << oss.str() << endl;
|
||||
|
||||
string result = oss.str();
|
||||
result.replace(152, 10, replacement);
|
||||
result.replace(426, 10, replacement);
|
||||
|
||||
result.replace(449, 10, replacement);
|
||||
|
||||
CPPUNIT_ASSERT( result == xml_dump );
|
||||
}
|
||||
|
||||
@ -335,7 +306,7 @@ cout << endl << oss.str() << endl;
|
||||
// Add a history item
|
||||
vm->add_history(0, hostnames[0], vm_dirs[0], vmm_mads[0], tm_mads[0]);
|
||||
|
||||
rc = vmp->update(vm);
|
||||
rc = vmp->update(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
rc = vmp->update_history(vm);
|
||||
@ -353,7 +324,7 @@ cout << endl << oss.str() << endl;
|
||||
// Add a history item
|
||||
vm->add_history(1, hostnames[1], vm_dirs[1], vmm_mads[1], tm_mads[1]);
|
||||
|
||||
rc = vmp->update(vm);
|
||||
rc = vmp->update(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
rc = vmp->update_history(vm);
|
||||
@ -362,7 +333,7 @@ cout << endl << oss.str() << endl;
|
||||
// Add another history item
|
||||
vm->add_history(2, hostnames[2], vm_dirs[2], vmm_mads[2], tm_mads[2]);
|
||||
|
||||
rc = vmp->update(vm);
|
||||
rc = vmp->update(vm);
|
||||
CPPUNIT_ASSERT( rc == 0 );
|
||||
|
||||
rc = vmp->update_history(vm);
|
||||
@ -394,8 +365,8 @@ cout << endl << oss.str() << endl;
|
||||
string result = oss.str();
|
||||
|
||||
result.replace(159, 10, replacement);
|
||||
result.replace(440, 10, replacement);
|
||||
result.replace(950, 10, replacement);
|
||||
result.replace(463, 10, replacement);
|
||||
result.replace(995, 10, replacement);
|
||||
|
||||
CPPUNIT_ASSERT( result == xml_history_dump );
|
||||
}
|
||||
|
@ -392,8 +392,8 @@ static void yy_fatal_error (yyconst char msg[] );
|
||||
*yy_cp = '\0'; \
|
||||
(yy_c_buf_p) = yy_cp;
|
||||
|
||||
#define YY_NUM_RULES 12
|
||||
#define YY_END_OF_BUFFER 13
|
||||
#define YY_NUM_RULES 11
|
||||
#define YY_END_OF_BUFFER 12
|
||||
/* This struct is not used in this scanner,
|
||||
but its presence is necessary. */
|
||||
struct yy_trans_info
|
||||
@ -401,12 +401,11 @@ struct yy_trans_info
|
||||
flex_int32_t yy_verify;
|
||||
flex_int32_t yy_nxt;
|
||||
};
|
||||
static yyconst flex_int16_t yy_accept[33] =
|
||||
static yyconst flex_int16_t yy_accept[30] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 13, 11, 1, 10, 10, 12,
|
||||
10, 9, 3, 7, 2, 7, 4, 5, 11, 0,
|
||||
3, 2, 5, 0, 8, 3, 6, 7, 7, 2,
|
||||
4, 0
|
||||
0, 0, 0, 0, 12, 10, 1, 9, 9, 11,
|
||||
9, 8, 3, 6, 2, 4, 5, 10, 0, 3,
|
||||
2, 5, 0, 7, 3, 6, 2, 4, 0
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_ec[256] =
|
||||
@ -415,16 +414,16 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 2, 1, 4, 1, 5, 1, 1, 1, 1,
|
||||
1, 1, 1, 6, 1, 7, 1, 8, 8, 8,
|
||||
8, 8, 8, 8, 8, 8, 8, 1, 1, 1,
|
||||
9, 1, 1, 1, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
11, 1, 12, 1, 10, 1, 10, 10, 10, 10,
|
||||
1, 1, 1, 6, 1, 1, 1, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 1, 1, 1,
|
||||
8, 1, 1, 1, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
9, 1, 10, 1, 7, 1, 7, 7, 7, 7,
|
||||
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
|
||||
10, 10, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 7, 7, 7, 7, 7, 7, 7, 7,
|
||||
7, 7, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
|
||||
@ -441,52 +440,49 @@ static yyconst flex_int32_t yy_ec[256] =
|
||||
1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int32_t yy_meta[13] =
|
||||
static yyconst flex_int32_t yy_meta[11] =
|
||||
{ 0,
|
||||
1, 1, 1, 1, 2, 1, 1, 3, 1, 3,
|
||||
1, 1
|
||||
1, 1, 1, 1, 2, 1, 1, 1, 1, 1
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_base[37] =
|
||||
static yyconst flex_int16_t yy_base[33] =
|
||||
{ 0,
|
||||
36, 35, 0, 0, 39, 0, 42, 42, 11, 42,
|
||||
34, 42, 35, 17, 30, 0, 24, 42, 0, 0,
|
||||
20, 19, 42, 15, 42, 16, 42, 0, 0, 14,
|
||||
13, 42, 27, 30, 33, 11
|
||||
29, 28, 0, 0, 32, 0, 35, 35, 9, 35,
|
||||
27, 35, 28, 22, 26, 25, 35, 0, 0, 24,
|
||||
23, 35, 20, 35, 16, 9, 12, 11, 35, 19,
|
||||
11, 21
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_def[37] =
|
||||
static yyconst flex_int16_t yy_def[33] =
|
||||
{ 0,
|
||||
33, 33, 32, 3, 32, 34, 32, 32, 32, 32,
|
||||
35, 32, 32, 32, 32, 36, 32, 32, 34, 9,
|
||||
32, 32, 32, 35, 32, 32, 32, 14, 36, 32,
|
||||
32, 0, 32, 32, 32, 32
|
||||
30, 30, 29, 3, 29, 31, 29, 29, 29, 29,
|
||||
32, 29, 29, 29, 29, 29, 29, 31, 9, 29,
|
||||
29, 29, 32, 29, 29, 29, 29, 29, 0, 29,
|
||||
29, 29
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_nxt[55] =
|
||||
static yyconst flex_int16_t yy_nxt[46] =
|
||||
{ 0,
|
||||
8, 9, 10, 11, 12, 13, 8, 14, 15, 16,
|
||||
17, 18, 20, 29, 31, 30, 21, 26, 25, 22,
|
||||
30, 26, 23, 27, 28, 31, 29, 6, 6, 6,
|
||||
19, 30, 19, 24, 24, 24, 26, 25, 32, 7,
|
||||
7, 5, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 32, 32, 32
|
||||
8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
|
||||
19, 18, 28, 27, 20, 26, 21, 25, 22, 6,
|
||||
6, 23, 23, 24, 27, 25, 28, 27, 26, 25,
|
||||
24, 29, 7, 7, 5, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29
|
||||
} ;
|
||||
|
||||
static yyconst flex_int16_t yy_chk[55] =
|
||||
static yyconst flex_int16_t yy_chk[46] =
|
||||
{ 0,
|
||||
3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
|
||||
3, 3, 9, 36, 31, 30, 9, 26, 24, 9,
|
||||
22, 21, 9, 14, 14, 17, 14, 33, 33, 33,
|
||||
34, 15, 34, 35, 35, 35, 13, 11, 5, 2,
|
||||
1, 32, 32, 32, 32, 32, 32, 32, 32, 32,
|
||||
32, 32, 32, 32
|
||||
9, 31, 28, 27, 9, 26, 9, 25, 9, 30,
|
||||
30, 32, 32, 23, 21, 20, 16, 15, 14, 13,
|
||||
11, 5, 2, 1, 29, 29, 29, 29, 29, 29,
|
||||
29, 29, 29, 29, 29
|
||||
} ;
|
||||
|
||||
/* Table of booleans, true if rule could match eol. */
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[13] =
|
||||
static yyconst flex_int32_t yy_rule_can_match_eol[12] =
|
||||
{ 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, };
|
||||
0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, };
|
||||
|
||||
static yy_state_type yy_last_accepting_state;
|
||||
static char *yy_last_accepting_cpos;
|
||||
@ -532,7 +528,7 @@ char *vm_var_text;
|
||||
llocp->first_column = llocp->last_column; \
|
||||
llocp->last_column += vm_var_leng;
|
||||
|
||||
#line 536 "vm_var_parser.c"
|
||||
#line 532 "vm_var_parser.c"
|
||||
|
||||
#define INITIAL 0
|
||||
#define VAR 1
|
||||
@ -724,7 +720,7 @@ YY_DECL
|
||||
/* $NUM.CONTEXT_VARIABLE */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
|
||||
#line 728 "vm_var_parser.c"
|
||||
#line 724 "vm_var_parser.c"
|
||||
|
||||
if ( !(yy_init) )
|
||||
{
|
||||
@ -777,13 +773,13 @@ yy_match:
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 33 )
|
||||
if ( yy_current_state >= 30 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
++yy_cp;
|
||||
}
|
||||
while ( yy_base[yy_current_state] != 42 );
|
||||
while ( yy_base[yy_current_state] != 35 );
|
||||
|
||||
yy_find_action:
|
||||
yy_act = yy_accept[yy_current_state];
|
||||
@ -845,33 +841,26 @@ YY_RULE_SETUP
|
||||
case 6:
|
||||
YY_RULE_SETUP
|
||||
#line 55 "vm_var_parser.l"
|
||||
{ vm_var_text[vm_var_leng-1] = '\0';
|
||||
lvalp->val_int = atoi(vm_var_text);
|
||||
return INTEGER;}
|
||||
YY_BREAK
|
||||
case 7:
|
||||
YY_RULE_SETUP
|
||||
#line 58 "vm_var_parser.l"
|
||||
{ lvalp->val_str = strdup(vm_var_text);
|
||||
return VARIABLE;}
|
||||
YY_BREAK
|
||||
case 8:
|
||||
/* rule 8 can match eol */
|
||||
case 7:
|
||||
/* rule 7 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 60 "vm_var_parser.l"
|
||||
#line 58 "vm_var_parser.l"
|
||||
{ lvalp->val_str = strdup(vm_var_text+1);
|
||||
lvalp->val_str[vm_var_leng-2] = '\0';
|
||||
return STRING;}
|
||||
YY_BREAK
|
||||
case 9:
|
||||
case 8:
|
||||
YY_RULE_SETUP
|
||||
#line 64 "vm_var_parser.l"
|
||||
#line 62 "vm_var_parser.l"
|
||||
{ lvalp->val_char = '\0';
|
||||
return EOA;}
|
||||
YY_BREAK
|
||||
case 10:
|
||||
case 9:
|
||||
YY_RULE_SETUP
|
||||
#line 66 "vm_var_parser.l"
|
||||
#line 65 "vm_var_parser.l"
|
||||
{ lvalp->val_char = *vm_var_text;
|
||||
BEGIN(INITIAL);
|
||||
return EOA;}
|
||||
@ -885,18 +874,18 @@ case YY_STATE_EOF(VAR):
|
||||
/* ------------------------------------------------------------------------- */
|
||||
/* Just copy the string verbatim till we find a variable (starts with $) */
|
||||
/* ------------------------------------------------------------------------- */
|
||||
case 11:
|
||||
/* rule 11 can match eol */
|
||||
case 10:
|
||||
/* rule 10 can match eol */
|
||||
YY_RULE_SETUP
|
||||
#line 77 "vm_var_parser.l"
|
||||
{ lvalp->val_str = strdup(vm_var_text); return RSTRING;}
|
||||
YY_BREAK
|
||||
case 12:
|
||||
case 11:
|
||||
YY_RULE_SETUP
|
||||
#line 79 "vm_var_parser.l"
|
||||
ECHO;
|
||||
YY_BREAK
|
||||
#line 900 "vm_var_parser.c"
|
||||
#line 889 "vm_var_parser.c"
|
||||
case YY_STATE_EOF(INITIAL):
|
||||
yyterminate();
|
||||
|
||||
@ -1188,7 +1177,7 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 33 )
|
||||
if ( yy_current_state >= 30 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
@ -1216,11 +1205,11 @@ static int yy_get_next_buffer (void)
|
||||
while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
|
||||
{
|
||||
yy_current_state = (int) yy_def[yy_current_state];
|
||||
if ( yy_current_state >= 33 )
|
||||
if ( yy_current_state >= 30 )
|
||||
yy_c = yy_meta[(unsigned int) yy_c];
|
||||
}
|
||||
yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
|
||||
yy_is_jam = (yy_current_state == 32);
|
||||
yy_is_jam = (yy_current_state == 29);
|
||||
|
||||
return yy_is_jam ? 0 : yy_current_state;
|
||||
}
|
||||
|
@ -52,20 +52,20 @@
|
||||
<VAR>\[[[:blank:]]* { return OBRACKET;}
|
||||
<VAR>[[:blank:]]*\] { return CBRACKET;}
|
||||
|
||||
<VAR>[[:digit:]]+\. { yytext[yyleng-1] = '\0';
|
||||
lvalp->val_int = atoi(yytext);
|
||||
return INTEGER;}
|
||||
<VAR>[[:alnum:]_]+ { lvalp->val_str = strdup(yytext);
|
||||
return VARIABLE;}
|
||||
|
||||
<VAR>\"[^\"]*\" { lvalp->val_str = strdup(yytext+1);
|
||||
lvalp->val_str[yyleng-2] = '\0';
|
||||
return STRING;}
|
||||
|
||||
<VAR>\$ { lvalp->val_char = '\0';
|
||||
return EOA;}
|
||||
|
||||
<VAR>. { lvalp->val_char = *yytext;
|
||||
BEGIN(INITIAL);
|
||||
return EOA;}
|
||||
|
||||
<VAR><<EOF>> { lvalp->val_char = '\0';
|
||||
BEGIN(INITIAL);
|
||||
return EOA;}
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton implementation for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -46,7 +45,7 @@
|
||||
#define YYBISON 1
|
||||
|
||||
/* Bison version. */
|
||||
#define YYBISON_VERSION "2.4.1"
|
||||
#define YYBISON_VERSION "2.4.2"
|
||||
|
||||
/* Skeleton name. */
|
||||
#define YYSKELETON_NAME "yacc.c"
|
||||
@ -100,8 +99,7 @@ extern "C"
|
||||
{
|
||||
void vm_var_error(
|
||||
YYLTYPE * llocp,
|
||||
VirtualMachine * vm,
|
||||
int vm_id,
|
||||
VirtualMachine * vm,
|
||||
ostringstream * parsed,
|
||||
char ** errmsg,
|
||||
const char * str);
|
||||
@ -109,7 +107,6 @@ void vm_var_error(
|
||||
int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp);
|
||||
|
||||
int vm_var_parse (VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream * parsed,
|
||||
char ** errmsg);
|
||||
}
|
||||
@ -117,71 +114,109 @@ int vm_var_parse (VirtualMachine * vm,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_single(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream& parsed,
|
||||
const string& name)
|
||||
void get_network_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& net_name,
|
||||
const string& net_value,
|
||||
string& attr_value)
|
||||
{
|
||||
VirtualMachine * tvm = vm;
|
||||
string value = "";
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
tvm = nd.get_vmpool()->get(vm_id,true);
|
||||
VirtualNetworkPool * vnpool = nd.get_vnpool();
|
||||
VirtualNetwork * vn;
|
||||
|
||||
string network = "";
|
||||
|
||||
attr_value = "";
|
||||
|
||||
if (net_name.empty())
|
||||
{
|
||||
vector<const Attribute *> nics;
|
||||
const VectorAttribute * nic;
|
||||
|
||||
if (vm->get_template_attribute("NIC",nics) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nic = dynamic_cast<const VectorAttribute * >(nics[0]);
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
network = nic->vector_value("NETWORK");
|
||||
}
|
||||
|
||||
if ( tvm == 0 )
|
||||
else if (net_name == "NAME")
|
||||
{
|
||||
network = net_value;
|
||||
}
|
||||
|
||||
if ( network.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tvm->get_template_attribute(name.c_str(),value);
|
||||
vn = vnpool->get(network,true);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
|
||||
vn->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_single(VirtualMachine * vm,
|
||||
ostringstream& parsed,
|
||||
const string& name)
|
||||
{
|
||||
string value = "";
|
||||
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
|
||||
parsed << value;
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
tvm->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_vector(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream& parsed,
|
||||
const string& name,
|
||||
const string& vname,
|
||||
const string& vvar,
|
||||
const string& vval)
|
||||
|
||||
{
|
||||
VirtualMachine * tvm = vm;
|
||||
|
||||
{
|
||||
vector<const Attribute*> values;
|
||||
const VectorAttribute * vattr = 0;
|
||||
|
||||
int num;
|
||||
string value = "";
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
tvm = nd.get_vmpool()->get(vm_id,true);
|
||||
}
|
||||
|
||||
if ( tvm == 0 )
|
||||
|
||||
if ( name == "NETWORK")
|
||||
{
|
||||
string value;
|
||||
|
||||
get_network_attribute(vm,vname,vvar,vval,value);
|
||||
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
{
|
||||
goto error_name;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vvar.empty() )
|
||||
@ -190,7 +225,7 @@ void insert_vector(VirtualMachine * vm,
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
@ -208,12 +243,6 @@ void insert_vector(VirtualMachine * vm,
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
}
|
||||
|
||||
error_name:
|
||||
if ( vm == 0 )
|
||||
{
|
||||
tvm->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -222,7 +251,7 @@ error_name:
|
||||
|
||||
|
||||
/* Line 189 of yacc.c */
|
||||
#line 226 "vm_var_syntax.cc"
|
||||
#line 255 "vm_var_syntax.cc"
|
||||
|
||||
/* Enabling traces. */
|
||||
#ifndef YYDEBUG
|
||||
@ -268,7 +297,7 @@ typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 166 "vm_var_syntax.y"
|
||||
#line 195 "vm_var_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
@ -277,7 +306,7 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
/* Line 214 of yacc.c */
|
||||
#line 281 "vm_var_syntax.cc"
|
||||
#line 310 "vm_var_syntax.cc"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
@ -302,7 +331,7 @@ typedef struct YYLTYPE
|
||||
|
||||
|
||||
/* Line 264 of yacc.c */
|
||||
#line 306 "vm_var_syntax.cc"
|
||||
#line 335 "vm_var_syntax.cc"
|
||||
|
||||
#ifdef short
|
||||
# undef short
|
||||
@ -352,7 +381,7 @@ typedef short int yytype_int16;
|
||||
#define YYSIZE_MAXIMUM ((YYSIZE_T) -1)
|
||||
|
||||
#ifndef YY_
|
||||
# if YYENABLE_NLS
|
||||
# if defined YYENABLE_NLS && YYENABLE_NLS
|
||||
# if ENABLE_NLS
|
||||
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
|
||||
# define YY_(msgid) dgettext ("bison-runtime", msgid)
|
||||
@ -517,18 +546,18 @@ union yyalloc
|
||||
#endif
|
||||
|
||||
/* YYFINAL -- State number of the termination state. */
|
||||
#define YYFINAL 9
|
||||
#define YYFINAL 7
|
||||
/* YYLAST -- Last index in YYTABLE. */
|
||||
#define YYLAST 20
|
||||
#define YYLAST 18
|
||||
|
||||
/* YYNTOKENS -- Number of terminals. */
|
||||
#define YYNTOKENS 12
|
||||
/* YYNNTS -- Number of nonterminals. */
|
||||
#define YYNNTS 3
|
||||
/* YYNRULES -- Number of rules. */
|
||||
#define YYNRULES 8
|
||||
#define YYNRULES 7
|
||||
/* YYNRULES -- Number of states. */
|
||||
#define YYNSTATES 21
|
||||
#define YYNSTATES 18
|
||||
|
||||
/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX. */
|
||||
#define YYUNDEFTOK 2
|
||||
@ -574,7 +603,7 @@ static const yytype_uint8 yytranslate[] =
|
||||
YYRHS. */
|
||||
static const yytype_uint8 yyprhs[] =
|
||||
{
|
||||
0, 0, 3, 5, 8, 10, 13, 19, 29
|
||||
0, 0, 3, 5, 8, 10, 13, 19
|
||||
};
|
||||
|
||||
/* YYRHS -- A `-1'-separated list of the rules' RHS. */
|
||||
@ -582,14 +611,13 @@ static const yytype_int8 yyrhs[] =
|
||||
{
|
||||
13, 0, -1, 14, -1, 13, 14, -1, 10, -1,
|
||||
9, 7, -1, 9, 5, 9, 6, 7, -1, 9,
|
||||
5, 9, 4, 9, 3, 8, 6, 7, -1, 11,
|
||||
9, 7, -1
|
||||
5, 9, 4, 9, 3, 8, 6, 7, -1
|
||||
};
|
||||
|
||||
/* YYRLINE[YYN] -- source line where rule number YYN was defined. */
|
||||
static const yytype_uint8 yyrline[] =
|
||||
static const yytype_uint16 yyrline[] =
|
||||
{
|
||||
0, 190, 190, 191, 194, 199, 214, 232, 255
|
||||
0, 219, 219, 220, 223, 228, 243, 261
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -617,13 +645,13 @@ static const yytype_uint16 yytoknum[] =
|
||||
/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives. */
|
||||
static const yytype_uint8 yyr1[] =
|
||||
{
|
||||
0, 12, 13, 13, 14, 14, 14, 14, 14
|
||||
0, 12, 13, 13, 14, 14, 14, 14
|
||||
};
|
||||
|
||||
/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN. */
|
||||
static const yytype_uint8 yyr2[] =
|
||||
{
|
||||
0, 2, 1, 2, 1, 2, 5, 9, 3
|
||||
0, 2, 1, 2, 1, 2, 5, 9
|
||||
};
|
||||
|
||||
/* YYDEFACT[STATE-NAME] -- Default rule to reduce with in state
|
||||
@ -631,31 +659,29 @@ static const yytype_uint8 yyr2[] =
|
||||
means the default is an error. */
|
||||
static const yytype_uint8 yydefact[] =
|
||||
{
|
||||
0, 0, 4, 0, 0, 2, 0, 5, 0, 1,
|
||||
3, 0, 8, 0, 0, 0, 6, 0, 0, 0,
|
||||
7
|
||||
0, 0, 4, 0, 2, 0, 5, 1, 3, 0,
|
||||
0, 0, 0, 6, 0, 0, 0, 7
|
||||
};
|
||||
|
||||
/* YYDEFGOTO[NTERM-NUM]. */
|
||||
static const yytype_int8 yydefgoto[] =
|
||||
{
|
||||
-1, 4, 5
|
||||
-1, 3, 4
|
||||
};
|
||||
|
||||
/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
|
||||
STATE-NUM. */
|
||||
#define YYPACT_NINF -9
|
||||
#define YYPACT_NINF -5
|
||||
static const yytype_int8 yypact[] =
|
||||
{
|
||||
-8, -1, -9, 3, 0, -9, 4, -9, 7, -9,
|
||||
-9, 1, -9, 6, 9, 5, -9, 10, 11, 12,
|
||||
-9
|
||||
-3, -4, -5, 0, -5, -1, -5, -5, -5, -2,
|
||||
2, 5, 10, -5, 6, 9, 11, -5
|
||||
};
|
||||
|
||||
/* YYPGOTO[NTERM-NUM]. */
|
||||
static const yytype_int8 yypgoto[] =
|
||||
{
|
||||
-9, -9, 16
|
||||
-5, -5, 13
|
||||
};
|
||||
|
||||
/* YYTABLE[YYPACT[STATE-NUM]]. What to do in state STATE-NUM. If
|
||||
@ -665,25 +691,22 @@ static const yytype_int8 yypgoto[] =
|
||||
#define YYTABLE_NINF -1
|
||||
static const yytype_uint8 yytable[] =
|
||||
{
|
||||
9, 1, 2, 3, 6, 13, 7, 14, 17, 1,
|
||||
2, 3, 8, 11, 12, 15, 16, 19, 18, 20,
|
||||
10
|
||||
7, 5, 10, 6, 11, 0, 1, 2, 9, 1,
|
||||
2, 12, 13, 14, 15, 16, 8, 0, 17
|
||||
};
|
||||
|
||||
static const yytype_uint8 yycheck[] =
|
||||
static const yytype_int8 yycheck[] =
|
||||
{
|
||||
0, 9, 10, 11, 5, 4, 7, 6, 3, 9,
|
||||
10, 11, 9, 9, 7, 9, 7, 6, 8, 7,
|
||||
4
|
||||
0, 5, 4, 7, 6, -1, 9, 10, 9, 9,
|
||||
10, 9, 7, 3, 8, 6, 3, -1, 7
|
||||
};
|
||||
|
||||
/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
|
||||
symbol of state STATE-NUM. */
|
||||
static const yytype_uint8 yystos[] =
|
||||
{
|
||||
0, 9, 10, 11, 13, 14, 5, 7, 9, 0,
|
||||
14, 9, 7, 4, 6, 9, 7, 3, 8, 6,
|
||||
7
|
||||
0, 9, 10, 13, 14, 5, 7, 0, 14, 9,
|
||||
4, 6, 9, 7, 3, 8, 6, 7
|
||||
};
|
||||
|
||||
#define yyerrok (yyerrstatus = 0)
|
||||
@ -698,9 +721,18 @@ static const yytype_uint8 yystos[] =
|
||||
|
||||
/* Like YYERROR except do call yyerror. This remains here temporarily
|
||||
to ease the transition to the new meaning of YYERROR, for GCC.
|
||||
Once GCC version 2 has supplanted version 1, this can go. */
|
||||
Once GCC version 2 has supplanted version 1, this can go. However,
|
||||
YYFAIL appears to be in use. Nevertheless, it is formally deprecated
|
||||
in Bison 2.4.2's NEWS entry, where a plan to phase it out is
|
||||
discussed. */
|
||||
|
||||
#define YYFAIL goto yyerrlab
|
||||
#if defined YYFAIL
|
||||
/* This is here to suppress warnings from the GCC cpp's
|
||||
-Wunused-macros. Normally we don't worry about that warning, but
|
||||
some users do, and we want to make it easy for users to remove
|
||||
YYFAIL uses, which will produce warnings from Bison 2.5. */
|
||||
#endif
|
||||
|
||||
#define YYRECOVERING() (!!yyerrstatus)
|
||||
|
||||
@ -716,7 +748,7 @@ do \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error: cannot back up")); \
|
||||
yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error: cannot back up")); \
|
||||
YYERROR; \
|
||||
} \
|
||||
while (YYID (0))
|
||||
@ -757,7 +789,7 @@ while (YYID (0))
|
||||
we won't break user code: when these are the locations we know. */
|
||||
|
||||
#ifndef YY_LOCATION_PRINT
|
||||
# if YYLTYPE_IS_TRIVIAL
|
||||
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
# define YY_LOCATION_PRINT(File, Loc) \
|
||||
fprintf (File, "%d.%d-%d.%d", \
|
||||
(Loc).first_line, (Loc).first_column, \
|
||||
@ -796,7 +828,7 @@ do { \
|
||||
{ \
|
||||
YYFPRINTF (stderr, "%s ", Title); \
|
||||
yy_symbol_print (stderr, \
|
||||
Type, Value, Location, vm, vm_id, parsed, errmsg); \
|
||||
Type, Value, Location, vm, parsed, errmsg); \
|
||||
YYFPRINTF (stderr, "\n"); \
|
||||
} \
|
||||
} while (YYID (0))
|
||||
@ -810,16 +842,15 @@ do { \
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
static void
|
||||
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg)
|
||||
yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg)
|
||||
#else
|
||||
static void
|
||||
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg)
|
||||
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg)
|
||||
FILE *yyoutput;
|
||||
int yytype;
|
||||
YYSTYPE const * const yyvaluep;
|
||||
YYLTYPE const * const yylocationp;
|
||||
VirtualMachine * vm;
|
||||
int vm_id;
|
||||
ostringstream * parsed;
|
||||
char ** errmsg;
|
||||
#endif
|
||||
@ -828,7 +859,6 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parse
|
||||
return;
|
||||
YYUSE (yylocationp);
|
||||
YYUSE (vm);
|
||||
YYUSE (vm_id);
|
||||
YYUSE (parsed);
|
||||
YYUSE (errmsg);
|
||||
# ifdef YYPRINT
|
||||
@ -852,16 +882,15 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parse
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
static void
|
||||
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg)
|
||||
yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, YYLTYPE const * const yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg)
|
||||
#else
|
||||
static void
|
||||
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg)
|
||||
yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg)
|
||||
FILE *yyoutput;
|
||||
int yytype;
|
||||
YYSTYPE const * const yyvaluep;
|
||||
YYLTYPE const * const yylocationp;
|
||||
VirtualMachine * vm;
|
||||
int vm_id;
|
||||
ostringstream * parsed;
|
||||
char ** errmsg;
|
||||
#endif
|
||||
@ -873,7 +902,7 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, err
|
||||
|
||||
YY_LOCATION_PRINT (yyoutput, *yylocationp);
|
||||
YYFPRINTF (yyoutput, ": ");
|
||||
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg);
|
||||
yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, vm, parsed, errmsg);
|
||||
YYFPRINTF (yyoutput, ")");
|
||||
}
|
||||
|
||||
@ -916,15 +945,14 @@ do { \
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
static void
|
||||
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg)
|
||||
yy_reduce_print (YYSTYPE *yyvsp, YYLTYPE *yylsp, int yyrule, VirtualMachine * vm, ostringstream * parsed, char ** errmsg)
|
||||
#else
|
||||
static void
|
||||
yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg)
|
||||
yy_reduce_print (yyvsp, yylsp, yyrule, vm, parsed, errmsg)
|
||||
YYSTYPE *yyvsp;
|
||||
YYLTYPE *yylsp;
|
||||
int yyrule;
|
||||
VirtualMachine * vm;
|
||||
int vm_id;
|
||||
ostringstream * parsed;
|
||||
char ** errmsg;
|
||||
#endif
|
||||
@ -940,7 +968,7 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg)
|
||||
YYFPRINTF (stderr, " $%d = ", yyi + 1);
|
||||
yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
|
||||
&(yyvsp[(yyi + 1) - (yynrhs)])
|
||||
, &(yylsp[(yyi + 1) - (yynrhs)]) , vm, vm_id, parsed, errmsg);
|
||||
, &(yylsp[(yyi + 1) - (yynrhs)]) , vm, parsed, errmsg);
|
||||
YYFPRINTF (stderr, "\n");
|
||||
}
|
||||
}
|
||||
@ -948,7 +976,7 @@ yy_reduce_print (yyvsp, yylsp, yyrule, vm, vm_id, parsed, errmsg)
|
||||
# define YY_REDUCE_PRINT(Rule) \
|
||||
do { \
|
||||
if (yydebug) \
|
||||
yy_reduce_print (yyvsp, yylsp, Rule, vm, vm_id, parsed, errmsg); \
|
||||
yy_reduce_print (yyvsp, yylsp, Rule, vm, parsed, errmsg); \
|
||||
} while (YYID (0))
|
||||
|
||||
/* Nonzero means print parse trace. It is left uninitialized so that
|
||||
@ -1199,16 +1227,15 @@ yysyntax_error (char *yyresult, int yystate, int yychar)
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
static void
|
||||
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg)
|
||||
yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, YYLTYPE *yylocationp, VirtualMachine * vm, ostringstream * parsed, char ** errmsg)
|
||||
#else
|
||||
static void
|
||||
yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg)
|
||||
yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, parsed, errmsg)
|
||||
const char *yymsg;
|
||||
int yytype;
|
||||
YYSTYPE *yyvaluep;
|
||||
YYLTYPE *yylocationp;
|
||||
VirtualMachine * vm;
|
||||
int vm_id;
|
||||
ostringstream * parsed;
|
||||
char ** errmsg;
|
||||
#endif
|
||||
@ -1216,7 +1243,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, vm, vm_id, parsed, errmsg)
|
||||
YYUSE (yyvaluep);
|
||||
YYUSE (yylocationp);
|
||||
YYUSE (vm);
|
||||
YYUSE (vm_id);
|
||||
YYUSE (parsed);
|
||||
YYUSE (errmsg);
|
||||
|
||||
@ -1241,7 +1267,7 @@ int yyparse ();
|
||||
#endif
|
||||
#else /* ! YYPARSE_PARAM */
|
||||
#if defined __STDC__ || defined __cplusplus
|
||||
int yyparse (VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg);
|
||||
int yyparse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg);
|
||||
#else
|
||||
int yyparse ();
|
||||
#endif
|
||||
@ -1269,12 +1295,11 @@ yyparse (YYPARSE_PARAM)
|
||||
#if (defined __STDC__ || defined __C99__FUNC__ \
|
||||
|| defined __cplusplus || defined _MSC_VER)
|
||||
int
|
||||
yyparse (VirtualMachine * vm, int vm_id, ostringstream * parsed, char ** errmsg)
|
||||
yyparse (VirtualMachine * vm, ostringstream * parsed, char ** errmsg)
|
||||
#else
|
||||
int
|
||||
yyparse (vm, vm_id, parsed, errmsg)
|
||||
yyparse (vm, parsed, errmsg)
|
||||
VirtualMachine * vm;
|
||||
int vm_id;
|
||||
ostringstream * parsed;
|
||||
char ** errmsg;
|
||||
#endif
|
||||
@ -1367,7 +1392,7 @@ YYLTYPE yylloc;
|
||||
yyvsp = yyvs;
|
||||
yylsp = yyls;
|
||||
|
||||
#if YYLTYPE_IS_TRIVIAL
|
||||
#if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
|
||||
/* Initialize the default location before parsing starts. */
|
||||
yylloc.first_line = yylloc.last_line = 1;
|
||||
yylloc.first_column = yylloc.last_column = 1;
|
||||
@ -1557,8 +1582,8 @@ yyreduce:
|
||||
{
|
||||
case 4:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 195 "vm_var_syntax.y"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 224 "vm_var_syntax.y"
|
||||
{
|
||||
(*parsed) << (yyvsp[(1) - (1)].val_str);
|
||||
free((yyvsp[(1) - (1)].val_str));
|
||||
@ -1567,14 +1592,14 @@ yyreduce:
|
||||
|
||||
case 5:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 200 "vm_var_syntax.y"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 229 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (2)].val_str));
|
||||
|
||||
VM_VAR_TO_UPPER(name);
|
||||
|
||||
insert_single(vm,vm_id,*parsed,name);
|
||||
insert_single(vm,*parsed,name);
|
||||
|
||||
if ( (yyvsp[(2) - (2)].val_char) != '\0' )
|
||||
{
|
||||
@ -1587,8 +1612,8 @@ yyreduce:
|
||||
|
||||
case 6:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 215 "vm_var_syntax.y"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 244 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (5)].val_str));
|
||||
string vname((yyvsp[(3) - (5)].val_str));
|
||||
@ -1596,7 +1621,7 @@ yyreduce:
|
||||
VM_VAR_TO_UPPER(name);
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
|
||||
insert_vector(vm,vm_id,*parsed,name,vname,"","");
|
||||
insert_vector(vm,*parsed,name,vname,"","");
|
||||
|
||||
if ( (yyvsp[(5) - (5)].val_char) != '\0' )
|
||||
{
|
||||
@ -1610,8 +1635,8 @@ yyreduce:
|
||||
|
||||
case 7:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 233 "vm_var_syntax.y"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 262 "vm_var_syntax.y"
|
||||
{
|
||||
string name((yyvsp[(1) - (9)].val_str));
|
||||
string vname((yyvsp[(3) - (9)].val_str));
|
||||
@ -1622,7 +1647,7 @@ yyreduce:
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
VM_VAR_TO_UPPER(vvar);
|
||||
|
||||
insert_vector(vm,vm_id,*parsed,name,vname,vvar,vval);
|
||||
insert_vector(vm,*parsed,name,vname,vvar,vval);
|
||||
|
||||
if ( (yyvsp[(9) - (9)].val_char) != '\0' )
|
||||
{
|
||||
@ -1636,31 +1661,10 @@ yyreduce:
|
||||
;}
|
||||
break;
|
||||
|
||||
case 8:
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 256 "vm_var_syntax.y"
|
||||
{
|
||||
string name("CONTEXT");
|
||||
string vname((yyvsp[(2) - (3)].val_str));
|
||||
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
|
||||
insert_vector(0,(yyvsp[(1) - (3)].val_int),*parsed,name,vname,"","");
|
||||
|
||||
if ( (yyvsp[(3) - (3)].val_char) != '\0' )
|
||||
{
|
||||
(*parsed) << (yyvsp[(3) - (3)].val_char);
|
||||
}
|
||||
|
||||
free((yyvsp[(2) - (3)].val_str));
|
||||
;}
|
||||
break;
|
||||
|
||||
|
||||
|
||||
/* Line 1455 of yacc.c */
|
||||
#line 1664 "vm_var_syntax.cc"
|
||||
/* Line 1464 of yacc.c */
|
||||
#line 1668 "vm_var_syntax.cc"
|
||||
default: break;
|
||||
}
|
||||
YY_SYMBOL_PRINT ("-> $$ =", yyr1[yyn], &yyval, &yyloc);
|
||||
@ -1696,7 +1700,7 @@ yyerrlab:
|
||||
{
|
||||
++yynerrs;
|
||||
#if ! YYERROR_VERBOSE
|
||||
yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error"));
|
||||
yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error"));
|
||||
#else
|
||||
{
|
||||
YYSIZE_T yysize = yysyntax_error (0, yystate, yychar);
|
||||
@ -1720,11 +1724,11 @@ yyerrlab:
|
||||
if (0 < yysize && yysize <= yymsg_alloc)
|
||||
{
|
||||
(void) yysyntax_error (yymsg, yystate, yychar);
|
||||
yyerror (&yylloc, vm, vm_id, parsed, errmsg, yymsg);
|
||||
yyerror (&yylloc, vm, parsed, errmsg, yymsg);
|
||||
}
|
||||
else
|
||||
{
|
||||
yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("syntax error"));
|
||||
yyerror (&yylloc, vm, parsed, errmsg, YY_("syntax error"));
|
||||
if (yysize != 0)
|
||||
goto yyexhaustedlab;
|
||||
}
|
||||
@ -1748,7 +1752,7 @@ yyerrlab:
|
||||
else
|
||||
{
|
||||
yydestruct ("Error: discarding",
|
||||
yytoken, &yylval, &yylloc, vm, vm_id, parsed, errmsg);
|
||||
yytoken, &yylval, &yylloc, vm, parsed, errmsg);
|
||||
yychar = YYEMPTY;
|
||||
}
|
||||
}
|
||||
@ -1805,7 +1809,7 @@ yyerrlab1:
|
||||
|
||||
yyerror_range[0] = *yylsp;
|
||||
yydestruct ("Error: popping",
|
||||
yystos[yystate], yyvsp, yylsp, vm, vm_id, parsed, errmsg);
|
||||
yystos[yystate], yyvsp, yylsp, vm, parsed, errmsg);
|
||||
YYPOPSTACK (1);
|
||||
yystate = *yyssp;
|
||||
YY_STACK_PRINT (yyss, yyssp);
|
||||
@ -1845,7 +1849,7 @@ yyabortlab:
|
||||
| yyexhaustedlab -- memory exhaustion comes here. |
|
||||
`-------------------------------------------------*/
|
||||
yyexhaustedlab:
|
||||
yyerror (&yylloc, vm, vm_id, parsed, errmsg, YY_("memory exhausted"));
|
||||
yyerror (&yylloc, vm, parsed, errmsg, YY_("memory exhausted"));
|
||||
yyresult = 2;
|
||||
/* Fall through. */
|
||||
#endif
|
||||
@ -1853,7 +1857,7 @@ yyexhaustedlab:
|
||||
yyreturn:
|
||||
if (yychar != YYEMPTY)
|
||||
yydestruct ("Cleanup: discarding lookahead",
|
||||
yytoken, &yylval, &yylloc, vm, vm_id, parsed, errmsg);
|
||||
yytoken, &yylval, &yylloc, vm, parsed, errmsg);
|
||||
/* Do not reclaim the symbols of the rule which action triggered
|
||||
this YYABORT or YYACCEPT. */
|
||||
YYPOPSTACK (yylen);
|
||||
@ -1861,7 +1865,7 @@ yyreturn:
|
||||
while (yyssp != yyss)
|
||||
{
|
||||
yydestruct ("Cleanup: popping",
|
||||
yystos[*yyssp], yyvsp, yylsp, vm, vm_id, parsed, errmsg);
|
||||
yystos[*yyssp], yyvsp, yylsp, vm, parsed, errmsg);
|
||||
YYPOPSTACK (1);
|
||||
}
|
||||
#ifndef yyoverflow
|
||||
@ -1878,14 +1882,13 @@ yyreturn:
|
||||
|
||||
|
||||
|
||||
/* Line 1675 of yacc.c */
|
||||
#line 272 "vm_var_syntax.y"
|
||||
/* Line 1684 of yacc.c */
|
||||
#line 285 "vm_var_syntax.y"
|
||||
|
||||
|
||||
extern "C" void vm_var_error(
|
||||
YYLTYPE * llocp,
|
||||
VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream * parsed,
|
||||
char ** error_msg,
|
||||
const char * str)
|
||||
|
@ -1,10 +1,9 @@
|
||||
|
||||
/* A Bison parser, made by GNU Bison 2.4.1. */
|
||||
/* A Bison parser, made by GNU Bison 2.4.2. */
|
||||
|
||||
/* Skeleton interface for Bison's Yacc-like parsers in C
|
||||
|
||||
Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006
|
||||
Free Software Foundation, Inc.
|
||||
Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
|
||||
Foundation, Inc.
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
@ -57,8 +56,8 @@
|
||||
typedef union YYSTYPE
|
||||
{
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 166 "vm_var_syntax.y"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 195 "vm_var_syntax.y"
|
||||
|
||||
char * val_str;
|
||||
int val_int;
|
||||
@ -66,8 +65,8 @@ typedef union YYSTYPE
|
||||
|
||||
|
||||
|
||||
/* Line 1676 of yacc.c */
|
||||
#line 71 "vm_var_syntax.hh"
|
||||
/* Line 1685 of yacc.c */
|
||||
#line 70 "vm_var_syntax.hh"
|
||||
} YYSTYPE;
|
||||
# define YYSTYPE_IS_TRIVIAL 1
|
||||
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
|
||||
|
@ -37,8 +37,7 @@ extern "C"
|
||||
{
|
||||
void vm_var_error(
|
||||
YYLTYPE * llocp,
|
||||
VirtualMachine * vm,
|
||||
int vm_id,
|
||||
VirtualMachine * vm,
|
||||
ostringstream * parsed,
|
||||
char ** errmsg,
|
||||
const char * str);
|
||||
@ -46,7 +45,6 @@ void vm_var_error(
|
||||
int vm_var_lex (YYSTYPE *lvalp, YYLTYPE *llocp);
|
||||
|
||||
int vm_var_parse (VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream * parsed,
|
||||
char ** errmsg);
|
||||
}
|
||||
@ -54,71 +52,109 @@ int vm_var_parse (VirtualMachine * vm,
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_single(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream& parsed,
|
||||
const string& name)
|
||||
void get_network_attribute(VirtualMachine * vm,
|
||||
const string& attr_name,
|
||||
const string& net_name,
|
||||
const string& net_value,
|
||||
string& attr_value)
|
||||
{
|
||||
VirtualMachine * tvm = vm;
|
||||
string value = "";
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
tvm = nd.get_vmpool()->get(vm_id,true);
|
||||
VirtualNetworkPool * vnpool = nd.get_vnpool();
|
||||
VirtualNetwork * vn;
|
||||
|
||||
string network = "";
|
||||
|
||||
attr_value = "";
|
||||
|
||||
if (net_name.empty())
|
||||
{
|
||||
vector<const Attribute *> nics;
|
||||
const VectorAttribute * nic;
|
||||
|
||||
if (vm->get_template_attribute("NIC",nics) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
nic = dynamic_cast<const VectorAttribute * >(nics[0]);
|
||||
|
||||
if ( nic == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
network = nic->vector_value("NETWORK");
|
||||
}
|
||||
|
||||
if ( tvm == 0 )
|
||||
else if (net_name == "NAME")
|
||||
{
|
||||
network = net_value;
|
||||
}
|
||||
|
||||
if ( network.empty() )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tvm->get_template_attribute(name.c_str(),value);
|
||||
vn = vnpool->get(network,true);
|
||||
|
||||
if ( vn == 0 )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
vn->get_template_attribute(attr_name.c_str(),attr_value);
|
||||
|
||||
vn->unlock();
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_single(VirtualMachine * vm,
|
||||
ostringstream& parsed,
|
||||
const string& name)
|
||||
{
|
||||
string value = "";
|
||||
|
||||
vm->get_template_attribute(name.c_str(),value);
|
||||
|
||||
parsed << value;
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
tvm->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
/* -------------------------------------------------------------------------- */
|
||||
|
||||
void insert_vector(VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream& parsed,
|
||||
const string& name,
|
||||
const string& vname,
|
||||
const string& vvar,
|
||||
const string& vval)
|
||||
|
||||
{
|
||||
VirtualMachine * tvm = vm;
|
||||
|
||||
{
|
||||
vector<const Attribute*> values;
|
||||
const VectorAttribute * vattr = 0;
|
||||
|
||||
int num;
|
||||
string value = "";
|
||||
|
||||
if ( vm == 0 )
|
||||
{
|
||||
Nebula& nd = Nebula::instance();
|
||||
|
||||
tvm = nd.get_vmpool()->get(vm_id,true);
|
||||
}
|
||||
|
||||
if ( tvm == 0 )
|
||||
|
||||
if ( name == "NETWORK")
|
||||
{
|
||||
string value;
|
||||
|
||||
get_network_attribute(vm,vname,vvar,vval,value);
|
||||
|
||||
if (!value.empty())
|
||||
{
|
||||
parsed << value;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if ( ( num = tvm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
if ( ( num = vm->get_template_attribute(name.c_str(),values) ) <= 0 )
|
||||
{
|
||||
goto error_name;
|
||||
return;
|
||||
}
|
||||
|
||||
if ( vvar.empty() )
|
||||
@ -127,7 +163,7 @@ void insert_vector(VirtualMachine * vm,
|
||||
}
|
||||
else
|
||||
{
|
||||
const VectorAttribute * tmp = 0;
|
||||
const VectorAttribute * tmp = 0;
|
||||
|
||||
for (int i=0 ; i < num ; i++)
|
||||
{
|
||||
@ -145,12 +181,6 @@ void insert_vector(VirtualMachine * vm,
|
||||
{
|
||||
parsed << vattr->vector_value(vname.c_str());
|
||||
}
|
||||
|
||||
error_name:
|
||||
if ( vm == 0 )
|
||||
{
|
||||
tvm->unlock();
|
||||
}
|
||||
}
|
||||
|
||||
/* -------------------------------------------------------------------------- */
|
||||
@ -159,7 +189,6 @@ error_name:
|
||||
%}
|
||||
|
||||
%parse-param {VirtualMachine * vm}
|
||||
%parse-param {int vm_id}
|
||||
%parse-param {ostringstream * parsed}
|
||||
%parse-param {char ** errmsg}
|
||||
|
||||
@ -202,7 +231,7 @@ vm_variable:RSTRING
|
||||
|
||||
VM_VAR_TO_UPPER(name);
|
||||
|
||||
insert_single(vm,vm_id,*parsed,name);
|
||||
insert_single(vm,*parsed,name);
|
||||
|
||||
if ( $2 != '\0' )
|
||||
{
|
||||
@ -219,7 +248,7 @@ vm_variable:RSTRING
|
||||
VM_VAR_TO_UPPER(name);
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
|
||||
insert_vector(vm,vm_id,*parsed,name,vname,"","");
|
||||
insert_vector(vm,*parsed,name,vname,"","");
|
||||
|
||||
if ( $5 != '\0' )
|
||||
{
|
||||
@ -240,7 +269,7 @@ vm_variable:RSTRING
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
VM_VAR_TO_UPPER(vvar);
|
||||
|
||||
insert_vector(vm,vm_id,*parsed,name,vname,vvar,vval);
|
||||
insert_vector(vm,*parsed,name,vname,vvar,vval);
|
||||
|
||||
if ( $9 != '\0' )
|
||||
{
|
||||
@ -252,29 +281,12 @@ vm_variable:RSTRING
|
||||
free($5);
|
||||
free($7);
|
||||
}
|
||||
| INTEGER VARIABLE EOA
|
||||
{
|
||||
string name("CONTEXT");
|
||||
string vname($2);
|
||||
|
||||
VM_VAR_TO_UPPER(vname);
|
||||
|
||||
insert_vector(0,$1,*parsed,name,vname,"","");
|
||||
|
||||
if ( $3 != '\0' )
|
||||
{
|
||||
(*parsed) << $3;
|
||||
}
|
||||
|
||||
free($2);
|
||||
}
|
||||
;
|
||||
%%
|
||||
|
||||
extern "C" void vm_var_error(
|
||||
YYLTYPE * llocp,
|
||||
VirtualMachine * vm,
|
||||
int vm_id,
|
||||
ostringstream * parsed,
|
||||
char ** error_msg,
|
||||
const char * str)
|
||||
|
Loading…
x
Reference in New Issue
Block a user