Skip to content

Commit 8659149

Browse files
authored
Merge pull request #131 from polycube-network/pr/remove_mac_simple_bridge
pcn-simplebridge: remove mac from ports
2 parents a434057 + f9187f9 commit 8659149

File tree

11 files changed

+3
-120
lines changed

11 files changed

+3
-120
lines changed

src/services/pcn-simplebridge/datamodel/simplebridge.yang

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,7 @@ module simplebridge {
1616
polycube-base:service-name "simplebridge";
1717
polycube-base:service-min-kernel-version "4.11.0";
1818

19-
uses "polycube-standard-base:standard-base-yang-module" {
20-
augment ports {
21-
leaf mac {
22-
type yang:mac-address;
23-
description "MAC address of the port";
24-
config true;
25-
polycube-base:init-only-config;
26-
polycube-base:cli-example "C5:13:2D:36:27:9B";
27-
}
28-
}
29-
}
19+
uses "polycube-standard-base:standard-base-yang-module";
3020

3121
container fdb {
3222
leaf aging-time {

src/services/pcn-simplebridge/src/Ports.cpp

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,7 @@
2222
Ports::Ports(polycube::service::Cube<Ports> &parent,
2323
std::shared_ptr<polycube::service::PortIface> port,
2424
const PortsJsonObject &conf)
25-
: PortsBase(parent, port) {
26-
// This MAC address is not used in the datapath. We set only the variable here
27-
if (conf.macIsSet()) {
28-
mac_ = conf.getMac();
29-
} else {
30-
mac_ = utils::get_random_mac();
31-
logger()->info("[Ports] New port add with random mac: {0}", mac_);
32-
}
33-
}
25+
: PortsBase(parent, port) {}
3426

3527
Ports::~Ports() {
3628
try {
@@ -53,9 +45,3 @@ Ports::~Ports() {
5345
e.what());
5446
}
5547
}
56-
57-
std::string Ports::getMac() {
58-
// This method retrieves the mac value.
59-
return mac_;
60-
}
61-

src/services/pcn-simplebridge/src/Ports.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,6 @@ class Ports : public PortsBase {
2929
const PortsJsonObject &conf);
3030
virtual ~Ports();
3131

32-
/// <summary>
33-
/// MAC address of the port
34-
/// </summary>
35-
std::string getMac() override;
36-
3732
private:
3833
std::string mac_;
3934
};

src/services/pcn-simplebridge/src/api/SimplebridgeApi.cpp

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -486,31 +486,6 @@ Response read_simplebridge_ports_list_by_id_handler(
486486
}
487487
}
488488

489-
Response read_simplebridge_ports_mac_by_id_handler(
490-
const char *name, const Key *keys,
491-
size_t num_keys ) {
492-
// Getting the path params
493-
std::string unique_name { name };
494-
std::string unique_portsName;
495-
for (size_t i = 0; i < num_keys; ++i) {
496-
if (!strcmp(keys[i].name, "ports_name")) {
497-
unique_portsName = std::string { keys[i].value.string };
498-
break;
499-
}
500-
}
501-
502-
503-
try {
504-
505-
auto x = read_simplebridge_ports_mac_by_id(unique_name, unique_portsName);
506-
nlohmann::json response_body;
507-
response_body = x;
508-
return { kOk, ::strdup(response_body.dump().c_str()) };
509-
} catch(const std::exception &e) {
510-
return { kGenericError, ::strdup(e.what()) };
511-
}
512-
}
513-
514489
Response replace_simplebridge_by_id_handler(
515490
const char *name, const Key *keys,
516491
size_t num_keys ,

src/services/pcn-simplebridge/src/api/SimplebridgeApi.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ Response read_simplebridge_fdb_entry_port_by_id_handler(const char *name, const
5656
Response read_simplebridge_list_by_id_handler(const char *name, const Key *keys, size_t num_keys);
5757
Response read_simplebridge_ports_by_id_handler(const char *name, const Key *keys, size_t num_keys);
5858
Response read_simplebridge_ports_list_by_id_handler(const char *name, const Key *keys, size_t num_keys);
59-
Response read_simplebridge_ports_mac_by_id_handler(const char *name, const Key *keys, size_t num_keys);
6059
Response replace_simplebridge_by_id_handler(const char *name, const Key *keys, size_t num_keys, const char *value);
6160
Response replace_simplebridge_fdb_by_id_handler(const char *name, const Key *keys, size_t num_keys, const char *value);
6261
Response replace_simplebridge_fdb_entry_by_id_handler(const char *name, const Key *keys, size_t num_keys, const char *value);

src/services/pcn-simplebridge/src/api/SimplebridgeApiImpl.cpp

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -451,24 +451,6 @@ read_simplebridge_ports_list_by_id(const std::string &name) {
451451
return m;
452452
}
453453

454-
/**
455-
* @brief Read mac by ID
456-
*
457-
* Read operation of resource: mac*
458-
*
459-
* @param[in] name ID of name
460-
* @param[in] portsName ID of ports_name
461-
*
462-
* Responses:
463-
* std::string
464-
*/
465-
std::string
466-
read_simplebridge_ports_mac_by_id(const std::string &name, const std::string &portsName) {
467-
auto simplebridge = get_cube(name);
468-
auto ports = simplebridge->getPorts(portsName);
469-
return ports->getMac();
470-
471-
}
472454

473455
/**
474456
* @brief Replace fdb by ID

src/services/pcn-simplebridge/src/api/SimplebridgeApiImpl.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ namespace SimplebridgeApiImpl {
5959
std::vector<SimplebridgeJsonObject> read_simplebridge_list_by_id();
6060
PortsJsonObject read_simplebridge_ports_by_id(const std::string &name, const std::string &portsName);
6161
std::vector<PortsJsonObject> read_simplebridge_ports_list_by_id(const std::string &name);
62-
std::string read_simplebridge_ports_mac_by_id(const std::string &name, const std::string &portsName);
6362
void replace_simplebridge_by_id(const std::string &name, const SimplebridgeJsonObject &value);
6463
void replace_simplebridge_fdb_by_id(const std::string &name, const FdbJsonObject &value);
6564
void replace_simplebridge_fdb_entry_by_id(const std::string &name, const std::string &address, const FdbEntryJsonObject &value);

src/services/pcn-simplebridge/src/base/PortsBase.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ PortsJsonObject PortsBase::toJsonObject() {
2929
conf.setBase(Port::to_json());
3030

3131
conf.setName(getName());
32-
conf.setMac(getMac());
3332

3433
return conf;
3534
}

src/services/pcn-simplebridge/src/base/PortsBase.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,11 @@ class PortsBase: public polycube::service::Port {
3535
public:
3636
PortsBase(polycube::service::Cube<Ports> &parent,
3737
std::shared_ptr<polycube::service::PortIface> port);
38-
38+
3939
virtual ~PortsBase();
4040
virtual void update(const PortsJsonObject &conf);
4141
virtual PortsJsonObject toJsonObject();
4242

43-
/// <summary>
44-
/// MAC address of the port
45-
/// </summary>
46-
virtual std::string getMac() = 0;
47-
4843
std::shared_ptr<spdlog::logger> logger();
4944
protected:
5045
Simplebridge &parent_;

src/services/pcn-simplebridge/src/serializer/PortsJsonObject.cpp

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -19,22 +19,17 @@ namespace model {
1919

2020
PortsJsonObject::PortsJsonObject() {
2121
m_nameIsSet = false;
22-
m_macIsSet = false;
2322
}
2423

2524
PortsJsonObject::PortsJsonObject(const nlohmann::json &val) :
2625
JsonObjectBase(val) {
2726
m_nameIsSet = false;
28-
m_macIsSet = false;
2927

3028

3129
if (val.count("name")) {
3230
setName(val.at("name").get<std::string>());
3331
}
3432

35-
if (val.count("mac")) {
36-
setMac(val.at("mac").get<std::string>());
37-
}
3833
}
3934

4035
nlohmann::json PortsJsonObject::toJson() const {
@@ -47,10 +42,6 @@ nlohmann::json PortsJsonObject::toJson() const {
4742
val["name"] = m_name;
4843
}
4944

50-
if (m_macIsSet) {
51-
val["mac"] = m_mac;
52-
}
53-
5445
return val;
5546
}
5647

@@ -69,24 +60,6 @@ bool PortsJsonObject::nameIsSet() const {
6960

7061

7162

72-
std::string PortsJsonObject::getMac() const {
73-
return m_mac;
74-
}
75-
76-
void PortsJsonObject::setMac(std::string value) {
77-
m_mac = value;
78-
m_macIsSet = true;
79-
}
80-
81-
bool PortsJsonObject::macIsSet() const {
82-
return m_macIsSet;
83-
}
84-
85-
void PortsJsonObject::unsetMac() {
86-
m_macIsSet = false;
87-
}
88-
89-
9063
}
9164
}
9265
}

0 commit comments

Comments
 (0)