From bcd9281b638c7f1a5c813d9b64d66c1a6ca7432b Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Sat, 10 Dec 2011 21:08:03 +0100 Subject: [PATCH] bug: solve reference by name in CONTEXT attribute for name and virtual network --- src/vm/vm_var_syntax.cc | 42 +++++++++++++++++++---------------------- src/vm/vm_var_syntax.h | 2 +- src/vm/vm_var_syntax.y | 20 ++++++++------------ 3 files changed, 28 insertions(+), 36 deletions(-) diff --git a/src/vm/vm_var_syntax.cc b/src/vm/vm_var_syntax.cc index 6a75d06320..a8b665169b 100644 --- a/src/vm/vm_var_syntax.cc +++ b/src/vm/vm_var_syntax.cc @@ -146,7 +146,6 @@ void get_image_attribute(VirtualMachine * vm, ImagePool * ipool = nd.get_ipool(); Image * img; int iid = -1; - string iid_str; int num; vector attrs; @@ -154,7 +153,7 @@ void get_image_attribute(VirtualMachine * vm, attr_value.clear(); - if (img_name.empty() || img_name != "IMAGE_ID") + if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") ) { return; } @@ -174,11 +173,10 @@ void get_image_attribute(VirtualMachine * vm, continue; } - iid_str = disk->vector_value("IMAGE_ID"); - - if ( iid_str == img_value ) + if ( disk->vector_value(img_name.c_str()) == img_value ) { - istringstream iss(img_value); + string iid_str = disk->vector_value("IMAGE_ID"); + istringstream iss(iid_str); iss >> iid; @@ -232,7 +230,6 @@ void get_network_attribute(VirtualMachine * vm, VirtualNetworkPool * vnpool = nd.get_vnpool(); VirtualNetwork * vn; int vnet_id = -1; - string vnet_id_str; int num; vector attrs; @@ -240,7 +237,7 @@ void get_network_attribute(VirtualMachine * vm, attr_value.clear(); - if (net_name.empty() || net_name != "NETWORK_ID") + if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") ) { return; } @@ -260,11 +257,10 @@ void get_network_attribute(VirtualMachine * vm, continue; } - vnet_id_str = net->vector_value("NETWORK_ID"); - - if ( vnet_id_str == net_value ) + if ( net->vector_value(net_name.c_str()) == net_value ) { - istringstream iss(net_value); + string vnet_id_str = net->vector_value("NETWORK_ID"); + istringstream iss(vnet_id_str); iss >> vnet_id; @@ -460,7 +456,7 @@ void insert_vector(VirtualMachine * vm, /* Line 268 of yacc.c */ -#line 464 "vm_var_syntax.cc" +#line 460 "vm_var_syntax.cc" /* Enabling traces. */ #ifndef YYDEBUG @@ -506,7 +502,7 @@ typedef union YYSTYPE { /* Line 293 of yacc.c */ -#line 408 "vm_var_syntax.y" +#line 404 "vm_var_syntax.y" char * val_str; int val_int; @@ -515,7 +511,7 @@ typedef union YYSTYPE /* Line 293 of yacc.c */ -#line 519 "vm_var_syntax.cc" +#line 515 "vm_var_syntax.cc" } YYSTYPE; # define YYSTYPE_IS_TRIVIAL 1 # define yystype YYSTYPE /* obsolescent; will be withdrawn */ @@ -540,7 +536,7 @@ typedef struct YYLTYPE /* Line 343 of yacc.c */ -#line 544 "vm_var_syntax.cc" +#line 540 "vm_var_syntax.cc" #ifdef short # undef short @@ -830,7 +826,7 @@ static const yytype_int8 yyrhs[] = /* YYRLINE[YYN] -- source line where rule number YYN was defined. */ static const yytype_uint16 yyrline[] = { - 0, 432, 432, 433, 436, 440, 453, 468 + 0, 428, 428, 429, 432, 436, 449, 464 }; #endif @@ -1831,7 +1827,7 @@ yyreduce: case 4: /* Line 1806 of yacc.c */ -#line 437 "vm_var_syntax.y" +#line 433 "vm_var_syntax.y" { (*parsed) << (yyvsp[(1) - (1)].val_str); } @@ -1840,7 +1836,7 @@ yyreduce: case 5: /* Line 1806 of yacc.c */ -#line 441 "vm_var_syntax.y" +#line 437 "vm_var_syntax.y" { string name((yyvsp[(1) - (2)].val_str)); @@ -1858,7 +1854,7 @@ yyreduce: case 6: /* Line 1806 of yacc.c */ -#line 454 "vm_var_syntax.y" +#line 450 "vm_var_syntax.y" { string name((yyvsp[(1) - (5)].val_str)); string vname((yyvsp[(3) - (5)].val_str)); @@ -1878,7 +1874,7 @@ yyreduce: case 7: /* Line 1806 of yacc.c */ -#line 469 "vm_var_syntax.y" +#line 465 "vm_var_syntax.y" { string name((yyvsp[(1) - (9)].val_str)); string vname((yyvsp[(3) - (9)].val_str)); @@ -1901,7 +1897,7 @@ yyreduce: /* Line 1806 of yacc.c */ -#line 1905 "vm_var_syntax.cc" +#line 1901 "vm_var_syntax.cc" default: break; } /* User semantic actions sometimes alter yychar, and that requires @@ -2139,7 +2135,7 @@ yyreturn: /* Line 2067 of yacc.c */ -#line 487 "vm_var_syntax.y" +#line 483 "vm_var_syntax.y" extern "C" void vm_var__error( diff --git a/src/vm/vm_var_syntax.h b/src/vm/vm_var_syntax.h index d40f8d1d51..337bb45d68 100644 --- a/src/vm/vm_var_syntax.h +++ b/src/vm/vm_var_syntax.h @@ -56,7 +56,7 @@ typedef union YYSTYPE { /* Line 2068 of yacc.c */ -#line 408 "vm_var_syntax.y" +#line 404 "vm_var_syntax.y" char * val_str; int val_int; diff --git a/src/vm/vm_var_syntax.y b/src/vm/vm_var_syntax.y index bd75e41a02..027dade20e 100644 --- a/src/vm/vm_var_syntax.y +++ b/src/vm/vm_var_syntax.y @@ -85,7 +85,6 @@ void get_image_attribute(VirtualMachine * vm, ImagePool * ipool = nd.get_ipool(); Image * img; int iid = -1; - string iid_str; int num; vector attrs; @@ -93,7 +92,7 @@ void get_image_attribute(VirtualMachine * vm, attr_value.clear(); - if (img_name.empty() || img_name != "IMAGE_ID") + if ( img_name.empty() || (img_name!="IMAGE" && img_name!="IMAGE_ID") ) { return; } @@ -113,11 +112,10 @@ void get_image_attribute(VirtualMachine * vm, continue; } - iid_str = disk->vector_value("IMAGE_ID"); - - if ( iid_str == img_value ) + if ( disk->vector_value(img_name.c_str()) == img_value ) { - istringstream iss(img_value); + string iid_str = disk->vector_value("IMAGE_ID"); + istringstream iss(iid_str); iss >> iid; @@ -171,7 +169,6 @@ void get_network_attribute(VirtualMachine * vm, VirtualNetworkPool * vnpool = nd.get_vnpool(); VirtualNetwork * vn; int vnet_id = -1; - string vnet_id_str; int num; vector attrs; @@ -179,7 +176,7 @@ void get_network_attribute(VirtualMachine * vm, attr_value.clear(); - if (net_name.empty() || net_name != "NETWORK_ID") + if ( net_name.empty() || (net_name!="NETWORK" && net_name!="NETWORK_ID") ) { return; } @@ -199,11 +196,10 @@ void get_network_attribute(VirtualMachine * vm, continue; } - vnet_id_str = net->vector_value("NETWORK_ID"); - - if ( vnet_id_str == net_value ) + if ( net->vector_value(net_name.c_str()) == net_value ) { - istringstream iss(net_value); + string vnet_id_str = net->vector_value("NETWORK_ID"); + istringstream iss(vnet_id_str); iss >> vnet_id;