Skip to content

Commit

Permalink
add missing hostname property to CIMInstance(Name)
Browse files Browse the repository at this point in the history
  • Loading branch information
phatina committed Oct 28, 2014
1 parent 50d7f99 commit 10b1ddc
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 2 deletions.
18 changes: 17 additions & 1 deletion src/lmiwbem_instance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -549,7 +549,23 @@ void CIMInstance::evalProperties()
std::list<Pegasus::CIMConstProperty> &properties = *m_rc_inst_properties.get();
for (it = properties.begin(); it != properties.end(); ++it) {
bp::object prop_name(it->getName());
m_properties[prop_name] = CIMProperty::create(*it);
if (it->getValue().getType() == Pegasus::CIMTYPE_REFERENCE) {
// We got a property with CIMObjectPath value. Let's set its
// hostname which could be left out by Pegasus.
// FIXME: refactor using getHostname()
CIMInstanceName &this_iname = lmi::extract<CIMInstanceName&>(getPath());
Pegasus::CIMProperty property = it->clone();
Pegasus::CIMValue value = property.getValue();
Pegasus::CIMObjectPath iname;
value.get(iname);
iname.setHost(this_iname.getHostname().c_str());
value.set(iname);
property.setValue(value);

m_properties[prop_name] = CIMProperty::create(property);
} else {
m_properties[prop_name] = CIMProperty::create(*it);
}
property_list.append(prop_name);
}

Expand Down
12 changes: 11 additions & 1 deletion src/lmiwbem_instance_name.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,12 +176,22 @@ bp::object CIMInstanceName::create(
const Pegasus::Array<Pegasus::CIMKeyBinding> &keybindings = obj_path.getKeyBindings();
const Pegasus::Uint32 cnt = keybindings.size();
for (Pegasus::Uint32 i = 0; i < cnt; ++i) {
const Pegasus::CIMKeyBinding &keybinding = keybindings[i];
Pegasus::CIMKeyBinding keybinding = keybindings[i];
bp::object name(
std_string_as_pyunicode(
std::string(keybinding.getName().getString().getCString()))
);

if (keybinding.getType() == Pegasus::CIMKeyBinding::REFERENCE) {
// We got a keybinding with CIMObjectPath value. Let's set its
// hostname which could be left out by Pegasus.
Pegasus::CIMObjectPath path(keybinding.getValue());
if (path.getHost() == Pegasus::String::EMPTY) {
path.setHost(fake_this.m_hostname.c_str());
keybinding.setValue(path.toString());
}
}

bp::object value = keybindingToValue(keybinding);

fake_this.m_keybindings[name] = value;
Expand Down

0 comments on commit 10b1ddc

Please sign in to comment.