Skip to content

Commit

Permalink
deploy: 5133f57
Browse files Browse the repository at this point in the history
  • Loading branch information
Arista-Jenkins committed Aug 27, 2024
0 parents commit 8bd88d8
Show file tree
Hide file tree
Showing 224 changed files with 95,589 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: ab0cb98f2986eaad15a741f3cfa333d8
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
1,441 changes: 1,441 additions & 0 deletions _modules/arista/alert/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions _modules/arista/bugexposure/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,557 changes: 1,557 additions & 0 deletions _modules/arista/changecontrol/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,909 changes: 1,909 additions & 0 deletions _modules/arista/configlet/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

2,223 changes: 2,223 additions & 0 deletions _modules/arista/configstatus/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

815 changes: 815 additions & 0 deletions _modules/arista/connectivitymonitor/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,323 changes: 1,323 additions & 0 deletions _modules/arista/dashboard/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

463 changes: 463 additions & 0 deletions _modules/arista/endpointlocation/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,323 changes: 1,323 additions & 0 deletions _modules/arista/event/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,205 changes: 1,205 additions & 0 deletions _modules/arista/identityprovider/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

463 changes: 463 additions & 0 deletions _modules/arista/imagestatus/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

2,613 changes: 2,613 additions & 0 deletions _modules/arista/inventory/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

346 changes: 346 additions & 0 deletions _modules/arista/lifecycle/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

463 changes: 463 additions & 0 deletions _modules/arista/redirector/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,597 changes: 1,597 additions & 0 deletions _modules/arista/serviceaccount/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

4,411 changes: 4,411 additions & 0 deletions _modules/arista/studio/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

1,909 changes: 1,909 additions & 0 deletions _modules/arista/tag/v2/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

2,261 changes: 2,261 additions & 0 deletions _modules/arista/workspace/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

189 changes: 189 additions & 0 deletions _modules/cloudvision/Connector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,189 @@
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="../../">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>cloudvision.Connector &mdash; CloudVision Python 1.21.1 documentation</title>
<link rel="stylesheet" type="text/css" href="../../_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="../../_static/css/theme.css?v=19f00094" />


<!--[if lt IE 9]>
<script src="../../_static/js/html5shiv.min.js"></script>
<![endif]-->

<script src="../../_static/jquery.js?v=5d32c60e"></script>
<script src="../../_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="../../_static/documentation_options.js?v=ffc33bb7"></script>
<script src="../../_static/doctools.js?v=9a2dae69"></script>
<script src="../../_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="../../_static/js/theme.js"></script>
<link rel="index" title="Index" href="../../genindex.html" />
<link rel="search" title="Search" href="../../search.html" />
</head>

<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >



<a href="../../index.html" class="icon icon-home">
CloudVision Python
</a>
<div class="version">
1.21.1
</div>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="../../search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../modules.html">cloudvision</a></li>
</ul>

</div>
</div>
</nav>

<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="../../index.html">CloudVision Python</a>
</nav>

<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="../../index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item"><a href="../index.html">Module code</a></li>
<li class="breadcrumb-item active">cloudvision.Connector</li>
<li class="wy-breadcrumbs-aside">
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">

<h1>Source code for cloudvision.Connector</h1><div class="highlight"><pre>
<span></span><span class="c1"># Copyright (c) 2020 Arista Networks, Inc.</span>
<span class="c1"># Use of this source code is governed by the Apache License 2.0</span>
<span class="c1"># that can be found in the COPYING file.</span>

<span class="kn">import</span> <span class="nn">logging</span>
<span class="n">name</span> <span class="o">=</span> <span class="s2">&quot;cloudvision.Connector&quot;</span>


