0c6f5dc02bR4">4
+class Exfo:
5
+    BASE_URL = "https://159.192.8.11/API/REST"
6
+    BASE_IP = "https://159.192.8.11"
7
+    def __init__(self, user, passwd):
8
+        self.user = user
9
+        self.passwd = passwd
10
+        self.cookies = None
11
+        self.session = requests.Session()
12
+
13
+    def login(self):
14
+        pprint("--- login ---")
15
+        payload = f'uname={self.user}&pword={self.passwd}&format=json&encryptpword=0'
16
+        headers = {
17
+                'Content-Type': 'application/x-www-form-urlencoded',
18
+                'Accept': 'application/x-www-form-urlencoded',
19
+                }
20
+        url = self.BASE_URL + "/Login"
21
+        response = self.session.post(url, headers=headers, data=payload, verify=False)
22
+       
23
+        pprint(self.session.cookies.get_dict())
24
+        pprint(response.text)
25
+        pprint(response.cookies)
26
+        #self.cookies = response.cookies
27
+    def list_api(self):
28
+        pprint("---- list_api ---")
29
+        payload = {}
30
+        headers = {
31
+          'Accept': 'application/json'
32
+        }
33
+        url = self.BASE_URL + "/"
34
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
35
+        pprint(response.json())
36
+        return response
37
+
38
+    def call_api(self, service, payload={}):
39
+        
40
+        headers = {
41
+          'Accept': 'application/json'
42
+        }
43
+        if service == "sla":
44
+            ep = "/SLAs/v1/SLA?size=100"
45
+        url = self.BASE_URL + ep
46
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
47
+        pprint(response.json())
48
+        return response
49
+
50
+    def call_remote_api(self, ep, payload={}):
51
+        
52
+        headers = {
53
+          'Accept': 'application/json'
54
+        }
55
+        url = self.BASE_IP + ep
56
+        pprint(url)
57
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
58
+        pprint(response)
59
+        return response
60
+
61
+    def logout(self):
62
+        pprint("---- logout ---")
63
+        pprint(self.session.cookies.get_dict())
64
+        payload = {}
65
+        headers = {
66
+          'Accept': 'application/json',
67
+        }
68
+        url = self.BASE_URL + "/Logoff?action=logoff"
69
+        
70
+        response = self.session.post(url, headers=headers, data=payload,  verify=False)
71
+        pprint(response)
72
+        pprint(response.text)
73
+
74
+    def video_tier(self):
75
+        pprint("------ vdo tier -------")
76
+        url = self.BASE_URL + "/Verifiers/v2/VideoTier"
77
+
78
+        payload = {}
79
+        headers = {
80
+          'Accept': 'application/json'
81
+        }
82
+
83
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
84
+        pprint(response.json())
85
+
86
+    def test_implement(self):
87
+        pprint('------- test_implement -----')
88
+        url = self.BASE_URL + "/Test/v1"
89
+
90
+        payload = {}
91
+        headers = {
92
+          'Accept': 'application/json'
93
+        }
94
+        pprint(self.session.cookies.get_dict()) 
95
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
96
+
97
+        pprint(response.json)
98
+
99
+    def test_avl_test_types(self):
100
+        pprint('------- test_avl_test_types -----')
101
+        url  = self.BASE_URL + "/Test/v1/TypeByName?list_all=true"
102
+
103
+        payload = {}
104
+        headers = {
105
+          'Accept': 'application/json'
106
+        }
107
+        response = self.session.get(url, headers=headers, data=payload, verify=False)
108
+        print(response.json())
109
+
110
+
111
+
112
+
113
+
114
+if __name__ == '__main__':
115
+    e = Exfo("administrator", "exf0w0rxC@t4dm!n")
116
+    e.login()
117
+    e.list_api()
118
+    e.video_tier()
119
+    e.test_implement()
120
+    e.test_avl_test_types()
121
+    e.logout()
122
+

+ 1 - 0
app/network_report/settings.py

@@ -89,6 +89,7 @@ TEMPLATES = [
89 89
                 'django.template.context_processors.request',
90 90
                 'django.contrib.auth.context_processors.auth',
91 91
                 'django.contrib.messages.context_processors.messages',
92
+			    'backend.context_processors.network_report',
92 93
             ],
