Skip to content

Commit

Permalink
fixed the command template instance from the ccs
Browse files Browse the repository at this point in the history
  • Loading branch information
Claudio authored and Claudio committed Aug 4, 2015
1 parent 0d850d6 commit b17431c
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
17 changes: 15 additions & 2 deletions ChaosMetadataService/api/node/CommandCommonUtility.cpp
Expand Up @@ -19,7 +19,7 @@
*/

#include "CommandCommonUtility.h"

#include <chaos/common/chaos_types.h>
#include <chaos/common/global.h>
#include <chaos/common/chaos_constants.h>

Expand Down Expand Up @@ -128,6 +128,7 @@ std::auto_ptr<chaos::common::data::CDataWrapper> CommandCommonUtility::createCom
CDataWrapper *command_description,
CDataWrapper *command_template_description) throw(chaos::CException) {
bool is_correct_type = false;
ChaosStringVector all_template_key;
std::auto_ptr<chaos::common::data::CDataWrapper> result(new CDataWrapper());
result->addStringValue(NodeDefinitionKey::NODE_UNIQUE_ID, node_uid);

Expand All @@ -143,7 +144,19 @@ std::auto_ptr<chaos::common::data::CDataWrapper> CommandCommonUtility::createCom

//we have all parameter valid now compose the request
command_description->copyKeyTo(BatchCommandAndParameterDescriptionkey::BC_ALIAS, *result);
command_template_description->copyAllTo(*result);
command_template_description->getAllKey(all_template_key);
//we need to copy all template key except the key that are null because are the key that has been requested to the user and so
//have been forwarded with the template name
for(ChaosStringVectorIterator it = all_template_key.begin();
it != all_template_key.end();
it++) {
if(command_template_description->isNullValue(*it)) {
N_CCU_DBG << "Removed from template null value key:" << *it;
continue;
}
//we can add the key value
command_template_description->copyKeyTo(*it, *result);
}

//try to find requested paramter whitin the command submission
for(std::vector<AttributeRequested>::iterator it = attribute_paramterized.begin();
Expand Down
1 change: 1 addition & 0 deletions ChaosMetadataService/api/node/CommandTemplateSubmit.cpp
Expand Up @@ -70,6 +70,7 @@ CDataWrapper *CommandTemplateSubmit::execute(CDataWrapper *api_data,
it != command_instance_list.end();
it++) {
std::auto_ptr<CDataWrapper> instance_pack(new CDataWrapper());
N_CTS_INFO << "Send datapack "<< it->getJSONString();
instance_pack->addCSDataValue("submission_task", *it);
getBatchExecutor()->submitCommand(GET_MDS_COMMAND_ALIAS(batch::node::SubmitBatchCommand),
instance_pack.release(),
Expand Down
1 change: 1 addition & 0 deletions chaos/common/chaos_types.h
Expand Up @@ -51,6 +51,7 @@ typedef boost::ptr_map< t1, t2 >::const_iterator name ## ConstIterator;
#define CHAOS_DEFINE_GET_PTR_MAP_ELEMENT(map, element_type, element_key)\
dynamic_cast<element_type*>(&map.at(element_key));

CHAOS_DEFINE_VECTOR_FOR_TYPE(std::string, ChaosStringVector)

#define CHAOS_SCAN_VECTOR_ITERATOR(iter, vec, to_execute)\
for(iter it = vec.begin();\
Expand Down

0 comments on commit b17431c

Please sign in to comment.