<div class="viewcode-block" id="process_notifs">
<a class="viewcode-back" href="../../cloudvision.Connector.html#cloudvision.Connector.process_notifs">[docs]</a>
<span class="k">def</span> <span class="nf">process_notifs</span><span class="p">(</span><span class="n">stream</span><span class="p">,</span> <span class="n">paths</span><span class="o">=</span><span class="p">{},</span> <span class="n">keys</span><span class="o">=</span><span class="p">{},</span> <span class="n">nominalKeys</span><span class="o">=</span><span class="kc">None</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> process_notifs consume the batch coming from stream and return them</span>
<span class="sd"> as a hierarchy of dataset, path, and keys. Allowing for faster access</span>
<span class="sd"> of a given time serie.</span>
<span class="sd"> &quot;&quot;&quot;</span>
<span class="n">res</span> <span class="o">=</span> <span class="p">{}</span>

<span class="k">for</span> <span class="n">batch</span> <span class="ow">in</span> <span class="n">stream</span><span class="p">:</span>
<span class="n">dname</span> <span class="o">=</span> <span class="n">batch</span><span class="p">[</span><span class="s2">&quot;dataset&quot;</span><span class="p">][</span><span class="s2">&quot;name&quot;</span><span class="p">]</span>
<span class="k">for</span> <span class="n">notif</span> <span class="ow">in</span> <span class="n">batch</span><span class="p">[</span><span class="s2">&quot;notifications&quot;</span><span class="p">]:</span>
<span class="n">time</span> <span class="o">=</span> <span class="n">notif</span><span class="p">[</span><span class="s2">&quot;timestamp&quot;</span><span class="p">]</span>
<span class="n">path</span> <span class="o">=</span> <span class="s2">&quot;/&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">notif</span><span class="p">[</span><span class="s2">&quot;path_elements&quot;</span><span class="p">])</span>
<span class="k">if</span> <span class="n">paths</span> <span class="ow">and</span> <span class="n">path</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">paths</span><span class="p">:</span>
<span class="k">continue</span>
<span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="n">notif</span><span class="p">[</span><span class="s2">&quot;updates&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
<span class="k">if</span> <span class="n">keys</span> <span class="ow">and</span> <span class="n">key</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">keys</span><span class="p">:</span>
<span class="k">continue</span>
<span class="n">value</span> <span class="o">=</span> <span class="n">__get_val</span><span class="p">(</span><span class="n">value</span><span class="p">,</span> <span class="n">nominalKeys</span><span class="p">)</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">__update_dict</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="n">dname</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">nominalKeys</span><span class="p">,</span> <span class="n">value</span><span class="p">,</span> <span class="n">time</span><span class="p">)</span>
<span class="k">return</span> <span class="n">res</span></div>



<span class="k">def</span> <span class="nf">__get_val</span><span class="p">(</span><span class="n">nominal</span><span class="p">,</span> <span class="n">nomKeys</span><span class="p">):</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">nominal</span>
<span class="k">if</span> <span class="n">nomKeys</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
<span class="k">return</span> <span class="n">res</span>
<span class="k">for</span> <span class="n">k</span> <span class="ow">in</span> <span class="n">nomKeys</span><span class="p">:</span>
<span class="k">if</span> <span class="n">k</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">res</span><span class="p">:</span>
<span class="n">logging</span><span class="o">.</span><span class="n">error</span><span class="p">(</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> Key %s not found in json %s</span>
<span class="sd"> Full nominal %s</span>
<span class="sd"> Nominal key path %s</span>
<span class="sd"> &quot;&quot;&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">k</span><span class="p">,</span> <span class="n">res</span><span class="p">,</span> <span class="n">nominal</span><span class="p">,</span> <span class="n">nomKeys</span><span class="p">))</span>
<span class="k">return</span> <span class="kc">None</span>
<span class="n">res</span> <span class="o">=</span> <span class="n">res</span><span class="p">[</span><span class="n">k</span><span class="p">]</span>
<span class="k">return</span> <span class="n">res</span>


<span class="k">def</span> <span class="nf">__update_dict</span><span class="p">(</span><span class="n">resDict</span><span class="p">,</span> <span class="n">dataset</span><span class="p">,</span> <span class="n">path</span><span class="p">,</span> <span class="n">key</span><span class="p">,</span> <span class="n">nominalKeys</span><span class="p">,</span> <span class="n">val</span><span class="p">,</span> <span class="n">ts</span><span class="p">):</span>
<span class="n">entry</span> <span class="o">=</span> <span class="n">resDict</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">dataset</span><span class="p">,</span>
<span class="p">{})</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">path</span><span class="p">,</span>
<span class="p">{})</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="n">key</span><span class="p">,</span> <span class="p">{})</span>
<span class="k">if</span> <span class="n">nominalKeys</span><span class="p">:</span>
<span class="n">entry</span> <span class="o">=</span> <span class="n">entry</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s2">&quot;/&quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">nominalKeys</span><span class="p">),</span> <span class="p">{})</span>
<span class="n">entry</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s2">&quot;values&quot;</span><span class="p">,</span> <span class="p">[])</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">val</span><span class="p">)</span>
<span class="n">entry</span><span class="o">.</span><span class="n">setdefault</span><span class="p">(</span><span class="s2">&quot;timestamps&quot;</span><span class="p">,</span> <span class="p">[])</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">ts</span><span class="p">)</span>
<span class="k">return</span> <span class="n">resDict</span>


