Merge branch 'feature-1617'

This commit is contained in:
Ruben S. Montero committed 2012-11-24 00:29:27 +01:00
commit 3684203767
35 files changed
+3774 -578

No files matched your search

+38 -6
View File
@@ -29,6 +29,38 @@
class Datastore : public PoolObjectSQL, ObjectCollection, public Clusterable
{
public:
/**
* Type of Datastore
*/
enum DatastoreType
{
IMAGE_DS = 0, /** < Standard datastore for disk images */
SYSTEM_DS = 1, /** < System datastore for disks of running VMs */
FILE_DS = 2 /** < File datastore for context, kernel, initrd files */
};
/**
* Return the string representation of an DatastoreType
* @param ob the type
* @return the string
*/
static string type_to_str(DatastoreType ob)
{
switch (ob)
{
case IMAGE_DS: return "IMAGE_DS" ; break;
case SYSTEM_DS: return "SYSTEM_DS" ; break;
case FILE_DS: return "FILE_DS" ; break;
default: return "";
}
};
/**
* Return the string representation of an DatastoreType
* @param str_type string representing the DatastoreTypr
* @return the ImageType (defaults to IMAGE_DS)
*/
static DatastoreType str_to_type(string& str_type);
/**
* Function to print the Datastore object into a string in XML format
@@ -93,12 +125,12 @@ public:
};
/**
* Returns true if this is a system datastore
* @return true if this is a system datastore
* Returns the datastore type
* @return datastore type
*/
bool is_system() const
DatastoreType get_type() const
{
return system_ds == 1;
return type;
};
/**
@@ -145,9 +177,9 @@ private:
string base_path;
/**
* 1 if this is a system DS
* The datastore type
*/
int system_ds;
DatastoreType type;
/**
* Disk types for the Images created in this datastore
+10
View File
@@ -54,6 +54,16 @@ public:
*/
static const int DEFAULT_DS_ID;
/**
* Name for the file datastore
*/
static const string FILE_DS_NAME;
/**
* Identifier for the file datastore
*/
static const int FILE_DS_ID;
/* ---------------------------------------------------------------------- */
/* Methods for DB management */
/* ---------------------------------------------------------------------- */
+3 -1
View File
@@ -37,7 +37,8 @@ public:
{
OS = 0, /** < Base OS image */
CDROM = 1, /** < An ISO9660 image */
DATABLOCK = 2 /** < User persistent data device */
DATABLOCK = 2, /** < User persistent data device */
DATAFILE = 3 /** < Context, kernels and initrd files */
};
/**
@@ -52,6 +53,7 @@ public:
case OS: return "OS" ; break;
case CDROM: return "CDROM" ; break;
case DATABLOCK: return "DATABLOCK" ; break;
case DATAFILE: return "FILE" ; break;
default: return "";
}
};
+30 -12
View File
@@ -20,6 +20,7 @@
#include "PoolSQL.h"
#include "Image.h"
#include "NebulaLog.h"
#include "Datastore.h"
#include <time.h>
#include <sstream>
@@ -58,6 +59,7 @@ public:
* @param ds_name the name of the datastore
* @param ds_type disk type for the image
* @param ds_data the datastore data
* @param ds_type the datastore type
* @param source_img_id If the new Image is a clone, this must be the
* source Image ID. Otherwise, it must be set to -1
* @param oid the id assigned to the Image
@@ -67,18 +69,19 @@ public:
* -2 in case of template parse failure
*/
int allocate (
int uid,
int gid,
const string& uname,
const string& gname,
ImageTemplate * img_template,
int ds_id,
const string& ds_name,
Image::DiskType ds_type,
const string& ds_data,
int source_img_id,
int * oid,
string& error_str);
int uid,
int gid,
const string& uname,
const string& gname,
ImageTemplate * img_template,
int ds_id,
const string& ds_name,
Image::DiskType disk_type,
const string& ds_data,
Datastore::DatastoreType ds_type,
int source_img_id,
int * oid,
string& error_str);
/**
** Function to get a Image from the pool, if the object is not in memory
@@ -177,6 +180,21 @@ public:
return _default_dev_prefix;
};
/**
* Get the effective uid to get an image. Used in VM parsers
* @param disk a vector attribute with the image data
* @param uid default uid
* @return the uid to get the image;
*/
static int get_disk_uid(VectorAttribute * disk, int _uid);
/**
* Get the disk id based on its string representation. Used in VM parsers
* @param id_s the string id
* @return the id in int form
*/
static int get_disk_id(const string& id_s);
private:
//--------------------------------------------------------------------------
// Configuration Attributes for Images
+79 -1
View File
@@ -220,6 +220,50 @@ public:
etime = et;
};
/**
* Sets the KERNEL OS attribute (path to the kernel file). Used when
* the template is using a FILE Datastore for it
* @param path to the kernel (in the remote host)
*/
void set_kernel(const string& kernel)
{
vector<Attribute *> os_attr;
VectorAttribute * os;
int num = obj_template->get("OS", os_attr);
if ( num == 0 )
{
return;
}
os = dynamic_cast<VectorAttribute *>(os_attr[0]);
os->replace("KERNEL", kernel);
};
/**
* Sets the INITRD OS attribute (path to the initrd file). Used when
* the template is using a FILE Datastore for it
* @param path to the initrd (in the remote host)
*/
void set_initrd(const string& initrd)
{
vector<Attribute *> os_attr;
VectorAttribute * os;
int num = obj_template->get("OS", os_attr);
if ( num == 0 )
{
return;
}
os = dynamic_cast<VectorAttribute *>(os_attr[0]);
os->replace("INITRD", initrd);
};
// ------------------------------------------------------------------------
// Access to VM locations
// ------------------------------------------------------------------------
@@ -620,9 +664,24 @@ public:
* template values:
* @param attribute, the string to be parsed
* @param parsed, the resulting parsed string
* @param error description in case of failure
* @return 0 on success.
*/
int parse_template_attribute(const string& attribute, string& parsed);
int parse_template_attribute(const string& attribute,
string& parsed,
string& error);
/**
* Parse a file string variable (i.e. $FILE) using the FILE_DS datastores.
* It should be used for OS/DS_KERNEL, OS/DS_INITRD, CONTEXT/DS_FILES.
* @param attribute the string to be parsed
* @param img_ids ids of the FILE images in the attribute
* @param error description in case of failure
* @return 0 on success.
*/
int parse_file_attribute(string attribute,
vector<int>& img_ids,
string& error);
/**
* Factory method for virtual machine templates
@@ -1073,6 +1132,25 @@ private:
*/
static pthread_mutex_t lex_mutex;
/**
* Generates image attributes (DS_ID, TM_MAD, SOURCE...) for KERNEL and
* INITRD files.
* @param os attribute of the VM template
* @param base_name of the attribute "KERNEL", or "INITRD"
* @param error_str Returns the error reason, if any
* @return 0 on success
*/
int set_os_file(VectorAttribute * os,
const string& base_name,
string& error_str);
/**
* Parse the "OS" attribute of the template by substituting
* $FILE variables
* @param error_str Returns the error reason, if any
* @return 0 on success
*/
int parse_os(string& error_str);
/**
* Parse the "CONTEXT" attribute of the template by substituting
* $VARIABLE, $VARIABLE[ATTR] and $VARIABLE[ATTR, ATTR = VALUE]
+11 -5
View File
@@ -1,23 +1,28 @@
---
:ID:
---
:ID:
:desc: ONE identifier for the Datastore
:size: 4
:NAME:
:NAME:
:desc: Name of the Datastore
:size: 25
:left: true
:CLUSTER:
:CLUSTER:
:desc: Name of the Cluster
:size: 15
:left: true
:IMAGES:
:IMAGES:
:desc: Number of Images
:size: 6
:TYPE:
:desc: Datastore type
:size: 4
:left: true
:DS:
:desc: Datastore driver
:size: 8
:left: true
@@ -33,5 +38,6 @@
- :CLUSTER
- :IMAGES
- :TYPE
- :DS
- :TM
+8 -2
View File
@@ -60,7 +60,12 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
end
end
column :TYPE, "Datastore driver", :left, :size=>8 do |d|
column :TYPE, "Datastore type", :left, :size=>4 do |d|
type = Datastore::DATASTORE_TYPES[d["TYPE"].to_i]
Datastore::SHORT_DATASTORE_TYPES[type]
end
column :DS, "Datastore driver", :left, :size=>8 do |d|
d["DS_MAD"]
end
@@ -68,7 +73,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
d["TM_MAD"]
end
default :ID, :NAME, :CLUSTER, :IMAGES, :TYPE, :TM
default :ID, :NAME, :CLUSTER, :IMAGES, :TYPE, :DS, :TM
end
table
@@ -101,6 +106,7 @@ class OneDatastoreHelper < OpenNebulaHelper::OneHelper
puts str % ["GROUP", datastore['GNAME']]
puts str % ["CLUSTER", OpenNebulaHelper.cluster_str(datastore['CLUSTER'])]
puts str % ["TYPE", datastore.type_str]
puts str % ["DS_MAD", datastore['DS_MAD']]
puts str % ["TM_MAD", datastore['TM_MAD']]
puts str % ["BASE PATH",datastore['BASE_PATH']]
+3 -3
View File
@@ -34,14 +34,14 @@ class OneImageHelper < OpenNebulaHelper::OneHelper
:name => "type",
:large => "--type type",
:format => String,
:description => "Type of the new Image: OS, CDROM or DATABLOCK",
:description => "Type of the new Image: #{Image::IMAGE_TYPES.join(", ")}",
:proc => lambda do |o, options|
type=o.strip.upcase
if %w{OS CDROM DATABLOCK}.include? type
if Image::IMAGE_TYPES.include? type
[0, type]
else
[-1, "Type should be OS, CDROM or DATABLOCK"]
[-1, "Type should be: #{Image::IMAGE_TYPES.join(", ")}"]
end
end
},
+1
View File
@@ -150,6 +150,7 @@ cmd=CommandParser::CmdParser.new(ARGV) do
puts "ID: #{res}"
else
puts res.message
exit -1
end
end
end
+62 -41
View File
@@ -50,7 +50,7 @@ Datastore::Datastore(
ds_mad(""),
tm_mad(""),
base_path(""),
system_ds(0)
type(IMAGE_DS)
{
group_u = 1;
@@ -92,6 +92,33 @@ int Datastore::disk_attribute(VectorAttribute * disk)
/* Datastore :: Database Access Functions */
/* ************************************************************************ */
Datastore::DatastoreType Datastore::str_to_type(string& str_type)
{
Datastore::DatastoreType dst = IMAGE_DS;
if (str_type.empty())
{
return dst;
}
TO_UPPER(str_type);
if ( str_type == "IMAGE_DS" )
{
dst = IMAGE_DS;
}
else if ( str_type == "SYSTEM_DS" )
{
dst = SYSTEM_DS;
}
else if ( str_type == "FILE_DS" )
{
dst = FILE_DS;
}
return dst;
}
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
@@ -100,25 +127,22 @@ int Datastore::insert(SqlDB *db, string& error_str)
int rc;
ostringstream oss;
string s_disk_type;
string s_system_ds;
string s_ds_type;
Nebula& nd = Nebula::instance();
// ---------------------------------------------------------------------
// -------------------------------------------------------------------------
// Check default datastore attributes
// ---------------------------------------------------------------------
// -------------------------------------------------------------------------
erase_template_attribute("NAME", name);
// NAME is checked in DatastorePool::allocate
erase_template_attribute("NAME", name);//DatastorePool::allocate checks NAME
get_template_attribute("DS_MAD", ds_mad);
get_template_attribute("SYSTEM", s_system_ds);
get_template_attribute("TYPE", s_ds_type);
TO_UPPER(s_system_ds);
type = str_to_type(s_ds_type);
system_ds = (s_system_ds == "YES");
if ( system_ds == 1 )
if ( type == SYSTEM_DS )
{
if ( !ds_mad.empty() )
{
@@ -143,19 +167,20 @@ int Datastore::insert(SqlDB *db, string& error_str)
base_path = oss.str();
get_template_attribute("DISK_TYPE", s_disk_type);
disk_type = Image::FILE;
if (s_disk_type == "BLOCK")
if ( type == IMAGE_DS )
{
disk_type = Image::BLOCK;
}
else if (s_disk_type == "CDROM")
{
disk_type = Image::CD_ROM;
}
else
{
disk_type = Image::FILE;
get_template_attribute("DISK_TYPE", s_disk_type);
if (s_disk_type == "BLOCK")
{
disk_type = Image::BLOCK;
}
else if (s_disk_type == "CDROM")
{
disk_type = Image::CD_ROM;
}
}
if ( tm_mad.empty() == true )
@@ -295,7 +320,7 @@ string& Datastore::to_xml(string& xml) const
"<DS_MAD>" << ds_mad << "</DS_MAD>" <<
"<TM_MAD>" << tm_mad << "</TM_MAD>" <<
"<BASE_PATH>" << base_path << "</BASE_PATH>" <<
"<SYSTEM>" << system_ds << "</SYSTEM>" <<
"<TYPE>" << type << "</TYPE>" <<
"<DISK_TYPE>" << disk_type << "</DISK_TYPE>" <<
"<CLUSTER_ID>" << cluster_id << "</CLUSTER_ID>" <<
"<CLUSTER>" << cluster << "</CLUSTER>" <<
@@ -315,6 +340,7 @@ int Datastore::from_xml(const string& xml)
{
int rc = 0;
int int_disk_type;
int int_ds_type;
vector<xmlNodePtr> content;
// Initialize the internal XML object
@@ -330,7 +356,7 @@ int Datastore::from_xml(const string& xml)
rc += xpath(ds_mad, "/DATASTORE/DS_MAD", "not_found");
rc += xpath(tm_mad, "/DATASTORE/TM_MAD", "not_found");
rc += xpath(base_path, "/DATASTORE/BASE_PATH", "not_found");
rc += xpath(system_ds, "/DATASTORE/SYSTEM", -1);
rc += xpath(int_ds_type, "/DATASTORE/TYPE", -1);
rc += xpath(int_disk_type,"/DATASTORE/DISK_TYPE", -1);
rc += xpath(cluster_id, "/DATASTORE/CLUSTER_ID", -1);
@@ -340,6 +366,7 @@ int Datastore::from_xml(const string& xml)
rc += perms_from_xml();
disk_type = static_cast<Image::DiskType>(int_disk_type);
type = static_cast<Datastore::DatastoreType>(int_ds_type);
// Get associated classes
ObjectXML::get_nodes("/DATASTORE/IMAGES", content);
@@ -382,7 +409,7 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str)
{
string new_ds_mad;
string new_tm_mad;
string s_system_ds;
string s_ds_type;
int rc;
@@ -394,29 +421,23 @@ int Datastore::replace_template(const string& tmpl_str, string& error_str)
}
get_template_attribute("DS_MAD", new_ds_mad);
get_template_attribute("SYSTEM", s_system_ds);
get_template_attribute("TYPE", s_ds_type);
if ( oid == DatastorePool::SYSTEM_DS_ID )
{
system_ds = 1;
}
else if ( !s_system_ds.empty() )
{
TO_UPPER(s_system_ds);
system_ds = (s_system_ds == "YES");
}
if ( system_ds == 1 )
{
replace_template_attribute("SYSTEM", "YES");
new_ds_mad = "-";
type = SYSTEM_DS;
}
else
{
obj_template->erase("SYSTEM");
type = str_to_type(s_ds_type);
replace_template_attribute("TYPE", type_to_str(type));
}
if ( type == SYSTEM_DS )
{
new_ds_mad = "-";
}
if ( !new_ds_mad.empty() )
+57 -8
View File
@@ -32,6 +32,9 @@ const int DatastorePool::SYSTEM_DS_ID = 0;
const string DatastorePool::DEFAULT_DS_NAME = "default";
const int DatastorePool::DEFAULT_DS_ID = 1;
const string DatastorePool::FILE_DS_NAME = "files";
const int DatastorePool::FILE_DS_ID = 2;
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@@ -49,12 +52,12 @@ DatastorePool::DatastorePool(SqlDB * db):
int rc;
// ---------------------------------------------------------------------
// Create the system datastore
// Create the system datastore
// ---------------------------------------------------------------------
oss << "NAME = " << SYSTEM_DS_NAME << endl
<< "SYSTEM = YES" << endl
<< "TM_MAD = shared";
oss << "NAME = " << SYSTEM_DS_NAME << endl
<< "TYPE = SYSTEM_DS" << endl
<< "TM_MAD = shared";
ds_tmpl = new DatastoreTemplate;
rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str);
@@ -80,13 +83,59 @@ DatastorePool::DatastorePool(SqlDB * db):
}
// ---------------------------------------------------------------------
// Create the default datastore
// Create the default datastore
// ---------------------------------------------------------------------
oss.str("");
oss << "NAME = " << DEFAULT_DS_NAME << endl
<< "DS_MAD = fs" << endl
<< "TM_MAD = shared";
oss << "NAME = " << DEFAULT_DS_NAME << endl
<< "TYPE = IMAGE_DS" << endl
<< "DS_MAD = fs" << endl
<< "TM_MAD = shared";
ds_tmpl = new DatastoreTemplate;
rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str);
if( rc < 0 )
{
goto error_bootstrap;
}
allocate(UserPool::ONEADMIN_ID,
GroupPool::ONEADMIN_ID,
UserPool::oneadmin_name,
GroupPool::ONEADMIN_NAME,
ds_tmpl,
&rc,
ClusterPool::NONE_CLUSTER_ID,
ClusterPool::NONE_CLUSTER_NAME,
error_str);
if( rc < 0 )
{
goto error_bootstrap;
}
ds = get(rc, true);
ds->set_permissions(
-1,-1,-1,
-1,-1,-1,
1,-1,-1,
error_str);
update(ds);
ds->unlock();
// ---------------------------------------------------------------------
// Create the default file datastore
// ---------------------------------------------------------------------
oss.str("");
oss << "NAME = " << FILE_DS_NAME << endl
<< "TYPE = FILE_DS" << endl
<< "DS_MAD = fs" << endl
<< "TM_MAD = ssh";
ds_tmpl = new DatastoreTemplate;
rc = ds_tmpl->parse_str_or_xml(oss.str(), error_str);
+30 -8
View File
@@ -132,19 +132,33 @@ int Image::insert(SqlDB *db, string& error_str)
erase_template_attribute("PERSISTENT", persistent_attr);
TO_UPPER(persistent_attr);
if ( type != DATAFILE )
{
TO_UPPER(persistent_attr);
persistent_img = (persistent_attr == "YES");
persistent_img = (persistent_attr == "YES");
}
else // Files are always non-persistent
{
persistent_img = false;
}
// ------------ PREFIX --------------------
get_template_attribute("DEV_PREFIX", dev_prefix);
if( dev_prefix.empty() )
if ( type != DATAFILE )
{
SingleAttribute * dev_att = new SingleAttribute("DEV_PREFIX",
ImagePool::default_dev_prefix());
obj_template->set(dev_att);
get_template_attribute("DEV_PREFIX", dev_prefix);
if( dev_prefix.empty() )
{
SingleAttribute * dev_att = new SingleAttribute("DEV_PREFIX",
ImagePool::default_dev_prefix());
obj_template->set(dev_att);
}
}
else // Do not set dev_prefix for files
{
erase_template_attribute("DEV_PREFIX", dev_prefix);
}
// ------------ SIZE --------------------
@@ -569,6 +583,10 @@ int Image::set_type(string& _type)
{
type = DATABLOCK;
}
else if ( _type == "FILE" )
{
type = DATAFILE;
}
else
{
rc = -1;
@@ -630,6 +648,10 @@ Image::ImageType Image::str_to_type(string& str_type)
{
it = DATABLOCK;
}
else if ( str_type == "FILE" )
{
it = DATAFILE;
}
return it;
}
+29
View File
@@ -88,6 +88,17 @@ int ImageManager::acquire_image(int vm_id, Image *img, string& error)
{
int rc = 0;
if ( img->get_type() == Image::DATAFILE )
{
ostringstream oss;
oss << "Image " << img->get_oid() << " (" << img->get_name() << ") "
<< "of type FILE cannot be used as DISK.";
error = oss.str();
return -1;
}
switch (img->get_state())
{
case Image::READY:
@@ -149,6 +160,14 @@ void ImageManager::release_image(int vm_id, int iid, bool failed)
return;
}
if ( img->get_type() == Image::DATAFILE )
{
NebulaLog::log("ImM", Log::ERROR, "Trying to release a FILE image");
img->unlock();
return;
}
switch (img->get_state())
{
case Image::USED_PERS:
@@ -238,6 +257,14 @@ void ImageManager::release_cloning_image(int iid, int clone_img_id)
return;
}
if ( img->get_type() == Image::DATAFILE )
{
NebulaLog::log("ImM", Log::ERROR, "Trying to release a cloning FILE image");
img->unlock();
return;
}
switch (img->get_state())
{
case Image::USED:
@@ -682,6 +709,7 @@ int ImageManager::stat_image(Template* img_tmpl,
{
case Image::OS:
case Image::CDROM:
case Image::DATAFILE:
img_tmpl->get("SOURCE", res);
if (!res.empty())
@@ -720,6 +748,7 @@ int ImageManager::stat_image(Template* img_tmpl,
{
img_data << "<IMAGE><PATH>" << res << "</PATH></IMAGE>";
}
break;
}
add_request(&sr);
+38 -15
View File
@@ -63,18 +63,19 @@ ImagePool::ImagePool(SqlDB * db,
/* -------------------------------------------------------------------------- */
int ImagePool::allocate (
int uid,
int gid,
const string& uname,
const string& gname,
ImageTemplate* img_template,
int ds_id,
const string& ds_name,
Image::DiskType disk_type,
const string& ds_data,
int cloning_id,
int * oid,
string& error_str)
int uid,
int gid,
const string& uname,
const string& gname,
ImageTemplate * img_template,
int ds_id,
const string& ds_name,
Image::DiskType disk_type,
const string& ds_data,
Datastore::DatastoreType ds_type,
int cloning_id,
int * oid,
string& error_str)
{
Nebula& nd = Nebula::instance();
ImageManager * imagem = nd.get_imagem();
@@ -82,6 +83,7 @@ int ImagePool::allocate (
Image * img;
Image * img_aux = 0;
string name;
string type;
ostringstream oss;
img = new Image(uid, gid, uname, gname, img_template);
@@ -101,6 +103,20 @@ int ImagePool::allocate (
goto error_name_length;
}
img->get_template_attribute("TYPE", type);
if ( ds_type == Datastore::FILE_DS &&
img->str_to_type(type) != Image::DATAFILE )
{
goto error_types_missmatch_file;
}
if ( ds_type == Datastore::IMAGE_DS &&
img->str_to_type(type) == Image::DATAFILE )
{
goto error_types_missmatch_image;
}
img_aux = get(name,uid,false);
if( img_aux != 0 )
@@ -120,7 +136,6 @@ int ImagePool::allocate (
goto error_clone_state;
}
img->set_cloning_id(cloning_id);
}
@@ -181,6 +196,14 @@ error_name_length:
oss << "NAME is too long; max length is 128 chars.";
goto error_common;
error_types_missmatch_file:
oss << "Only IMAGES of type FILE can be registered in a FILE_DS datastore";
goto error_common;
error_types_missmatch_image:
oss << "IMAGES of type FILE cannot be registered in a IMAGE_DS datastore";
goto error_common;
error_duplicated:
oss << "NAME is already taken by IMAGE "
<< img_aux->get_oid() << ".";
@@ -201,7 +224,7 @@ error_common:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
static int get_disk_uid(VectorAttribute * disk, int _uid)
int ImagePool::get_disk_uid(VectorAttribute * disk, int _uid)
{
istringstream is;
@@ -246,7 +269,7 @@ static int get_disk_uid(VectorAttribute * disk, int _uid)
/* -------------------------------------------------------------------------- */
static int get_disk_id(const string& id_s)
int ImagePool::get_disk_id(const string& id_s)
{
istringstream is;
int id;
@@ -36,6 +36,10 @@ public class Datastore extends PoolElement
private static final String CHOWN = METHOD_PREFIX + "chown";
private static final String CHMOD = METHOD_PREFIX + "chmod";
private static final String[] DATASTORE_TYPES = {"IMAGE", "SYSTEM", "FILE"};
private static final String[] SHORT_DATASTORE_TYPES = {"img", "sys", "fil"};
/**
* Creates a new Datastore representation.
* @param id The datastore id.
@@ -358,6 +362,38 @@ public class Datastore extends PoolElement
// =================================
// Helpers
// =================================
/**
* Returns the type of the Datastore.
*
* @return The type of the Datastore.
*/
public int type()
{
String state = xpath("TYPE");
return state != null ? Integer.parseInt( state ) : -1;
}
/**
* Returns the type of the Datastore as a String.
*
* @return The type of the Datastore as a String.
*/
public String typeStr()
{
int type = type();
return type != -1 ? DATASTORE_TYPES[type] : null;
}
/**
* Returns the type of the Datastore as a short String.
*
* @return The type of the Datastore as a short String.
*/
public String shortTypeStr()
{
int type = type();
return type != -1 ? SHORT_DATASTORE_TYPES[type] : null;
}
/**
* Returns whether or not the image is part of this datastore
@@ -47,10 +47,10 @@ public class Image extends PoolElement
{"init", "rdy", "used", "disa", "lock", "err", "clon", "dele", "used"};
private static final String[] IMAGE_TYPES =
{"OS", "CDROM", "DATABLOCK"};
{"OS", "CDROM", "DATABLOCK", "FILE"};
private static final String[] SHORT_IMAGE_TYPES =
{"OS", "CD", "DB"};
{"OS", "CD", "DB", "FL"};
/**
* Creates a new Image representation.
+22
View File
@@ -32,6 +32,14 @@ module OpenNebula
:chmod => "datastore.chmod"
}
DATASTORE_TYPES=%w{IMAGE SYSTEM FILE}
SHORT_DATASTORE_TYPES = {
"IMAGE" => "img",
"SYSTEM"=> "sys",
"FILE" => "fil"
}
# Creates a Datastore description with just its identifier
# this method should be used to create plain Datastore objects.
# +id+ the id of the user
@@ -57,6 +65,20 @@ module OpenNebula
#######################################################################
# XML-RPC Methods for the Datastore Object
#######################################################################
# Returns the datastore type
def type
self['TYPE'].to_i
end
# Returns the datastore type (string value)
def type_str
DATASTORE_TYPES[type]
end
# Returns the datastore type (string value)
def short_type_str
SHORT_DATASTORE_TYPES[type_str]
end
# Retrieves the information of the given Datastore.
def info()
+5 -4
View File
@@ -52,12 +52,13 @@ module OpenNebula
"USED_PERS" => "used"
}
IMAGE_TYPES=%w{OS CDROM DATABLOCK}
IMAGE_TYPES=%w{OS CDROM DATABLOCK FILE}
SHORT_IMAGE_TYPES={
"OS" => "OS",
"CDROM" => "CD",
"DATABLOCK" => "DB"
"OS" => "OS",
"CDROM" => "CD",
"DATABLOCK" => "DB",
"FILE" => "FL"
}
# Creates an Image description with just its identifier
+30 -25
View File
@@ -232,9 +232,9 @@ void RequestManagerAllocate::request_execute(xmlrpc_c::paramList const& params,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachineAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
int VirtualMachineAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
int& id,
string& error_str,
RequestAttributes& att)
{
@@ -289,6 +289,8 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
string ds_name;
string ds_data;
Datastore::DatastoreType ds_type;
int rc, id;
PoolObjectAuth ds_perms;
@@ -301,7 +303,7 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
DatastorePool * dspool = nd.get_dspool();
ImagePool * ipool = static_cast<ImagePool *>(pool);
ImageManager * imagem = nd.get_imagem();
ImageTemplate * tmpl = new ImageTemplate;
Template img_usage;
@@ -332,7 +334,9 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
return;
}
if ( ds->is_system() )
ds_type = ds->get_type();
if ( ds_type == Datastore::SYSTEM_DS )
{
ostringstream oss;
@@ -361,8 +365,8 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
if ( rc == -1 )
{
failure_response(INTERNAL,
request_error("Cannot determine Image SIZE", size_str),
failure_response(INTERNAL,
request_error("Cannot determine Image SIZE", size_str),
att);
delete tmpl;
return;
@@ -373,18 +377,18 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
if ( iss.fail() )
{
failure_response(INTERNAL,
request_error("Cannot parse SIZE", size_str),
failure_response(INTERNAL,
request_error("Cannot parse SIZE", size_str),
att);
delete tmpl;
return;
return;
}
tmpl->erase("SIZE");
tmpl->add("SIZE", size_str);
// ------------- Set authorization request for non-oneadmin's --------------
img_usage.add("DATASTORE", ds_id);
img_usage.add("SIZE", size_str);
@@ -435,19 +439,20 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
if ( quota_authorization(&img_usage, Quotas::DATASTORE, att) == false )
{
delete tmpl;
return;
return;
}
}
rc = ipool->allocate(att.uid,
att.gid,
att.uname,
att.gname,
tmpl,
ds_id,
rc = ipool->allocate(att.uid,
att.gid,
att.uname,
att.gname,
tmpl,
ds_id,
ds_name,
ds_disk_type,
ds_data,
ds_data,
ds_type,
-1,
&id,
error_str);
@@ -476,9 +481,9 @@ void ImageAllocate::request_execute(xmlrpc_c::paramList const& params,
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int TemplateAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList,
int TemplateAllocate::pool_allocate(xmlrpc_c::paramList const& _paramList,
Template * tmpl,
int& id,
int& id,
string& error_str,
RequestAttributes& att)
{
@@ -517,9 +522,9 @@ int HostAllocate::pool_allocate(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
int& id,
string& error_str,
RequestAttributes& att)
{
@@ -540,7 +545,7 @@ int UserAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
if (driver.empty())
{
driver = UserPool::CORE_AUTH;
driver = UserPool::CORE_AUTH;
}
return upool->allocate(&id,ugid,uname,ugname,passwd,driver,true,error_str);
@@ -566,9 +571,9 @@ void UserAllocate::log_xmlrpc_param(
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int GroupAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
int GroupAllocate::pool_allocate(xmlrpc_c::paramList const& paramList,
Template * tmpl,
int& id,
int& id,
string& error_str,
RequestAttributes& att)
{
+60 -16
View File
@@ -44,11 +44,11 @@ void ImageEnable::request_execute(xmlrpc_c::paramList const& paramList,
{
if (enable_flag == true)
{
err_msg = "Could not enable image";
err_msg = "Could not enable image.";
}
else
{
err_msg = "Could not disable image";
err_msg = "Could not disable image.";
}
failure_response(INTERNAL, request_error(err_msg,""), att);
@@ -87,6 +87,15 @@ void ImagePersistent::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ( image->get_type() == Image::DATAFILE )
{
failure_response(ACTION,
request_error("FILE images must be non-persistent",""), att);
image->unlock();
return;
}
rc = image->persistent(persistent_flag, err_msg);
if ( rc != 0 )
@@ -142,6 +151,17 @@ void ImageChangeType::request_execute(xmlrpc_c::paramList const& paramList,
return;
}
if ( image->get_type() == Image::DATAFILE )
{
failure_response(ACTION,
request_error("Only FILE images can be stored in a FILE_DS"
" datastore.",""),
att);
image->unlock();
return;
}
rc = image->set_type(type);
if ( rc != 0 )
@@ -182,7 +202,7 @@ void ImageClone::request_execute(
Image * img;
Datastore * ds;
Nebula& nd = Nebula::instance();
Nebula& nd = Nebula::instance();
DatastorePool * dspool = nd.get_dspool();
ImagePool * ipool = static_cast<ImagePool *>(pool);
@@ -200,8 +220,19 @@ void ImageClone::request_execute(
return;
}
if ( img->get_type() == Image::DATAFILE )
{
failure_response(ACTION,
allocate_error("Image of type FILE cannot be clonned"),
att);
img->unlock();
return;
}
tmpl = img->clone_template(name);
img->get_permissions(perms);
ds_id = img->get_ds_id();
@@ -224,6 +255,18 @@ void ImageClone::request_execute(
return;
}
if ( ds->get_type() == Datastore::FILE_DS )
{
failure_response(ACTION, "Clone not supported for FILE_DS Datastores",
att);
delete tmpl;
ds->unlock();
return;
}
ds->get_permissions(ds_perms);
disk_type = ds->get_disk_type();
@@ -233,7 +276,7 @@ void ImageClone::request_execute(
ds->unlock();
// ------------- Set authorization request ---------------------------------
img_usage.add("DATASTORE", ds_id);
img_usage.add("SIZE", size);
@@ -265,21 +308,22 @@ void ImageClone::request_execute(
if ( quota_authorization(&img_usage, Quotas::DATASTORE, att) == false )
{
delete tmpl;
return;
}
return;
}
}
rc = ipool->allocate(att.uid,
att.gid,
att.uname,
rc = ipool->allocate(att.uid,
att.gid,
att.uname,
att.gname,
tmpl,
ds_id,
ds_name,
tmpl,
ds_id,
ds_name,
disk_type,
ds_data,
clone_id,
&new_id,
ds_data,
Datastore::IMAGE_DS,
clone_id,
&new_id,
error_str);
if ( rc < 0 )
{
+10 -1
View File
@@ -172,7 +172,7 @@ int RequestManagerVirtualMachine::get_host_information(int hid,
return -1;
}
if ( ds->is_system() == false )
if ( ds->get_type() != Datastore::SYSTEM_DS )
{
ostringstream oss;
@@ -641,6 +641,14 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
return;
}
if ( type == Image::DATAFILE )
{
failure_response(INTERNAL,
request_error("Cannot save_as image of type FILE", ""),
att);
return;
}
// -------------------------------------------------------------------------
// Get the data of the DataStore for the new image
// -------------------------------------------------------------------------
@@ -725,6 +733,7 @@ void VirtualMachineSaveDisk::request_execute(xmlrpc_c::paramList const& paramLis
ds_name,
ds_disk_type,
ds_data,
Datastore::IMAGE_DS,
-1,
&iid,
error_str);
+158 -138
View File
@@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison implementation for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2012 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
@@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.5"
#define YYBISON_VERSION "2.6.5"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -58,8 +58,6 @@
/* Pull parsers. */
#define YYPULL 1
/* Using locations. */
#define YYLSP_NEEDED 1
/* Substitute the variable and function names. */
#define yyparse template__parse
@@ -72,8 +70,7 @@
#define yylloc template__lloc
/* Copy the first part of user declarations. */
/* Line 268 of yacc.c */
/* Line 360 of yacc.c */
#line 17 "template_syntax.y"
#include <iostream>
@@ -125,14 +122,16 @@ extern "C"
}
/* Line 360 of yacc.c */
#line 127 "template_syntax.cc"
/* Line 268 of yacc.c */
#line 131 "template_syntax.cc"
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
# ifndef YY_NULL
# if defined __cplusplus && 201103L <= __cplusplus
# define YY_NULL nullptr
# else
# define YY_NULL 0
# endif
# endif
/* Enabling verbose error messages. */
#ifdef YYERROR_VERBOSE
@@ -142,11 +141,17 @@ extern "C"
# define YYERROR_VERBOSE 0
#endif
/* Enabling the token table. */
#ifndef YYTOKEN_TABLE
# define YYTOKEN_TABLE 0
/* In a future release of Bison, this section will be replaced
by #include "template_syntax.hh". */
#ifndef YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
# define YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int template__debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -165,21 +170,18 @@ extern "C"
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 293 of yacc.c */
/* Line 376 of yacc.c */
#line 74 "template_syntax.y"
char * val_str;
void * val_attr;
/* Line 293 of yacc.c */
#line 183 "template_syntax.cc"
/* Line 376 of yacc.c */
#line 185 "template_syntax.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
@@ -200,11 +202,26 @@ typedef struct YYLTYPE
#endif
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int template__parse (void *YYPARSE_PARAM);
#else
int template__parse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int template__parse (mem_collector * mc, Template * tmpl, char ** error_msg);
#else
int template__parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED */
/* Copy the second part of user declarations. */
/* Line 343 of yacc.c */
#line 208 "template_syntax.cc"
/* Line 379 of yacc.c */
#line 225 "template_syntax.cc"
#ifdef short
# undef short
@@ -257,24 +274,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
@@ -310,6 +327,7 @@ YYID (yyi)
# if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
# include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
/* Use EXIT_SUCCESS as a witness for stdlib.h. */
# ifndef EXIT_SUCCESS
# define EXIT_SUCCESS 0
# endif
@@ -403,20 +421,20 @@ union yyalloc
#endif
#if defined YYCOPY_NEEDED && YYCOPY_NEEDED
/* Copy COUNT objects from FROM to TO. The source and destination do
/* Copy COUNT objects from SRC to DST. The source and destination do
not overlap. */
# ifndef YYCOPY
# if defined __GNUC__ && 1 < __GNUC__
# define YYCOPY(To, From, Count) \
__builtin_memcpy (To, From, (Count) * sizeof (*(From)))
# define YYCOPY(Dst, Src, Count) \
__builtin_memcpy (Dst, Src, (Count) * sizeof (*(Src)))
# else
# define YYCOPY(To, From, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(To)[yyi] = (From)[yyi]; \
} \
# define YYCOPY(Dst, Src, Count) \
do \
{ \
YYSIZE_T yyi; \
for (yyi = 0; yyi < (Count); yyi++) \
(Dst)[yyi] = (Src)[yyi]; \
} \
while (YYID (0))
# endif
# endif
@@ -501,14 +519,14 @@ static const yytype_uint8 yyrline[] =
};
#endif
#if YYDEBUG || YYERROR_VERBOSE || YYTOKEN_TABLE
#if YYDEBUG || YYERROR_VERBOSE || 0
/* YYTNAME[SYMBOL-NUM] -- String name of the symbol SYMBOL-NUM.
First, the terminals, then, starting at YYNTOKENS, nonterminals. */
static const char *const yytname[] =
{
"$end", "error", "$undefined", "EQUAL", "COMMA", "OBRACKET", "CBRACKET",
"EQUAL_EMPTY", "STRING", "VARIABLE", "$accept", "template_file",
"template", "attribute", "array_val", 0
"template", "attribute", "array_val", YY_NULL
};
#endif
@@ -575,10 +593,10 @@ static const yytype_uint8 yytable[] =
18, 16, 8, 17, 0, 0, 19
};
#define yypact_value_is_default(yystate) \
((yystate) == (-9))
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-9)))
#define yytable_value_is_error(yytable_value) \
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
@@ -622,23 +640,24 @@ static const yytype_uint8 yystos[] =
#define YYRECOVERING() (!!yyerrstatus)
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY && yylen == 1) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (1); \
goto yybackup; \
} \
else \
{ \
#define YYBACKUP(Token, Value) \
do \
if (yychar == YYEMPTY) \
{ \
yychar = (Token); \
yylval = (Value); \
YYPOPSTACK (yylen); \
yystate = *yyssp; \
goto yybackup; \
} \
else \
{ \
yyerror (&yylloc, mc, tmpl, error_msg, YY_("syntax error: cannot back up")); \
YYERROR; \
} \
while (YYID (0))
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
@@ -647,27 +666,28 @@ while (YYID (0))
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
#ifndef YYLLOC_DEFAULT
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (YYID (N)) \
{ \
(Current).first_line = YYRHSLOC (Rhs, 1).first_line; \
(Current).first_column = YYRHSLOC (Rhs, 1).first_column; \
(Current).last_line = YYRHSLOC (Rhs, N).last_line; \
(Current).last_column = YYRHSLOC (Rhs, N).last_column; \
} \
else \
{ \
(Current).first_line = (Current).last_line = \
YYRHSLOC (Rhs, 0).last_line; \
(Current).first_column = (Current).last_column = \
YYRHSLOC (Rhs, 0).last_column; \
} \
while (YYID (0))
#endif
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
@@ -675,10 +695,14 @@ while (YYID (0))
#ifndef YY_LOCATION_PRINT
# 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, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
do { \
fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \
if ((Loc).first_line < (Loc).last_line) \
fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \
else if ((Loc).first_column < (Loc).last_column - 1) \
fprintf (File, "-%d", (Loc).last_column - 1); \
} while (0)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -686,7 +710,6 @@ while (YYID (0))
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
@@ -740,6 +763,8 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, yylocationp, mc, tmpl, error_
char ** error_msg;
#endif
{
FILE *yyo = yyoutput;
YYUSE (yyo);
if (!yyvaluep)
return;
YYUSE (yylocationp);
@@ -1005,12 +1030,12 @@ static int
yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
yytype_int16 *yyssp, int yytoken)
{
YYSIZE_T yysize0 = yytnamerr (0, yytname[yytoken]);
YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
YYSIZE_T yysize = yysize0;
YYSIZE_T yysize1;
enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
/* Internationalized format string. */
const char *yyformat = 0;
const char *yyformat = YY_NULL;
/* Arguments of yyformat. */
char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
/* Number of reported tokens (one for the "unexpected", one per
@@ -1070,7 +1095,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
break;
}
yyarg[yycount++] = yytname[yyx];
yysize1 = yysize + yytnamerr (0, yytname[yyx]);
yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
if (! (yysize <= yysize1
&& yysize1 <= YYSTACK_ALLOC_MAXIMUM))
return 2;
@@ -1170,20 +1195,6 @@ yydestruct (yymsg, yytype, yyvaluep, yylocationp, mc, tmpl, error_msg)
}
/* Prevent warnings from -Wmissing-prototypes. */
#ifdef YYPARSE_PARAM
#if defined __STDC__ || defined __cplusplus
int yyparse (void *YYPARSE_PARAM);
#else
int yyparse ();
#endif
#else /* ! YYPARSE_PARAM */
#if defined __STDC__ || defined __cplusplus
int yyparse (mem_collector * mc, Template * tmpl, char ** error_msg);
#else
int yyparse ();
#endif
#endif /* ! YYPARSE_PARAM */
/*----------.
@@ -1217,11 +1228,39 @@ yyparse (mc, tmpl, error_msg)
/* The lookahead symbol. */
int yychar;
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YY_INITIAL_VALUE(Value) = Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far. */
int yynerrs;
@@ -1235,7 +1274,7 @@ YYLTYPE yylloc;
`yyvs': related to semantic values.
`yyls': related to locations.
Refer to the stacks thru separate pointers, to allow yyoverflow
Refer to the stacks through separate pointers, to allow yyoverflow
to reallocate them elsewhere. */
/* The state stack. */
@@ -1261,7 +1300,7 @@ YYLTYPE yylloc;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
@@ -1280,10 +1319,9 @@ YYLTYPE yylloc;
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yylsp = yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
@@ -1292,21 +1330,7 @@ YYLTYPE yylloc;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#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;
#endif
yylsp[0] = yylloc;
goto yysetstate;
/*------------------------------------------------------------.
@@ -1452,7 +1476,9 @@ yybackup:
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
goto yynewstate;
@@ -1490,8 +1516,7 @@ yyreduce:
switch (yyn)
{
case 6:
/* Line 1806 of yacc.c */
/* Line 1778 of yacc.c */
#line 103 "template_syntax.y"
{
Attribute * pattr;
@@ -1505,8 +1530,7 @@ yyreduce:
break;
case 7:
/* Line 1806 of yacc.c */
/* Line 1778 of yacc.c */
#line 113 "template_syntax.y"
{
Attribute * pattr;
@@ -1523,8 +1547,7 @@ yyreduce:
break;
case 8:
/* Line 1806 of yacc.c */
/* Line 1778 of yacc.c */
#line 126 "template_syntax.y"
{
Attribute * pattr;
@@ -1538,8 +1561,7 @@ yyreduce:
break;
case 9:
/* Line 1806 of yacc.c */
/* Line 1778 of yacc.c */
#line 138 "template_syntax.y"
{
map<string,string>* vattr;
@@ -1556,8 +1578,7 @@ yyreduce:
break;
case 10:
/* Line 1806 of yacc.c */
/* Line 1778 of yacc.c */
#line 151 "template_syntax.y"
{
string name((yyvsp[(3) - (5)].val_str));
@@ -1574,9 +1595,8 @@ yyreduce:
break;
/* Line 1806 of yacc.c */
#line 1580 "template_syntax.cc"
/* Line 1778 of yacc.c */
#line 1600 "template_syntax.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1741,7 +1761,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -1770,7 +1792,7 @@ yyabortlab:
yyresult = 1;
goto yyreturn;
#if !defined(yyoverflow) || YYERROR_VERBOSE
#if !defined yyoverflow || YYERROR_VERBOSE
/*-------------------------------------------------.
| yyexhaustedlab -- memory exhaustion comes here. |
`-------------------------------------------------*/
@@ -1812,8 +1834,7 @@ yyreturn:
}
/* Line 2067 of yacc.c */
/* Line 2041 of yacc.c */
#line 164 "template_syntax.y"
@@ -1853,4 +1874,3 @@ extern "C" void template__error(
llocp->last_column);
}
}
+15 -12
View File
@@ -1,8 +1,8 @@
/* A Bison parser, made by GNU Bison 2.5. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2011 Free Software Foundation, Inc.
Copyright (C) 1984, 1989-1990, 2000-2012 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
@@ -30,6 +30,15 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
# define YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int template__debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
@@ -48,29 +57,24 @@
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2068 of yacc.c */
/* Line 2042 of yacc.c */
#line 74 "template_syntax.y"
char * val_str;
void * val_attr;
/* Line 2068 of yacc.c */
#line 66 "template_syntax.hh"
/* Line 2042 of yacc.c */
#line 72 "template_syntax.hh"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
@@ -84,5 +88,4 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif
#endif /* !YY_TEMPLATE_TEMPLATE_SYNTAX_HH_INCLUDED */
+86
View File
@@ -348,6 +348,55 @@ error_attributes:
return -1;
}
/* -------------------------------------------------------------------------- */
static string prolog_os_transfer_commands(
VirtualMachine * vm,
const VectorAttribute * os_attr,
const string& base,
string& opennebula_hostname,
ostream& xfr)
{
string base_ds = base + "_DS";
string name_ds = os_attr->vector_value(base_ds.c_str());
if ( name_ds.empty() )
{
return "";
}
string base_source = base + "_DS_SOURCE";
string base_ds_id = base + "_DS_DSID";
string base_tm = base + "_DS_TM";
string source = os_attr->vector_value(base_source.c_str());
string ds_id = os_attr->vector_value(base_ds_id.c_str());
string tm_mad = os_attr->vector_value(base_tm.c_str());
if ( source.empty() || ds_id.empty() || tm_mad.empty() )
{
return "";
}
ostringstream base_dst;
string name = base;
transform(name.begin(), name.end(), name.begin(), (int(*)(int))tolower);
base_dst << vm->get_remote_system_dir() << "/" << name;
xfr << "CLONE " << tm_mad << " "
<< opennebula_hostname << ":" << source << " "
<< vm->get_hostname() << ":"
<< base_dst.str() << " "
<< vm->get_oid() << " "
<< ds_id
<< endl;
return base_dst.str();
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
@@ -435,9 +484,46 @@ void TransferManager::prolog_action(int vid)
}
}
// -------------------------------------------------------------------------
// Transfers for kernel and initrd files
// -------------------------------------------------------------------------
attrs.clear();
num = vm->get_template_attribute("OS",attrs);
if ( num > 0 )
{
const VectorAttribute * os_attr;
os_attr = dynamic_cast<const VectorAttribute *>(attrs[0]);
string kernel = prolog_os_transfer_commands(vm,
os_attr,
"KERNEL",
opennebula_hostname,
xfr);
if ( !kernel.empty() )
{
vm->set_kernel(kernel);
vmpool->update(vm);
}
string initrd = prolog_os_transfer_commands(vm,
os_attr,
"initrd",
opennebula_hostname,
xfr);
if ( !initrd.empty() )
{
vm->set_initrd(initrd);
vmpool->update(vm);
}
}
// -------------------------------------------------------------------------
// Generate context file
// -------------------------------------------------------------------------
context_result = vm->generate_context(files, disk_id);
if ( context_result == -1 )
+6
View File
@@ -33,12 +33,18 @@ if env['parsers']=='yes':
)
env.NoClean(parser)
parser=env.Bison(
source='vm_file_var_syntax.y'
)
env.NoClean(parser)
# Sources to generate the library
source_files=[
'History.cc',
'VirtualMachine.cc',
'vm_var_parser.c',
'vm_var_syntax.cc',
'vm_file_var_syntax.cc',
'VirtualMachinePool.cc',
'VirtualMachineHook.cc',
'VirtualMachineTemplate.cc'
+377 -82
View File
@@ -31,7 +31,7 @@
#include "Nebula.h"
#include "vm_file_var_syntax.h"
#include "vm_var_syntax.h"
/* ************************************************************************** */
@@ -269,6 +269,17 @@ int VirtualMachine::insert(SqlDB * db, string& error_str)
}
}
// ------------------------------------------------------------------------
// Check the OS attribute
// ------------------------------------------------------------------------
rc = parse_os(error_str);
if ( rc != 0 )
{
goto error_os;
}
// ------------------------------------------------------------------------
// Get network leases
// ------------------------------------------------------------------------
@@ -349,6 +360,9 @@ error_leases_rollback:
release_network_leases();
goto error_common;
error_os:
goto error_common;
error_cpu:
error_str = "CPU attribute must be a positive float or integer value.";
goto error_common;
@@ -374,15 +388,150 @@ error_common:
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachine::set_os_file(VectorAttribute * os,
const string& base_name,
string& error_str)
{
vector<int> img_ids;
Nebula& nd = Nebula::instance();
ImagePool * ipool = nd.get_ipool();
Image * img = 0;
DatastorePool * ds_pool = nd.get_dspool();
Datastore * ds;
int ds_id;
string attr;
string base_name_ds = base_name + "_DS";
string base_name_id = base_name + "_DS_ID";
string base_name_source = base_name + "_DS_SOURCE";
string base_name_ds_id = base_name + "_DS_DSID";
string base_name_tm = base_name + "_DS_TM";
string base_name_cluster= base_name + "_DS_CLUSTER_ID";
attr = os->vector_value(base_name_ds.c_str());
if ( attr.empty() )
{
return 0;
}
if ( parse_file_attribute(attr, img_ids, error_str) != 0 )
{
return -1;
}
if ( img_ids.size() != 1 )
{
error_str = "Only one FILE variable can be used in: " + attr;
return -1;
}
img = ipool->get(img_ids.back(), true);
if ( img == 0 )
{
error_str = "Image no longer exists in attribute: " + attr;
return -1;
}
ds_id = img->get_ds_id();
os->remove(base_name);
os->replace(base_name_id, img->get_oid());
os->replace(base_name_source, img->get_source());
os->replace(base_name_ds_id, img->get_ds_id());
img->unlock();
ds = ds_pool->get(ds_id, true);
if ( ds == 0 )
{
error_str = "Associated datastore for image does not exist";
return -1;
}
os->replace(base_name_tm, ds->get_tm_mad());
if ( ds->get_cluster_id() != ClusterPool::NONE_CLUSTER_ID )
{
os->replace(base_name_cluster, ds->get_cluster_id());
}
ds->unlock();
return 0;
}
/* -------------------------------------------------------------------------- */
int VirtualMachine::parse_os(string& error_str)
{
int num;
int rc;
vector<Attribute *> os_attr;
VectorAttribute * os;
num = obj_template->get("OS", os_attr);
if ( num == 0 )
{
return 0;
}
else if ( num > 1 )
{
error_str = "Only one OS attribute can be defined.";
return -1;
}
os = dynamic_cast<VectorAttribute *>(os_attr[0]);
if ( os == 0 )
{
error_str = "Internal error parsing OS attribute.";
return -1;
}
rc = set_os_file(os, "KERNEL", error_str);
if ( rc != 0 )
{
return -1;
}
rc = set_os_file(os, "INITRD", error_str);
if ( rc != 0 )
{
return -1;
}
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int VirtualMachine::parse_context(string& error_str)
{
int rc, num;
vector<Attribute *> array_context;
VectorAttribute * context;
VectorAttribute * context_parsed;
string * str;
string parsed;
string * str;
string parsed;
string files_ds;
string files_ds_parsed;
ostringstream oss_parsed;
vector<int> img_ids;
num = obj_template->remove("CONTEXT", array_context);
@@ -404,28 +553,33 @@ int VirtualMachine::parse_context(string& error_str)
goto error_cleanup;
}
//Backup datastore files to parse them later
files_ds = context->vector_value("FILES_DS");
context->remove("FILES_DS");
// -------------------------------------------------------------------------
// Parse CONTEXT variables & free vector attributes
// -------------------------------------------------------------------------
str = context->marshall(" @^_^@ ");
if (str == 0)
{
NebulaLog::log("ONE",Log::ERROR, "Cannot marshall CONTEXT");
error_str = "Cannot marshall CONTEXT";
goto error_cleanup;
}
rc = parse_template_attribute(*str,parsed);
rc = parse_template_attribute(*str, parsed, error_str);
if ( rc == 0 )
delete str;
if (rc != 0)
{
VectorAttribute * context_parsed;
context_parsed = new VectorAttribute("CONTEXT");
context_parsed->unmarshall(parsed," @^_^@ ");
obj_template->set(context_parsed);
goto error_cleanup;
}
/* --- Delete old context attributes --- */
for (int i = 0; i < num ; i++)
{
if (array_context[i] != 0)
@@ -434,6 +588,52 @@ int VirtualMachine::parse_context(string& error_str)
}
}
// -------------------------------------------------------------------------
// Parse FILE_DS variables
// -------------------------------------------------------------------------
if (!files_ds.empty())
{
if ( parse_file_attribute(files_ds, img_ids, error_str) != 0 )
{
return -1;
}
if ( img_ids.size() > 0 )
{
vector<int>::iterator it;
Nebula& nd = Nebula::instance();
ImagePool * ipool = nd.get_ipool();
Image * img = 0;
for ( it=img_ids.begin() ; it < img_ids.end(); it++ )
{
img = ipool->get(*it, true);
if ( img != 0 )
{
oss_parsed << img->get_source() << " ";
img->unlock();
}
}
}
}
files_ds_parsed = oss_parsed.str();
context_parsed = new VectorAttribute("CONTEXT");
context_parsed->unmarshall(parsed," @^_^@ ");
if ( !files_ds_parsed.empty() )
{
context_parsed->replace("FILES_DS", files_ds_parsed);
}
obj_template->set(context_parsed);
return rc;
error_cleanup:
@@ -525,7 +725,7 @@ int VirtualMachine::parse_requirements(string& error_str)
goto error_cleanup;
}
rc = parse_template_attribute(reqs->value(),parsed);
rc = parse_template_attribute(reqs->value(), parsed, error_str);
if ( rc == 0 )
{
@@ -562,6 +762,31 @@ error_cleanup:
/* ------------------------------------------------------------------------ */
/* ------------------------------------------------------------------------ */
static int check_and_set_cluster_id(const char * id_name,
VectorAttribute * vatt,
string& cluster_id)
{
string vatt_cluster_id;
vatt_cluster_id = vatt->vector_value(id_name);
if ( !vatt_cluster_id.empty() )
{
if ( cluster_id.empty() )
{
cluster_id = vatt_cluster_id;
}
else if ( cluster_id != vatt_cluster_id )
{
return -1;
}
}
return 0;
}
/* ------------------------------------------------------------------------ */
int VirtualMachine::automatic_requirements(string& error_str)
{
int num_vatts;
@@ -571,9 +796,11 @@ int VirtualMachine::automatic_requirements(string& error_str)
ostringstream oss;
string requirements;
string cluster_id = "";
string vatt_cluster_id;
// Get cluster id from all DISK vector attributes
int incomp_id;
int rc;
// Get cluster id from all DISK vector attributes (IMAGE Datastore)
num_vatts = obj_template->get("DISK",v_attributes);
@@ -586,16 +813,39 @@ int VirtualMachine::automatic_requirements(string& error_str)
continue;
}
vatt_cluster_id = vatt->vector_value("CLUSTER_ID");
rc = check_and_set_cluster_id("CLUSTER_ID", vatt, cluster_id);
if ( !vatt_cluster_id.empty() )
if ( rc != 0 )
{
if ( !cluster_id.empty() && cluster_id != vatt_cluster_id )
incomp_id = i;
goto error_disk;
}
}
// Get cluster id from the KERNEL and INITRD (FILE Datastores)
v_attributes.clear();
num_vatts = obj_template->get("OS",v_attributes);
if ( num_vatts > 0 )
{
vatt = dynamic_cast<VectorAttribute * >(v_attributes[0]);
if ( vatt != 0 )
{
rc = check_and_set_cluster_id("KERNEL_CLUSTER_ID", vatt, cluster_id);
if ( rc != 0 )
{
goto error;
goto error_kernel;
}
cluster_id = vatt_cluster_id;
rc = check_and_set_cluster_id("INITRD_CLUSTER_ID", vatt, cluster_id);
if ( rc != 0 )
{
goto error_initrd;
}
}
}
@@ -613,16 +863,12 @@ int VirtualMachine::automatic_requirements(string& error_str)
continue;
}
vatt_cluster_id = vatt->vector_value("CLUSTER_ID");
rc = check_and_set_cluster_id("CLUSTER_ID", vatt, cluster_id);
if ( !vatt_cluster_id.empty() )
if ( rc != 0 )
{
if ( !cluster_id.empty() && cluster_id != vatt_cluster_id )
{
goto error;
}
cluster_id = vatt_cluster_id;
incomp_id = i;
goto error_nic;
}
}
@@ -643,59 +889,27 @@ int VirtualMachine::automatic_requirements(string& error_str)
return 0;
error:
error_disk:
oss << "Incompatible clusters in DISKs. Datastore for DISK["
<< incomp_id <<"] should be in cluster " << cluster_id << ".";
goto error_common;
oss << "Incompatible cluster IDs.";
error_kernel:
oss << "Incompatible cluster in KERNEL datastore, it should be in cluster "
<< cluster_id << ".";
goto error_common;
// Get cluster id from all DISK vector attributes
error_initrd:
oss << "Incompatible cluster in INITRD datastore, it should be in cluster "
<< cluster_id << ".";
goto error_common;
v_attributes.clear();
num_vatts = obj_template->get("DISK",v_attributes);
for(int i=0; i<num_vatts; i++)
{
vatt = dynamic_cast<VectorAttribute * >(v_attributes[i]);
if ( vatt == 0 )
{
continue;
}
vatt_cluster_id = vatt->vector_value("CLUSTER_ID");
if ( !vatt_cluster_id.empty() )
{
oss << endl << "DISK [" << i << "]: IMAGE ["
<< vatt->vector_value("IMAGE_ID") << "] from DATASTORE ["
<< vatt->vector_value("DATASTORE_ID") << "] requires CLUSTER ["
<< vatt_cluster_id << "]";
}
}
// Get cluster id from all NIC vector attributes
v_attributes.clear();
num_vatts = obj_template->get("NIC",v_attributes);
for(int i=0; i<num_vatts; i++)
{
vatt = dynamic_cast<VectorAttribute * >(v_attributes[i]);
if ( vatt == 0 )
{
continue;
}
vatt_cluster_id = vatt->vector_value("CLUSTER_ID");
if ( !vatt_cluster_id.empty() )
{
oss << endl << "NIC [" << i << "]: NETWORK ["
<< vatt->vector_value("NETWORK_ID") << "] requires CLUSTER ["
<< vatt_cluster_id << "]";
}
}
error_nic:
oss << "Incompatible clusters in NICs. Network for NIC[" << incomp_id <<"]"
<< " should be in cluster " << cluster_id << ".";
goto error_common;
error_common:
error_str = oss.str();
return -1;
@@ -1575,6 +1789,7 @@ void VirtualMachine::release_network_leases()
int VirtualMachine::generate_context(string &files, int &disk_id)
{
ofstream file;
string files_ds;
vector<const Attribute*> attrs;
const VectorAttribute * context;
@@ -1613,6 +1828,14 @@ int VirtualMachine::generate_context(string &files, int &disk_id)
files = context->vector_value("FILES");
files_ds = context->vector_value("FILES_DS");
if (!files_ds.empty())
{
files += " ";
files += files_ds;
}
const map<string, string> values = context->value();
file << "# Context variables generated by OpenNebula\n";
@@ -1826,6 +2049,10 @@ extern "C"
ostringstream * parsed,
char ** errmsg);
int vm_file_var_parse (VirtualMachine * vm,
vector<int> * img_ids,
char ** errmsg);
int vm_var_lex_destroy();
YY_BUFFER_STATE vm_var__scan_string(const char * str);
@@ -1836,7 +2063,8 @@ extern "C"
/* -------------------------------------------------------------------------- */
int VirtualMachine::parse_template_attribute(const string& attribute,
string& parsed)
string& parsed,
string& error_str)
{
YY_BUFFER_STATE str_buffer = 0;
const char * str;
@@ -1854,7 +2082,7 @@ int VirtualMachine::parse_template_attribute(const string& attribute,
goto error_yy;
}
rc = vm_var_parse(this,&oss_parsed,&error_msg);
rc = vm_var_parse(this, &oss_parsed, &error_msg);
vm_var__delete_buffer(str_buffer);
@@ -1867,7 +2095,9 @@ int VirtualMachine::parse_template_attribute(const string& attribute,
ostringstream oss;
oss << "Error parsing: " << attribute << ". " << error_msg;
log("VM",Log::ERROR,oss);
log("VM", Log::ERROR, oss);
error_str = oss.str();
free(error_msg);
}
@@ -1882,6 +2112,71 @@ error_yy:
return -1;
}
/* -------------------------------------------------------------------------- */
int VirtualMachine::parse_file_attribute(string attribute,
vector<int>& img_ids,
string& error)
{
YY_BUFFER_STATE str_buffer = 0;
const char * str;
int rc;
ostringstream oss_parsed;
char * error_msg = 0;
size_t non_blank_pos;
//Removes leading blanks from attribute, these are not managed
//by the parser as it is common to the other VM varibales
non_blank_pos = attribute.find_first_not_of(" \t\n\v\f\r");
if ( non_blank_pos != string::npos )
{
attribute.erase(0, non_blank_pos);
}
pthread_mutex_lock(&lex_mutex);
str = attribute.c_str();
str_buffer = vm_var__scan_string(str);
if (str_buffer == 0)
{
goto error_yy;
}
rc = vm_file_var_parse(this, &img_ids, &error_msg);
vm_var__delete_buffer(str_buffer);
vm_var_lex_destroy();
pthread_mutex_unlock(&lex_mutex);
if ( rc != 0 )
{
ostringstream oss;
if ( error_msg != 0 )
{
oss << "Error parsing: " << attribute << ". " << error_msg;
free(error_msg);
}
else
{
oss << "Unknown error parsing: " << attribute << ".";
}
error = oss.str();
}
return rc;
error_yy:
log("VM",Log::ERROR,"Error setting scan buffer");
pthread_mutex_unlock(&lex_mutex);
return -1;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
File diff suppressed because it is too large. Load diff
+94
View File
@@ -0,0 +1,94 @@
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison interface for Yacc-like parsers in C
Copyright (C) 1984, 1989-1990, 2000-2012 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
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>. */
/* As a special exception, you may create a larger work that contains
part or all of the Bison parser skeleton and distribute that work
under terms of your choice, so long as that work isn't itself a
parser generator using the skeleton or a modified version thereof
as a parser skeleton. Alternatively, if you modify or redistribute
the parser skeleton itself, you may (at your option) remove this
special exception, which will cause the skeleton and the resulting
Bison output files to be licensed under the GNU General Public
License without this special exception.
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef YY_VM_FILE_VAR_VM_FILE_VAR_SYNTAX_HH_INCLUDED
# define YY_VM_FILE_VAR_VM_FILE_VAR_SYNTAX_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
#endif
#if YYDEBUG
extern int vm_file_var__debug;
#endif
/* Tokens. */
#ifndef YYTOKENTYPE
# define YYTOKENTYPE
/* Put the tokens into the symbol table, so that GDB and other debuggers
know about them. */
enum yytokentype {
EQUAL = 258,
COMMA = 259,
OBRACKET = 260,
CBRACKET = 261,
EOA = 262,
STRING = 263,
VARIABLE = 264,
RSTRING = 265,
INTEGER = 266
};
#endif
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2042 of yacc.c */
#line 178 "vm_file_var_syntax.y"
char * val_str;
int val_int;
char val_char;
/* Line 2042 of yacc.c */
#line 75 "vm_file_var_syntax.hh"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
# define yystype YYSTYPE /* obsolescent; will be withdrawn */
# define YYSTYPE_IS_DECLARED 1
#endif
#if ! defined YYLTYPE && ! defined YYLTYPE_IS_DECLARED
typedef struct YYLTYPE
{
int first_line;
int first_column;
int last_line;
int last_column;
} YYLTYPE;
# define yyltype YYLTYPE /* obsolescent; will be withdrawn */
# define YYLTYPE_IS_DECLARED 1
# define YYLTYPE_IS_TRIVIAL 1
#endif
#endif /* !YY_VM_FILE_VAR_VM_FILE_VAR_SYNTAX_HH_INCLUDED */
+273
View File
@@ -0,0 +1,273 @@
/* -------------------------------------------------------------------------- */
/* Copyright 2002-2012, OpenNebula Project Leads (OpenNebula.org) */
/* */
/* Licensed under the Apache License, Version 2.0 (the "License"); you may */
/* not use this file except in compliance with the License. You may obtain */
/* a copy of the License at */
/* */
/* http://www.apache.org/licenses/LICENSE-2.0 */
/* */
/* Unless required by applicable law or agreed to in writing, software */
/* distributed under the License is distributed on an "AS IS" BASIS, */
/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. */
/* See the License for the specific language governing permissions and */
/* limitations under the License. */
/* -------------------------------------------------------------------------- */
%{
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <ctype.h>
#include <string.h>
#include "vm_file_var_syntax.h"
#include "ImagePool.h"
#include "UserPool.h"
#include "VirtualMachine.h"
#include "Nebula.h"
#define vm_file_var__lex vm_var_lex
#define YYERROR_VERBOSE
#define VM_VAR_TO_UPPER(S) transform (S.begin(),S.end(),S.begin(), \
(int(*)(int))toupper)
extern "C"
{
#include "mem_collector.h"
void vm_file_var__error(
YYLTYPE * llocp,
mem_collector * mc,
VirtualMachine * vm,
vector<int> * img_ids,
char ** errmsg,
const char * str);
int vm_file_var__lex (YYSTYPE *lvalp, YYLTYPE *llocp, mem_collector * mc);
int vm_file_var__parse (mem_collector * mc,
VirtualMachine * vm,
vector<int> * img_ids,
char ** errmsg);
int vm_file_var_parse (VirtualMachine * vm,
vector<int> * img_ids,
char ** errmsg)
{
mem_collector mc;
int rc;
mem_collector_init(&mc);
rc = vm_file_var__parse(&mc, vm, img_ids, errmsg);
mem_collector_cleanup(&mc);
return rc;
}
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
int get_image_path(VirtualMachine * vm,
const string& var_name,
const string& var1,
const string& val1,
const string& var2,
const string& val2,
vector<int> * img_ids,
string& error_str)
{
Nebula& nd = Nebula::instance();
ImagePool * ipool = nd.get_ipool();
Image * img = 0;
int iid = -1;
PoolObjectAuth perm;
if (var_name != "FILE" )
{
error_str = "Must use FILE variable for attribute.";
return -1;
}
if ( var1 == "IMAGE" )
{
int uid = vm->get_uid();
if ( !var2.empty() )
{
VectorAttribute * vfile;
map<string,string> file_values;
file_values.insert(make_pair(var1, val1));
file_values.insert(make_pair(var2, val2));
vfile = new VectorAttribute("FILE", file_values);
uid = ImagePool::get_disk_uid(vfile, uid);
delete vfile;
}
img = ipool->get(val1, uid, true);
}
else if ( var1 == "IMAGE_ID" )
{
iid = ImagePool::get_disk_id(val1);
if ( iid != -1 )
{
img = ipool->get(iid, true);
}
}
if ( img == 0 )
{
error_str = "Cannot get image (check name/ID or try IMAGE_UNAME or IMAGE_UID).";
return -1;
}
iid = img->get_oid();
img->get_permissions(perm);
if ( img->get_type() != Image::DATAFILE )
{
error_str = "FILE variables must use images of type FILE.";
img->unlock();
return -1;
}
img->unlock();
AuthRequest ar(vm->get_uid(), vm->get_gid());
ar.add_auth(AuthRequest::USE, perm);
if (UserPool::authorize(ar) == -1)
{
error_str = "User not authorize to use image.";
return -1;
}
img_ids->push_back(iid);
return 0;
}
/* -------------------------------------------------------------------------- */
/* -------------------------------------------------------------------------- */
%}
%parse-param {mem_collector * mc}
%parse-param {VirtualMachine * vm}
%parse-param {vector<int> * img_ids}
%parse-param {char ** errmsg}
%lex-param {mem_collector * mc}
%union {
char * val_str;
int val_int;
char val_char;
};
%defines
%locations
%pure_parser
%name-prefix = "vm_file_var__"
%output = "vm_file_var_syntax.cc"
%token EQUAL COMMA OBRACKET CBRACKET
%token <val_char> EOA
%token <val_str> STRING
%token <val_str> VARIABLE
%token <val_str> RSTRING
%token <val_int> INTEGER
%type <void> vm_variable
%type <void> vm_string
%%
vm_string: vm_variable
| vm_string vm_variable
;
vm_variable:
VARIABLE OBRACKET VARIABLE EQUAL STRING CBRACKET EOA
{
string file($1);
string var1($3);
string val1($5);
string result;
VM_VAR_TO_UPPER(file);
VM_VAR_TO_UPPER(var1);
if (get_image_path(vm, file, var1, val1, "", "", img_ids, result) == -1)
{
img_ids->clear();
*errmsg = strdup(result.c_str());
YYABORT;
}
}
| VARIABLE OBRACKET VARIABLE EQUAL STRING COMMA VARIABLE EQUAL STRING CBRACKET EOA
{
string file($1);
string var1($3);
string val1($5);
string var2($7);
string val2($9);
string result;
VM_VAR_TO_UPPER(file);
VM_VAR_TO_UPPER(var1);
VM_VAR_TO_UPPER(var2);
if (get_image_path(vm, file, var1, val1, var2, val2, img_ids, result) == -1)
{
img_ids->clear();
*errmsg = strdup(result.c_str());
YYABORT;
}
}
;
%%
extern "C" void vm_file_var__error(
YYLTYPE * llocp,
mem_collector * mc,
VirtualMachine * vm,
vector<int> * img_ids,
char ** error_msg,
const char * str)
{
int length;
length = strlen(str)+ 64;
*error_msg = (char *) malloc(sizeof(char)*length);
if (*error_msg != 0)
{
snprintf(*error_msg,
length,
"%s at line %i, columns %i:%i",
str,
llocp->first_line,
llocp->first_column,
llocp->last_column);
}
}
+74 -53
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison implementation for Yacc-like parsers in C
@@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.6.2"
#define YYBISON_VERSION "2.6.5"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -70,7 +70,7 @@
#define yylloc vm_var__lloc
/* Copy the first part of user declarations. */
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 17 "vm_var_syntax.y"
#include <iostream>
@@ -463,7 +463,7 @@ void insert_vector(VirtualMachine * vm,
/* -------------------------------------------------------------------------- */
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 468 "vm_var_syntax.cc"
# ifndef YY_NULL
@@ -484,8 +484,8 @@ void insert_vector(VirtualMachine * vm,
/* In a future release of Bison, this section will be replaced
by #include "vm_var_syntax.hh". */
#ifndef VM_VAR_VM_VAR_SYNTAX_HH
# define VM_VAR_VM_VAR_SYNTAX_HH
#ifndef YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
# define YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -516,7 +516,7 @@ extern int vm_var__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 416 "vm_var_syntax.y"
char * val_str;
@@ -524,7 +524,7 @@ typedef union YYSTYPE
char val_char;
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 529 "vm_var_syntax.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -560,11 +560,11 @@ int vm_var__parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !VM_VAR_VM_VAR_SYNTAX_HH */
#endif /* !YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED */
/* Copy the second part of user declarations. */
/* Line 353 of yacc.c */
/* Line 379 of yacc.c */
#line 569 "vm_var_syntax.cc"
#ifdef short
@@ -618,24 +618,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
@@ -933,10 +933,10 @@ static const yytype_uint8 yytable[] =
2, 12, 13, 14, 15, 16, 8, 0, 17
};
#define yypact_value_is_default(yystate) \
((yystate) == (-5))
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-5)))
#define yytable_value_is_error(yytable_value) \
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
@@ -997,10 +997,11 @@ do \
} \
while (YYID (0))
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
@@ -1028,17 +1029,20 @@ while (YYID (0))
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# 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, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
do { \
fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \
if ((Loc).first_line < (Loc).last_line) \
fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \
else if ((Loc).first_column < (Loc).last_column - 1) \
fprintf (File, "-%d", (Loc).last_column - 1); \
} while (0)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -1046,7 +1050,6 @@ while (YYID (0))
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
@@ -1572,11 +1575,39 @@ yyparse (mc, vm, parsed, errmsg)
/* The lookahead symbol. */
int yychar;
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YY_INITIAL_VALUE(Value) = Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far. */
int yynerrs;
@@ -1616,7 +1647,7 @@ YYLTYPE yylloc;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
@@ -1635,10 +1666,9 @@ YYLTYPE yylloc;
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yylsp = yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
@@ -1647,20 +1677,7 @@ YYLTYPE yylloc;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#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;
#endif
yylsp[0] = yylloc;
goto yysetstate;
/*------------------------------------------------------------.
@@ -1806,7 +1823,9 @@ yybackup:
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
goto yynewstate;
@@ -1844,7 +1863,7 @@ yyreduce:
switch (yyn)
{
case 4:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 445 "vm_var_syntax.y"
{
(*parsed) << (yyvsp[(1) - (1)].val_str);
@@ -1852,7 +1871,7 @@ yyreduce:
break;
case 5:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 449 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (2)].val_str));
@@ -1869,7 +1888,7 @@ yyreduce:
break;
case 6:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 462 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (5)].val_str));
@@ -1888,7 +1907,7 @@ yyreduce:
break;
case 7:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 477 "vm_var_syntax.y"
{
string name((yyvsp[(1) - (9)].val_str));
@@ -1910,8 +1929,8 @@ yyreduce:
break;
/* Line 1787 of yacc.c */
#line 1915 "vm_var_syntax.cc"
/* Line 1778 of yacc.c */
#line 1934 "vm_var_syntax.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -2076,7 +2095,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -2147,7 +2168,7 @@ yyreturn:
}
/* Line 2048 of yacc.c */
/* Line 2041 of yacc.c */
#line 495 "vm_var_syntax.y"
+6 -6
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison interface for Yacc-like parsers in C
@@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef VM_VAR_VM_VAR_SYNTAX_HH
# define VM_VAR_VM_VAR_SYNTAX_HH
#ifndef YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
# define YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -62,7 +62,7 @@ extern int vm_var__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 416 "vm_var_syntax.y"
char * val_str;
@@ -70,7 +70,7 @@ typedef union YYSTYPE
char val_char;
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 75 "vm_var_syntax.hh"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -91,4 +91,4 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif
#endif /* !VM_VAR_VM_VAR_SYNTAX_HH */
#endif /* !YY_VM_VAR_VM_VAR_SYNTAX_HH_INCLUDED */
+81 -60
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison implementation for Yacc-like parsers in C
@@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.6.2"
#define YYBISON_VERSION "2.6.5"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -70,7 +70,7 @@
#define yylloc expr_arith__lloc
/* Copy the first part of user declarations. */
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 17 "expr_arith.y"
#include <iostream>
@@ -125,7 +125,7 @@ extern "C"
}
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 130 "expr_arith.cc"
# ifndef YY_NULL
@@ -146,8 +146,8 @@ extern "C"
/* In a future release of Bison, this section will be replaced
by #include "expr_arith.hh". */
#ifndef EXPR_ARITH_EXPR_ARITH_HH
# define EXPR_ARITH_EXPR_ARITH_HH
#ifndef YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED
# define YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -172,7 +172,7 @@ extern int expr_arith__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 78 "expr_arith.y"
char * val_str;
@@ -180,7 +180,7 @@ typedef union YYSTYPE
float val_float;
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 185 "expr_arith.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -216,11 +216,11 @@ int expr_arith__parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !EXPR_ARITH_EXPR_ARITH_HH */
#endif /* !YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED */
/* Copy the second part of user declarations. */
/* Line 353 of yacc.c */
/* Line 379 of yacc.c */
#line 225 "expr_arith.cc"
#ifdef short
@@ -274,24 +274,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
@@ -594,10 +594,10 @@ static const yytype_uint8 yytable[] =
4, 5, 11, 12, 13, 14
};
#define yypact_value_is_default(yystate) \
((yystate) == (-5))
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-5)))
#define yytable_value_is_error(yytable_value) \
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
@@ -659,10 +659,11 @@ do \
} \
while (YYID (0))
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
@@ -690,17 +691,20 @@ while (YYID (0))
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# 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, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
do { \
fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \
if ((Loc).first_line < (Loc).last_line) \
fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \
else if ((Loc).first_column < (Loc).last_column - 1) \
fprintf (File, "-%d", (Loc).last_column - 1); \
} while (0)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -708,7 +712,6 @@ while (YYID (0))
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
@@ -1234,11 +1237,39 @@ yyparse (mc, oxml, result, error_msg)
/* The lookahead symbol. */
int yychar;
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YY_INITIAL_VALUE(Value) = Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far. */
int yynerrs;
@@ -1278,7 +1309,7 @@ YYLTYPE yylloc;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
@@ -1297,10 +1328,9 @@ YYLTYPE yylloc;
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yylsp = yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
@@ -1309,20 +1339,7 @@ YYLTYPE yylloc;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#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;
#endif
yylsp[0] = yylloc;
goto yysetstate;
/*------------------------------------------------------------.
@@ -1468,7 +1485,9 @@ yybackup:
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
goto yynewstate;
@@ -1506,19 +1525,19 @@ yyreduce:
switch (yyn)
{
case 2:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 100 "expr_arith.y"
{ result = static_cast<int>((yyvsp[(1) - (1)].val_float));}
break;
case 3:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 101 "expr_arith.y"
{ result = 0; }
break;
case 4:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 104 "expr_arith.y"
{ float val = 0.0;
@@ -1548,56 +1567,56 @@ yyreduce:
break;
case 5:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 129 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(1) - (1)].val_float); }
break;
case 6:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 130 "expr_arith.y"
{ (yyval.val_float) = static_cast<float>((yyvsp[(1) - (1)].val_int)); }
break;
case 7:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 131 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) + (yyvsp[(3) - (3)].val_float);}
break;
case 8:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 132 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) - (yyvsp[(3) - (3)].val_float);}
break;
case 9:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 133 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) * (yyvsp[(3) - (3)].val_float);}
break;
case 10:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 134 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(1) - (3)].val_float) / (yyvsp[(3) - (3)].val_float);}
break;
case 11:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 135 "expr_arith.y"
{ (yyval.val_float) = - (yyvsp[(2) - (2)].val_float);}
break;
case 12:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 136 "expr_arith.y"
{ (yyval.val_float) = (yyvsp[(2) - (3)].val_float);}
break;
/* Line 1787 of yacc.c */
#line 1601 "expr_arith.cc"
/* Line 1778 of yacc.c */
#line 1620 "expr_arith.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1762,7 +1781,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -1833,7 +1854,7 @@ yyreturn:
}
/* Line 2048 of yacc.c */
/* Line 2041 of yacc.c */
#line 139 "expr_arith.y"
+6 -6
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison interface for Yacc-like parsers in C
@@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef EXPR_ARITH_EXPR_ARITH_HH
# define EXPR_ARITH_EXPR_ARITH_HH
#ifndef YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED
# define YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -56,7 +56,7 @@ extern int expr_arith__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 78 "expr_arith.y"
char * val_str;
@@ -64,7 +64,7 @@ typedef union YYSTYPE
float val_float;
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 69 "expr_arith.hh"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -85,4 +85,4 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif
#endif /* !EXPR_ARITH_EXPR_ARITH_HH */
#endif /* !YY_EXPR_ARITH_EXPR_ARITH_HH_INCLUDED */
+86 -65
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison implementation for Yacc-like parsers in C
@@ -44,7 +44,7 @@
#define YYBISON 1
/* Bison version. */
#define YYBISON_VERSION "2.6.2"
#define YYBISON_VERSION "2.6.5"
/* Skeleton name. */
#define YYSKELETON_NAME "yacc.c"
@@ -70,7 +70,7 @@
#define yylloc expr_bool__lloc
/* Copy the first part of user declarations. */
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 17 "expr_bool.y"
#include <iostream>
@@ -130,7 +130,7 @@ void get_xml_attribute(ObjectXML * oxml, const char* attr, float& val);
void get_xml_attribute(ObjectXML * oxml, const char* attr, string& val);
/* Line 336 of yacc.c */
/* Line 360 of yacc.c */
#line 135 "expr_bool.cc"
# ifndef YY_NULL
@@ -151,8 +151,8 @@ void get_xml_attribute(ObjectXML * oxml, const char* attr, string& val);
/* In a future release of Bison, this section will be replaced
by #include "expr_bool.hh". */
#ifndef EXPR_BOOL_EXPR_BOOL_HH
# define EXPR_BOOL_EXPR_BOOL_HH
#ifndef YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED
# define YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -177,7 +177,7 @@ extern int expr_bool__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 83 "expr_bool.y"
char * val_str;
@@ -185,7 +185,7 @@ typedef union YYSTYPE
float val_float;
/* Line 350 of yacc.c */
/* Line 376 of yacc.c */
#line 190 "expr_bool.cc"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -221,11 +221,11 @@ int expr_bool__parse ();
#endif
#endif /* ! YYPARSE_PARAM */
#endif /* !EXPR_BOOL_EXPR_BOOL_HH */
#endif /* !YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED */
/* Copy the second part of user declarations. */
/* Line 353 of yacc.c */
/* Line 379 of yacc.c */
#line 230 "expr_bool.cc"
#ifdef short
@@ -279,24 +279,24 @@ typedef short int yytype_int16;
# if defined YYENABLE_NLS && YYENABLE_NLS
# if ENABLE_NLS
# include <libintl.h> /* INFRINGES ON USER NAME SPACE */
# define YY_(msgid) dgettext ("bison-runtime", msgid)
# define YY_(Msgid) dgettext ("bison-runtime", Msgid)
# endif
# endif
# ifndef YY_
# define YY_(msgid) msgid
# define YY_(Msgid) Msgid
# endif
#endif
/* Suppress unused-variable warnings by "using" E. */
#if ! defined lint || defined __GNUC__
# define YYUSE(e) ((void) (e))
# define YYUSE(E) ((void) (E))
#else
# define YYUSE(e) /* empty */
# define YYUSE(E) /* empty */
#endif
/* Identity function, used to suppress warnings about constant conditions. */
#ifndef lint
# define YYID(n) (n)
# define YYID(N) (N)
#else
#if (defined __STDC__ || defined __C99__FUNC__ \
|| defined __cplusplus || defined _MSC_VER)
@@ -604,10 +604,10 @@ static const yytype_uint8 yytable[] =
16, 17, 18, 26, 27, 28, 19, 21, 20, 22
};
#define yypact_value_is_default(yystate) \
((yystate) == (-6))
#define yypact_value_is_default(Yystate) \
(!!((Yystate) == (-6)))
#define yytable_value_is_error(yytable_value) \
#define yytable_value_is_error(Yytable_value) \
YYID (0)
static const yytype_int8 yycheck[] =
@@ -670,10 +670,11 @@ do \
} \
while (YYID (0))
/* Error token number */
#define YYTERROR 1
#define YYERRCODE 256
/* YYLLOC_DEFAULT -- Set CURRENT to span from RHS[1] to RHS[N].
If N is 0, then set CURRENT to the empty location which ends
the previous symbol: RHS[0] (always defined). */
@@ -701,17 +702,20 @@ while (YYID (0))
#define YYRHSLOC(Rhs, K) ((Rhs)[K])
/* YY_LOCATION_PRINT -- Print the location on the stream.
This macro was not mandated originally: define only if we know
we won't break user code: when these are the locations we know. */
#ifndef YY_LOCATION_PRINT
# 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, \
(Loc).last_line, (Loc).last_column)
# define YY_LOCATION_PRINT(File, Loc) \
do { \
fprintf (File, "%d.%d", (Loc).first_line, (Loc).first_column); \
if ((Loc).first_line < (Loc).last_line) \
fprintf (File, "-%d.%d", (Loc).last_line, (Loc).last_column - 1); \
else if ((Loc).first_column < (Loc).last_column - 1) \
fprintf (File, "-%d", (Loc).last_column - 1); \
} while (0)
# else
# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
# endif
@@ -719,7 +723,6 @@ while (YYID (0))
/* YYLEX -- calling `yylex' with the right arguments. */
#ifdef YYLEX_PARAM
# define YYLEX yylex (&yylval, &yylloc, YYLEX_PARAM)
#else
@@ -1245,11 +1248,39 @@ yyparse (mc, oxml, result, error_msg)
/* The lookahead symbol. */
int yychar;
#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
/* Suppress an incorrect diagnostic about yylval being uninitialized. */
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
_Pragma ("GCC diagnostic push") \
_Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
_Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
_Pragma ("GCC diagnostic pop")
#else
/* Default value used for initialization, for pacifying older GCCs
or non-GCC compilers. */
static YYSTYPE yyval_default;
# define YY_INITIAL_VALUE(Value) = Value
#endif
#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
# define YY_IGNORE_MAYBE_UNINITIALIZED_END
#endif
#ifndef YY_INITIAL_VALUE
# define YY_INITIAL_VALUE(Value) /* Nothing. */
#endif
/* The semantic value of the lookahead symbol. */
YYSTYPE yylval;
YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
/* Location data for the lookahead symbol. */
YYLTYPE yylloc;
YYLTYPE yylloc
# if defined YYLTYPE_IS_TRIVIAL && YYLTYPE_IS_TRIVIAL
= { 1, 1, 1, 1 }
# endif
;
/* Number of syntax errors so far. */
int yynerrs;
@@ -1289,7 +1320,7 @@ YYLTYPE yylloc;
int yyn;
int yyresult;
/* Lookahead token as an internal (translated) token number. */
int yytoken;
int yytoken = 0;
/* The variables used to return semantic value and location from the
action routines. */
YYSTYPE yyval;
@@ -1308,10 +1339,9 @@ YYLTYPE yylloc;
Keep to zero when no symbol should be popped. */
int yylen = 0;
yytoken = 0;
yyss = yyssa;
yyvs = yyvsa;
yyls = yylsa;
yyssp = yyss = yyssa;
yyvsp = yyvs = yyvsa;
yylsp = yyls = yylsa;
yystacksize = YYINITDEPTH;
YYDPRINTF ((stderr, "Starting parse\n"));
@@ -1320,20 +1350,7 @@ YYLTYPE yylloc;
yyerrstatus = 0;
yynerrs = 0;
yychar = YYEMPTY; /* Cause a token to be read. */
/* Initialize stack pointers.
Waste one element of value and location stack
so that they stay on the same level as the state stack.
The wasted elements are never initialized. */
yyssp = yyss;
yyvsp = yyvs;
yylsp = yyls;
#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;
#endif
yylsp[0] = yylloc;
goto yysetstate;
/*------------------------------------------------------------.
@@ -1479,7 +1496,9 @@ yybackup:
yychar = YYEMPTY;
yystate = yyn;
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
*++yylsp = yylloc;
goto yynewstate;
@@ -1517,19 +1536,19 @@ yyreduce:
switch (yyn)
{
case 2:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 103 "expr_bool.y"
{ result=(yyvsp[(1) - (1)].val_int); }
break;
case 3:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 104 "expr_bool.y"
{ result=true; }
break;
case 4:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 107 "expr_bool.y"
{ int val;
@@ -1538,7 +1557,7 @@ yyreduce:
break;
case 5:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 112 "expr_bool.y"
{ int val;
@@ -1547,7 +1566,7 @@ yyreduce:
break;
case 6:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 117 "expr_bool.y"
{ int val;
@@ -1556,7 +1575,7 @@ yyreduce:
break;
case 7:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 122 "expr_bool.y"
{ int val;
@@ -1565,7 +1584,7 @@ yyreduce:
break;
case 8:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 127 "expr_bool.y"
{ float val;
@@ -1574,7 +1593,7 @@ yyreduce:
break;
case 9:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 132 "expr_bool.y"
{ float val;
@@ -1583,7 +1602,7 @@ yyreduce:
break;
case 10:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 137 "expr_bool.y"
{ float val;
@@ -1592,7 +1611,7 @@ yyreduce:
break;
case 11:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 142 "expr_bool.y"
{ float val;
@@ -1601,7 +1620,7 @@ yyreduce:
break;
case 12:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 147 "expr_bool.y"
{ string val;
@@ -1610,7 +1629,7 @@ yyreduce:
break;
case 13:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 152 "expr_bool.y"
{ string val;
@@ -1619,32 +1638,32 @@ yyreduce:
break;
case 14:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 157 "expr_bool.y"
{ (yyval.val_int) = (yyvsp[(1) - (3)].val_int) && (yyvsp[(3) - (3)].val_int); }
break;
case 15:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 158 "expr_bool.y"
{ (yyval.val_int) = (yyvsp[(1) - (3)].val_int) || (yyvsp[(3) - (3)].val_int); }
break;
case 16:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 159 "expr_bool.y"
{ (yyval.val_int) = ! (yyvsp[(2) - (2)].val_int); }
break;
case 17:
/* Line 1787 of yacc.c */
/* Line 1778 of yacc.c */
#line 160 "expr_bool.y"
{ (yyval.val_int) = (yyvsp[(2) - (3)].val_int); }
break;
/* Line 1787 of yacc.c */
#line 1648 "expr_bool.cc"
/* Line 1778 of yacc.c */
#line 1667 "expr_bool.cc"
default: break;
}
/* User semantic actions sometimes alter yychar, and that requires
@@ -1809,7 +1828,9 @@ yyerrlab1:
YY_STACK_PRINT (yyss, yyssp);
}
YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
*++yyvsp = yylval;
YY_IGNORE_MAYBE_UNINITIALIZED_END
yyerror_range[2] = yylloc;
/* Using YYLLOC is tempting, but would change the location of
@@ -1880,7 +1901,7 @@ yyreturn:
}
/* Line 2048 of yacc.c */
/* Line 2041 of yacc.c */
#line 163 "expr_bool.y"
+6 -6
View File
@@ -1,4 +1,4 @@
/* A Bison parser, made by GNU Bison 2.6.2. */
/* A Bison parser, made by GNU Bison 2.6.5. */
/* Bison interface for Yacc-like parsers in C
@@ -30,8 +30,8 @@
This special exception was added by the Free Software Foundation in
version 2.2 of Bison. */
#ifndef EXPR_BOOL_EXPR_BOOL_HH
# define EXPR_BOOL_EXPR_BOOL_HH
#ifndef YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED
# define YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED
/* Enabling traces. */
#ifndef YYDEBUG
# define YYDEBUG 0
@@ -56,7 +56,7 @@ extern int expr_bool__debug;
#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
typedef union YYSTYPE
{
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 83 "expr_bool.y"
char * val_str;
@@ -64,7 +64,7 @@ typedef union YYSTYPE
float val_float;
/* Line 2049 of yacc.c */
/* Line 2042 of yacc.c */
#line 69 "expr_bool.hh"
} YYSTYPE;
# define YYSTYPE_IS_TRIVIAL 1
@@ -85,4 +85,4 @@ typedef struct YYLTYPE
# define YYLTYPE_IS_TRIVIAL 1
#endif
#endif /* !EXPR_BOOL_EXPR_BOOL_HH */
#endif /* !YY_EXPR_BOOL_EXPR_BOOL_HH_INCLUDED */