Skip to content

Commit

Permalink
@2313258 Add agent status accessors and agent iterators for options/s…
Browse files Browse the repository at this point in the history
…tatus.
  • Loading branch information
rmadsen authored and tsuna committed May 18, 2015
1 parent 78c827e commit 09515e8
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 6 deletions.
2 changes: 2 additions & 0 deletions EosSdk.i
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@ void throw_py_error(error const& err) {
wrap_iterator(eos::acl_iter_t, eos::acl_iter_impl, eos::acl_key_t);
wrap_iterator(eos::acl_rule_ip_iter_t, eos::acl_rule_ip_iter_impl, eos::acl_rule_ip_entry_t);
wrap_iterator(eos::acl_rule_eth_iter_t, eos::acl_rule_eth_iter_impl, eos::acl_rule_eth_entry_t);
wrap_iterator(eos::agent_option_iter_t, eos::agent_option_iter_impl, std::string);
wrap_iterator(eos::agent_status_iter_t, eos::agent_status_iter_impl, std::string);
wrap_iterator(eos::class_map_iter_t, eos::class_map_iter_impl, eos::class_map_key_t);
wrap_iterator(eos::fib_fec_iter_t, eos::fib_fec_iter_impl, eos::fib_fec_t);
wrap_iterator(eos::fib_route_iter_t, eos::fib_route_iter_impl, eos::fib_route_t);
Expand Down
21 changes: 16 additions & 5 deletions agent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,22 @@ class agent_mgr_impl : public agent_mgr {
return "";
}

agent_option_iter_t agent_option_iter() const {
agent_option_iter_t * nop = 0;
return *nop; // TODO: No op impl.
}

std::string
status(std::string const & key) const {
return "";
}

agent_status_iter_t status_iter() const {
agent_status_iter_t * nop = 0;
return *nop; // TODO: No op impl.
}


void
status_set(std::string const & key, std::string const & value) {
}
Expand All @@ -67,11 +83,6 @@ class agent_mgr_impl : public agent_mgr {
status_del(std::string const & key) {
}

std::string
status(std::string const & key) const {
return "";
}

};

void handle_agent_initialize(agent_mgr * mgr) {
Expand Down
47 changes: 46 additions & 1 deletion eos/agent.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <eos/base.h>
#include <eos/base_handler.h>
#include <eos/base_mgr.h>
#include <eos/iterator.h>

/**
* @file
Expand Down Expand Up @@ -127,6 +128,25 @@ class EOS_SDK_PUBLIC agent_handler : public base_handler<agent_mgr, agent_handle
virtual void on_agent_option(std::string const & name, std::string const & value);
};

class agent_option_iter_impl;
/// Iterator type for configured options
class EOS_SDK_PUBLIC agent_option_iter_t :
public iter_base<std::string, agent_option_iter_impl> {
private:
friend class agent_option_iter_impl;
explicit agent_option_iter_t(agent_option_iter_impl * const) EOS_SDK_PRIVATE;
};

class agent_status_iter_impl;
/// Iterator type for published status keys.
class EOS_SDK_PUBLIC agent_status_iter_t :
public iter_base<std::string, agent_status_iter_impl> {
private:
friend class agent_status_iter_impl;
explicit agent_status_iter_t(agent_status_iter_impl * const) EOS_SDK_PRIVATE;
};


class EOS_SDK_PUBLIC agent_mgr : public base_mgr<agent_handler> {
public:
virtual ~agent_mgr();
Expand Down Expand Up @@ -156,14 +176,39 @@ class EOS_SDK_PUBLIC agent_mgr : public base_mgr<agent_handler> {
*/
virtual std::string agent_option(std::string const & name) const = 0;

/**
* Iterate through all configured agent options.
*
* Yields a string for each option name that has a non-empty value
* set.
*/
virtual agent_option_iter_t agent_option_iter() const = 0;


/**
* Get last set value for the given status key.
*
* If no value has been set for the named key, an empty string is
* returned.
*/
virtual std::string status(std::string const & key) const = 0;

/**
* Iterate through all status values that this agent has set.
*
* Yields a string for each key that has a non-empty value set.
*/
virtual agent_status_iter_t status_iter() const = 0;

/// Publish a status value mapped to the named key.
virtual void status_set(std::string const & key,
std::string const & value) = 0;
/// Delete the stored agent status with the given key
virtual void status_del(std::string const & key) = 0;


/**
* Called when agent graceful shutdown has successfully completed.
* Notify the SDK that the agent has successfully shutdown.
*
* If the agent requires special handling to cleanup state when
* the agent is disabled, then an agent_handler must be created
Expand Down
3 changes: 3 additions & 0 deletions iterator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Arista Networks, Inc. Confidential and Proprietary.

#include "eos/acl.h"
#include "eos/agent.h"
#include "eos/class_map.h"
#include "eos/decap_group.h"
#include "eos/directflow.h"
Expand Down Expand Up @@ -101,6 +102,8 @@ inline iter_base<T, Impl>::operator bool() const {
INSTANTIATE_ITERATOR(acl_key_t, acl_iter_impl);
INSTANTIATE_ITERATOR(acl_rule_eth_entry_t, acl_rule_eth_iter_impl);
INSTANTIATE_ITERATOR(acl_rule_ip_entry_t, acl_rule_ip_iter_impl);
INSTANTIATE_ITERATOR(std::string, agent_option_iter_impl);
INSTANTIATE_ITERATOR(std::string, agent_status_iter_impl);
INSTANTIATE_ITERATOR(class_map_key_t, class_map_iter_impl);
INSTANTIATE_ITERATOR(decap_group_t, decap_group_iter_impl);
INSTANTIATE_ITERATOR(fib_fec_t, fib_fec_iter_impl);
Expand Down

0 comments on commit 09515e8

Please sign in to comment.