<div class="viewcode-block" id="sort_dict">
<a class="viewcode-back" href="../../cloudvision.Connector.html#cloudvision.Connector.sort_dict">[docs]</a>
<span class="k">def</span> <span class="nf">sort_dict</span><span class="p">(</span><span class="n">resDict</span><span class="p">):</span>
<span class="w"> </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd"> sort_dict orders every timeseries in a hierarchy of dataset by its timestamps.</span>
<span class="sd"> &quot;&quot;&quot;</span>

<span class="k">def</span> <span class="nf">sort_timeserie</span><span class="p">(</span><span class="n">timeserie</span><span class="p">):</span>
<span class="n">timeserie</span><span class="p">[</span><span class="s2">&quot;values&quot;</span><span class="p">],</span> <span class="n">timeserie</span><span class="p">[</span><span class="s2">&quot;timestamps&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">zip</span><span class="p">(</span><span class="o">*</span><span class="nb">sorted</span><span class="p">(</span><span class="nb">zip</span><span class="p">(</span>
<span class="n">timeserie</span><span class="p">[</span><span class="s2">&quot;values&quot;</span><span class="p">],</span>
<span class="n">timeserie</span><span class="p">[</span><span class="s2">&quot;timestamps&quot;</span><span class="p">]),</span> <span class="n">key</span><span class="o">=</span><span class="k">lambda</span> <span class="n">x</span><span class="p">:</span> <span class="p">(</span><span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">seconds</span><span class="p">,</span> <span class="n">x</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">nanos</span><span class="p">)))</span>

<span class="n">stack</span> <span class="o">=</span> <span class="p">[</span><span class="n">resDict</span><span class="p">]</span>
<span class="k">while</span> <span class="n">stack</span><span class="p">:</span>
<span class="n">timeserie</span> <span class="o">=</span> <span class="n">stack</span><span class="o">.</span><span class="n">pop</span><span class="p">()</span>
<span class="k">if</span> <span class="s2">&quot;values&quot;</span> <span class="ow">in</span> <span class="n">timeserie</span> <span class="ow">and</span> <span class="s2">&quot;timestamps&quot;</span> <span class="ow">in</span> <span class="n">timeserie</span><span class="p">:</span>
<span class="n">sort_timeserie</span><span class="p">(</span><span class="n">timeserie</span><span class="p">)</span>
<span class="k">else</span><span class="p">:</span>
<span class="n">stack</span><span class="o">.</span><span class="n">extend</span><span class="p">(</span><span class="n">timeserie</span><span class="o">.</span><span class="n">values</span><span class="p">())</span>
<span class="k">return</span> <span class="n">resDict</span></div>

</pre></div>

</div>
</div>
<footer>

<hr/>

<div role="contentinfo">
<p>&#169; Copyright 2022, Arista.</p>
</div>

Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.


</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>

</body>
</html>
Loading

0 comments on commit 8bd88d8

Please sign in to comment.