Skip to content

Commit

Permalink
deploy: 725dedc
Browse files Browse the repository at this point in the history
  • Loading branch information
Arista-Jenkins committed Oct 17, 2024
0 parents commit 48a2048
Show file tree
Hide file tree
Showing 247 changed files with 95,266 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 records the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 1bb92a7c388133b18558e1594cd0c2a1
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
1,436 changes: 1,436 additions & 0 deletions _modules/arista/alert/v1/services/gen_pb2_grpc.html

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

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

Large diffs are not rendered by default.

184 changes: 184 additions & 0 deletions _modules/cloudvision/Connector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,184 @@


<!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=e59714d7" />


<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=9bcbadda"></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 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 48a2048

Please sign in to comment.