forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[VS] Add support for context and multiple switches (sonic-net#830)
So far virtual switch supported only 1 switch to be created and only default hwinfo which was empty string. This change allows to reuse context_config.json to allow multiple switches to be created in virtual switch and each can have different hwinfo. This scenario can be useful when running VS test with multiple swss containers running.
- Loading branch information
Showing
19 changed files
with
467 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#pragma once | ||
|
||
#include "ContextConfig.h" | ||
|
||
namespace saivs | ||
{ | ||
class Context | ||
{ | ||
public: | ||
|
||
Context( | ||
_In_ std::shared_ptr<ContextConfig> contextConfig); | ||
|
||
virtual ~Context(); | ||
|
||
public: | ||
|
||
std::shared_ptr<ContextConfig> getContextConfig() const; | ||
|
||
private: | ||
|
||
std::shared_ptr<ContextConfig> m_contextConfig; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#pragma once | ||
|
||
#include "SwitchConfigContainer.h" | ||
|
||
namespace saivs | ||
{ | ||
class ContextConfig | ||
{ | ||
public: | ||
|
||
ContextConfig( | ||
_In_ uint32_t guid, | ||
_In_ const std::string& name); | ||
|
||
virtual ~ContextConfig(); | ||
|
||
public: | ||
|
||
void insert( | ||
_In_ std::shared_ptr<SwitchConfig> config); | ||
|
||
|
||
public: // TODO to private | ||
|
||
uint32_t m_guid; | ||
|
||
std::string m_name; | ||
|
||
std::shared_ptr<SwitchConfigContainer> m_scc; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#pragma once | ||
|
||
#include "ContextConfig.h" | ||
|
||
#include "swss/sal.h" | ||
|
||
#include <memory> | ||
#include <map> | ||
#include <set> | ||
|
||
namespace saivs | ||
{ | ||
class ContextConfigContainer | ||
{ | ||
public: | ||
|
||
ContextConfigContainer(); | ||
|
||
virtual ~ContextConfigContainer(); | ||
|
||
public: | ||
|
||
void insert( | ||
_In_ std::shared_ptr<ContextConfig> contextConfig); | ||
|
||
std::shared_ptr<ContextConfig> get( | ||
_In_ uint32_t guid); | ||
|
||
std::set<std::shared_ptr<ContextConfig>> getAllContextConfigs(); | ||
|
||
public: | ||
|
||
static std::shared_ptr<ContextConfigContainer> loadFromFile( | ||
_In_ const char* contextConfig); | ||
|
||
static std::shared_ptr<ContextConfigContainer> getDefault(); | ||
|
||
private: | ||
|
||
std::map<uint32_t, std::shared_ptr<ContextConfig>> m_map; | ||
|
||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#include "Context.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
using namespace saivs; | ||
|
||
Context::Context( | ||
_In_ std::shared_ptr<ContextConfig> contextConfig): | ||
m_contextConfig(contextConfig) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// empty | ||
} | ||
|
||
Context::~Context() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// empty | ||
} | ||
|
||
std::shared_ptr<ContextConfig> Context::getContextConfig() const | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
return m_contextConfig; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
#include "ContextConfig.h" | ||
|
||
#include "swss/logger.h" | ||
|
||
using namespace saivs; | ||
|
||
ContextConfig::ContextConfig( | ||
_In_ uint32_t guid, | ||
_In_ const std::string& name): | ||
m_guid(guid), | ||
m_name(name) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_scc = std::make_shared<SwitchConfigContainer>(); | ||
} | ||
|
||
ContextConfig::~ContextConfig() | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
// empty | ||
} | ||
|
||
void ContextConfig::insert( | ||
_In_ std::shared_ptr<SwitchConfig> config) | ||
{ | ||
SWSS_LOG_ENTER(); | ||
|
||
m_scc->insert(config); | ||
} |
Oops, something went wrong.