Skip to content

Commit

Permalink
Merge pull request #123 from polycube-network/pr/fix_show_parent
Browse files Browse the repository at this point in the history
polycubed: show parent when attached to a netdev
  • Loading branch information
frisso committed May 10, 2019
2 parents 09d1bd5 + d55111d commit a89a923
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/polycubed/src/extiface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,5 +251,9 @@ bool ExtIface::is_used() const {
return cubes_.size() > 0 || peer_ != nullptr;
}

std::string ExtIface::get_iface_name() const {
return iface_;
}

} // namespace polycubed
} // namespace polycube
2 changes: 2 additions & 0 deletions src/polycubed/src/extiface.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ class ExtIface : public PeerIface {
void set_next_index(uint16_t index);
bool is_used() const;

std::string get_iface_name() const;

protected:
static std::set<std::string> used_ifaces;
int load_ingress();
Expand Down
7 changes: 5 additions & 2 deletions src/polycubed/src/transparent_cube.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,8 +151,11 @@ nlohmann::json TransparentCube::to_json() const {

std::string parent;
if (parent_) {
auto port_parent = dynamic_cast<Port *>(parent_);
parent = port_parent->get_path();
if (auto port_parent = dynamic_cast<Port *>(parent_)) {
parent = port_parent->get_path();
} else if (auto iface_parent = dynamic_cast<ExtIface *>(parent_)) {
parent = iface_parent->get_iface_name();
}
}

j["parent"] = parent;
Expand Down

0 comments on commit a89a923

Please sign in to comment.