-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmongoScript.py
More file actions
95 lines (70 loc) · 3.46 KB
/
mongoScript.py
File metadata and controls
95 lines (70 loc) · 3.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
from pymongo import MongoClient
class Mongo_Database:
def __init__(self):
pass
def get_mongodb_connection(self):
self.client = MongoClient('localhost')
return self.client.start_session()
def get_mongodb_huawei_data(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['huawei_data']
def get_mongodb_devices_status(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices_status']
def get_mongodb_status_device_temporal(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices_status_temp']
def get_mongodb_network(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['network_devices']
def get_mongodb_viptela_Devices(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices_sdwan']
def get_mongodb_serial_viptela_devices(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices_seriales_sdwan']
def get_mongodb_devices(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices']
def get_mongodb_devices_temporal(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['devices_temp']
def get_mongodb_template(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['template']
def get_mongodb_network_clients(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['clients_in_networks']
def set_mongodb_information_centros_educativos(self):
self.client = MongoClient('localhost')
self.db = self.client["dashboard_devices_status"]
return self.db['geografiaCE']
def get_mongodb_count_devices (self):
return self.get_mongodb_devices().count_documents({})
def get_mongodb_count_devices_status(self):
return self.get_mongodb_devices_status().count_documents({})
def get_mongodb_count_networks(self):
return self.get_mongodb_network().count_documents({})
def get_mongodb_devices_in_centros_educativos(self,code):
return self.get_mongodb_devices().find({'name' : {'$regex' : '.*' + code + '.*'}})
def get_monfogdb_serial_device(self,serial):
return self.get_mongodb_devices().count_documents({'serial' : serial})
def get_mongodb_device_status(self,serial):
return self.get_mongodb_devices_status().find_one({'serial_equipo' : serial})
def get_mongodb_network_name_from_code(self,code):
return self.get_mongodb_network().find_one({'tags' : {'$regex' : '.*' + code + '.*'}})
def get_mongodb_network_template_from_id(self,id_temp):
return self.get_mongodb_template().find_one({'id' : id_temp})
###
def get_mongodb_clients_from_idnetwork(self,id):
return self.get_mongodb_network_clients().count_documents({'serial' : id})