-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Change frequency of tunnel ep advertisement timer, based on out-of-band-config file inserted by host-agent. Signed-off-by: Kiran Shastri <shastrinator@gmail.com>
- Loading branch information
1 parent
39090f8
commit 43f6847
Showing
22 changed files
with
377 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ | ||
/* | ||
* Implementation for FSOutOfBandConfigSource class. | ||
* | ||
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
#ifdef HAVE_CONFIG_H | ||
#include <config.h> | ||
#endif | ||
#if defined(HAVE_SYS_INOTIFY_H) && defined(HAVE_SYS_EVENTFD_H) | ||
#define USE_INOTIFY | ||
#endif | ||
|
||
#include <stdexcept> | ||
#include <sstream> | ||
|
||
#include <boost/property_tree/json_parser.hpp> | ||
#include <boost/algorithm/string.hpp> | ||
#include <opflex/modb/URIBuilder.h> | ||
#include <boost/algorithm/string/predicate.hpp> | ||
#include <opflexagent/FSOutOfBandConfigSource.h> | ||
#include <modelgbp/observer/DropLogModeEnumT.hpp> | ||
#include <opflexagent/ExtraConfigManager.h> | ||
#include <opflexagent/logging.h> | ||
|
||
namespace opflexagent { | ||
|
||
using boost::optional; | ||
namespace fs = boost::filesystem; | ||
using std::string; | ||
using std::make_pair; | ||
using std::runtime_error; | ||
using opflex::modb::URI; | ||
using boost::asio::ip::address; | ||
using modelgbp::observer::DropLogModeEnumT; | ||
|
||
FSOutOfBandConfigSource::FSOutOfBandConfigSource(ExtraConfigManager* manager_, | ||
FSWatcher& listener, | ||
const std::string& serviceDir, | ||
const opflex::modb::URI &uri) | ||
: manager(manager_) { | ||
listener.addWatch(serviceDir, *this); | ||
} | ||
|
||
static bool isOutOfBandConfig(const fs::path& filePath) { | ||
string fstr = filePath.filename().string(); | ||
return (fstr == "aci-containers-system.oob"); | ||
} | ||
|
||
void FSOutOfBandConfigSource::updated(const fs::path& filePath) { | ||
using boost::property_tree::ptree; | ||
ptree properties; | ||
try { | ||
if (isOutOfBandConfig(filePath)) { | ||
const string& pathStr = filePath.string(); | ||
read_json(pathStr, properties); | ||
const std::string TUNNEL_ADV_INTVL("tunnel-ep-advertisement-interval"); | ||
OutOfBandConfigSpec oobSpec(properties.get<long>(TUNNEL_ADV_INTVL, 300)); | ||
manager->outOfBandConfigUpdated(oobSpec); | ||
} | ||
} catch (const std::exception& ex) { | ||
LOG(ERROR) << "Could not update out of band config for " | ||
<< filePath << ": " | ||
<< ex.what(); | ||
} | ||
|
||
} | ||
|
||
void FSOutOfBandConfigSource::deleted(const fs::path& filePath) { | ||
try { | ||
string pathStr = filePath.string(); | ||
if (isOutOfBandConfig(filePath)) { | ||
manager->outOfBandConfigDeleted(); | ||
} | ||
} catch (const std::exception& ex) { | ||
LOG(ERROR) << "Could not delete out of band config for " | ||
<< filePath << ": " | ||
<< ex.what(); | ||
} | ||
} | ||
|
||
} /* namespace opflexagent */ |
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
58 changes: 58 additions & 0 deletions
58
agent-ovs/lib/include/opflexagent/FSOutOfBandConfigSource.h
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,58 @@ | ||
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ | ||
/* | ||
* Include file for filesystem out of band config source | ||
* | ||
* Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
#pragma once | ||
#ifndef OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H | ||
#define OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H | ||
|
||
#include <opflexagent/FSWatcher.h> | ||
#include <boost/filesystem.hpp> | ||
|
||
#include <opflexagent/OutOfBandConfig.h> | ||
|
||
#include <string> | ||
|
||
namespace opflexagent { | ||
|
||
class ExtraConfigManager; | ||
|
||
/** | ||
* An out of band config source that gets information for | ||
* out of band config from the filesystem. | ||
*/ | ||
class FSOutOfBandConfigSource : public FSWatcher::Watcher { | ||
public: | ||
/** | ||
* Instantiate a new out of band config source. It will set a | ||
* watch on the given path. | ||
*/ | ||
FSOutOfBandConfigSource(ExtraConfigManager* manager, | ||
FSWatcher& listener, | ||
const std::string& OutOfBandConfigDir, | ||
const opflex::modb::URI& uri); | ||
|
||
/** | ||
* Destroy the out of band config source and clean up all state | ||
*/ | ||
virtual ~FSOutOfBandConfigSource() {} | ||
|
||
// See Watcher | ||
virtual void updated(const boost::filesystem::path& filePath); | ||
// See Watcher | ||
virtual void deleted(const boost::filesystem::path& filePath); | ||
|
||
private: | ||
ExtraConfigManager* manager; | ||
}; | ||
|
||
} /* namespace opflexagent */ | ||
|
||
#endif /* OPFLEXAGENT_OUTOFBANDCONFIGSOURCE_H */ |
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 @@ | ||
/* -*- C++ -*-; c-basic-offset: 4; indent-tabs-mode: nil */ | ||
/* | ||
* Include file for out of band config | ||
* | ||
* Copyright (c) 2020 Cisco Systems, Inc. and others. All rights reserved. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License v1.0 which accompanies this distribution, | ||
* and is available at http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
#pragma once | ||
#ifndef OPFLEXAGENT_OUTOFBANDCONFIG_H | ||
#define OPFLEXAGENT_OUTOFBANDCONFIG_H | ||
|
||
namespace opflexagent { | ||
class OutOfBandConfigSpec { | ||
public: | ||
OutOfBandConfigSpec(long intvl):tunnelEpAdvInterval(intvl) {}; | ||
long tunnelEpAdvInterval; | ||
}; | ||
} /* namespace opflexagent */ | ||
|
||
#endif /* OPFLEXAGENT_OUTOFBANDCONFIG_H */ |
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
Oops, something went wrong.