-
Notifications
You must be signed in to change notification settings - Fork 713
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[everflow] align capability fetch with new swss implementation (#4773)
* [everflow] align capability fetch with new swss implementation Signed-off-by: Stepan Blyshchak <stepanb@nvidia.com>
- Loading branch information
1 parent
bd06538
commit fea06af
Showing
2 changed files
with
78 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#!/usr/bin/python | ||
|
||
import swsssdk | ||
from sonic_py_common import multi_asic | ||
DOCUMENTATION = ''' | ||
module: acl_capabilities_facts | ||
version_added: "1.0" | ||
author: Stepan Blyschak (stepanb@nvidia.com) | ||
short_description: Retrieve ACL capability information | ||
''' | ||
|
||
EXAMPLES = ''' | ||
- name: Get ACL capability facts | ||
acl_capabilities_facts: | ||
''' | ||
|
||
|
||
class AclCapabilityModule(object): | ||
def __init__(self): | ||
self.module = AnsibleModule( | ||
argument_spec=dict(), | ||
supports_check_mode=True) | ||
|
||
self.out = None | ||
self.facts = {} | ||
|
||
return | ||
|
||
def run(self): | ||
""" | ||
Run ACL capabilities facts collection. | ||
""" | ||
self.facts['acl_capabilities'] = {} | ||
namespace_list = multi_asic.get_namespace_list() | ||
swsssdk.SonicDBConfig.load_sonic_global_db_config() | ||
conn = swsssdk.SonicV2Connector(namespace=namespace_list[0]) | ||
conn.connect(conn.STATE_DB) | ||
keys = conn.keys(conn.STATE_DB, 'ACL_STAGE_CAPABILITY_TABLE|*') or [] | ||
|
||
for key in keys: | ||
capab = conn.get_all(conn.STATE_DB, key) | ||
self.facts['acl_capabilities'][key.split('|')[-1]] = capab | ||
|
||
self.module.exit_json(ansible_facts=self.facts) | ||
|
||
|
||
def main(): | ||
AclCapabilityModule().run() | ||
|
||
|
||
from ansible.module_utils.basic import * | ||
if __name__ == "__main__": | ||
main() | ||
|
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