93 94
         },
94 95
     },

+ 3 - 25
app/templates/_sidemenu.html

@@ -7,36 +7,14 @@
7 7
           Dashboard
8 8
         </a>
9 9
       </li>
10
+      {% for r in  apis.results %}
10 11
       <li class="nav-item">
11 12
         <a class="nav-link" href="#">
12 13
           <span data-feather="file"></span>
13
-          Orders
14
-        </a>
15
-      </li>
16
-      <li class="nav-item">
17
-        <a class="nav-link" href="#">
18
-          <span data-feather="shopping-cart"></span>
19
-          Products
20
-        </a>
21
-      </li>
22
-      <li class="nav-item">
23
-        <a class="nav-link" href="#">
24
-          <span data-feather="users"></span>
25
-          Customers
26
-        </a>
27
-      </li>
28
-      <li class="nav-item">
29
-        <a class="nav-link" href="#">
30
-          <span data-feather="bar-chart-2"></span>
31
-          Reports
32
-        </a>
33
-      </li>
34
-      <li class="nav-item">
35
-        <a class="nav-link" href="#">
36
-          <span data-feather="layers"></span>
37
-          Integrations
14
+          {{ r.display_name  }}
38 15
         </a>
39 16
       </li>
17
+      {% endfor %}
40 18
     </ul>
41 19
 
42 20
     <h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-1 text-muted">

+ 2 - 2
app/templates/base.html

@@ -59,7 +59,7 @@
59 59
   <div class="row">
60 60
     {% include "_sidemenu.html" %}
61 61
 
62
-    <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4">
62
+    <main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 py-3">
63 63
       {% block content %}
64 64
         <h1>Content is Here</h1>
65 65
       {% endblock %}
@@ -68,7 +68,7 @@
68 68
 </div>
69 69
 
70 70
 
71
-    <script src="{% static "bootstrap/dist/js/bootstrap.bundle.min.js" %}" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
71
+    <script src="{% static "bootstrap/dist/js/bootstrap.bundle.min.js" %}"></script>
72 72
 
73 73
       <script src="https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/feather.min.js" integrity="sha384-uO3SXW5IuS1ZpFPKugNNWqTZRRglnUJK6UAZ/gxOX80nxEkN9NcGZTftn6RzhGWE" crossorigin="anonymous"></script>
74 74
       <script src="https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js" integrity="sha384-zNy6FEbO50N+Cg5wap8IKA4M/ZnLJgzc6w2NqACZaK0u0FXfOWRRJOnQtpZun8ha" crossorigin="anonymous"></script>

+ 6 - 0
docker-compose.yml

@@ -16,6 +16,12 @@ services:
16 16
       - POSTGRES_DB=postgres
17 17
       - POSTGRES_USER=postgres
18 18
       - POSTGRES_PASSWORD=postgres
19
+  mongodb:
20
+    image: mongo:6-jammy
21
+    ports:
22
+      - '27017:27017'
23
+    volumes:
24
+      - ./mongodb:/data/db
19 25
   web:
20 26
     build: .
21 27
     image: tum/network-report-image

+ 3 - 0
requirements.txt

@@ -88,3 +88,6 @@ django-qr-code
88 88
 python-barcode
89 89
 gunicorn==21.2.0
90 90
 django-autotranslate
91
+pymongo
92
+dnspython
93
+ttp

tum/tmt_learning - Gogs: Simplico Git Service

Нема описа

LICENSE 1.1KB

1234567891011121314151617181920212223
  1. The MIT License (MIT)
  2. Copyright (c) 2014-2016 Jonathan Ong me@jongleberry.com and contributors
  3. Permission is hereby granted, free of charge, to any person obtaining a copy
  4. of this software and associated documentation files (the "Software"), to deal
  5. in the Software without restriction, including without limitation the rights
  6. to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  7. copies of the Software, and to permit persons to whom the Software is
  8. furnished to do so, subject to the following conditions:
  9. The above copyright notice and this permission notice shall be included in
  10. all copies or substantial portions of the Software.
  11. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  12. IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  13. FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  14. AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  15. LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  16. OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  17. THE SOFTWARE.