Fix #1690 Fix Computer node name when using wizard to generate the environment #1791

Merged
merged 1 commit into from Mar 8, 2012
@@ -471,20 +471,29 @@ IPropertyTree* CWizardInputs::createEnvironment()
xpath.clear().append(XML_TAG_COMPUTERTYPE).append("/").append(XML_ATTR_OPSYS);
pCompTree->setProp(xpath.str(), "linux");
+ unsigned x;
+ IpAddress ipaddr;
+
for(unsigned i = 0; i < m_ipaddressSupport.ordinality(); i++)
{
IPropertyTree* pComputer = pCompTree->addPropTree(XML_TAG_COMPUTER,createPTree());
- name.clear().appendf("node%03d", (i + 1));
+ ipaddr.ipset(m_ipaddressSupport.item(i));
+ ipaddr.getNetAddress(sizeof(x),&x);
+ name.clear().appendf("node%03d%03d", (x >> 16) & 0xFF, (x >> 24) & 0xFF);
+ getUniqueName(pCompTree, name, XML_TAG_COMPUTER, "");
pComputer->addProp(XML_ATTR_COMPUTERTYPE, "linuxmachine");
pComputer->addProp(XML_ATTR_DOMAIN, "localdomain");
pComputer->addProp(XML_ATTR_NAME, name.str());
pComputer->addProp(XML_ATTR_NETADDRESS, m_ipaddressSupport.item(i));
}
for(unsigned i = 0; i < m_ipaddress.ordinality(); i++)
- {
+ {
IPropertyTree* pComputer = pCompTree->addPropTree(XML_TAG_COMPUTER,createPTree());
- name.clear().appendf("node%03d", (m_ipaddressSupport.ordinality() + i + 1));
+ ipaddr.ipset(m_ipaddress.item(i));
+ ipaddr.getNetAddress(sizeof(x),&x);
+ name.clear().appendf("node%03d%03d", (x >> 16) & 0xFF, (x >> 24) & 0xFF);
+ getUniqueName(pCompTree, name, XML_TAG_COMPUTER, "");
pComputer->addProp(XML_ATTR_COMPUTERTYPE, "linuxmachine");
pComputer->addProp(XML_ATTR_DOMAIN, "localdomain");
pComputer->addProp(XML_ATTR_NAME, name.str());