Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
I
iot_manager_migration
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
CI / CD Analytics
Repository Analytics
Value Stream Analytics
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
ajil.k
iot_manager_migration
Commits
28acb8fc
Commit
28acb8fc
authored
May 03, 2023
by
ajil.k
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added
parents
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
83 additions
and
0 deletions
+83
-0
restoring_from_bson.py
restoring_from_bson.py
+23
-0
schema.py
schema.py
+60
-0
translator.py
translator.py
+0
-0
No files found.
restoring_from_bson.py
0 → 100644
View file @
28acb8fc
import
bson
import
pymongo
# Set up a MongoDB client
client
=
pymongo
.
MongoClient
(
'mongodb://ilens:ilens
%401234
@192.168.0.220:4720/?authSource=admin'
)
# Select the database and collection to restore
db
=
client
[
"Iot_manager(Test)"
]
col_list
=
[
'mp201a'
,
'glens'
,
'ilens'
,
'ilens_ir4.0'
,
'dubai-munc'
,
'epda-rak'
,
'camw'
,
'ilens-avis'
,
'old_glens'
,
'old_calixto'
,
"ilens-mc"
]
for
collection_name
in
col_list
:
i
=
0
collection
=
db
[
collection_name
]
path
=
"C:/Users/ajil.k/Desktop/iot_devices/iot_devices/"
# Open the BSON file for reading
full_path_with_extension
=
f
"{path}{collection_name}.bson"
with
open
(
full_path_with_extension
,
"rb"
)
as
bson_file
:
# Loop through each document in the BSON file and insert it into the collection
for
document
in
bson
.
decode_file_iter
(
bson_file
):
collection
.
insert_one
(
document
)
i
+=
1
print
(
f
"{collection_name} - {i}"
)
schema.py
0 → 100644
View file @
28acb8fc
from
datetime
import
datetime
from
pydantic
import
BaseModel
,
Field
class
DeviceDetails
(
BaseModel
):
device_id
:
str
=
Field
(
default
=
""
,
description
=
"The ID of the device"
)
software_name
:
str
=
Field
(
default
=
""
,
description
=
"The name of the software running on the device"
)
mac_address
:
str
=
Field
(
default
=
""
,
description
=
"The MAC address of the device"
)
site_id
:
str
=
Field
(
default
=
""
,
description
=
"The ID of the site where the device is located"
)
site_name
:
str
=
Field
(
default
=
""
,
description
=
"The name of the site where the device is located"
)
site_location
:
dict
=
Field
(
default
=
{
"country"
:
""
,
"state"
:
""
,
"city"
:
""
},
description
=
"The location of the site where the device is located"
)
customer
:
str
=
Field
(
default
=
""
,
description
=
"The name of the customer that owns the device"
)
vendor
:
str
=
Field
(
default
=
""
,
description
=
"The name of the vendor that supplied the device"
)
tags
:
list
[
str
]
=
Field
(
default
=
[],
description
=
"Any tags associated with the device"
)
class
DeviceParameters
(
BaseModel
):
mac_address
:
str
=
Field
(
default
=
""
,
description
=
"The MAC address of the device"
)
software_name
:
str
=
Field
(
default
=
""
,
description
=
"The name of the software running on the device"
)
ram_total
:
int
=
Field
(
default
=
0
,
description
=
"The total amount of RAM on the device"
)
ram_percent
:
float
=
Field
(
default
=
0.00
,
description
=
"The percentage of RAM used on the device"
)
ram_free
:
int
=
Field
(
default
=
0
,
description
=
"The amount of free RAM on the device"
)
ram_used
:
int
=
Field
(
default
=
0
,
description
=
"The amount of RAM used on the device"
)
disk
:
dict
=
Field
(
default
=
{},
description
=
"The details of the disk space on the device"
)
last_reboot
:
datetime
last_sync
:
datetime
throttle
:
str
=
Field
(
default
=
""
,
description
=
"The throttle status of the device"
)
io_count
:
dict
=
Field
(
default
=
{
"read_count"
:
0
,
"write_count"
:
0
,
"read_bytes"
:
0
,
"write_bytes"
:
0
,
"read_time"
:
0
,
"write_time"
:
0
,
"read_merged_count"
:
0
,
"write_merged_count"
:
0
,
"busy_time"
:
0
},
description
=
"The input/output count and time for the device"
)
public_ip
:
str
=
Field
(
default
=
""
,
description
=
"The public IP address of the device"
)
vpn_ip
:
str
=
Field
(
default
=
""
,
description
=
"The VPN IP address of the device"
)
vpn_connected
:
bool
=
Field
(
default
=
False
,
description
=
"The status of VPN connection of the device"
)
firmware_version
:
str
=
Field
(
default
=
""
,
description
=
"The firmware version of the device"
)
app_version
:
list
=
Field
(
default
=
[],
description
=
"The app version of the device"
)
monitor_id
:
str
=
Field
(
default
=
""
,
description
=
"The monitor ID of the device"
)
monitoring_list
:
str
=
Field
(
default
=
""
,
description
=
"The monitoring list of the device"
)
cpu
:
dict
=
Field
(
default
=
{
"current"
:
""
,
"overall_usage"
:
""
,
"cpu_temp"
:
""
,
"each_cpu_usage"
:
[
0
,
0
]},
description
=
"The CPU usage and temperature of the device"
)
rssi
:
str
=
Field
(
default
=
""
,
description
=
"The RSSI value of the device"
)
cts
:
int
=
Field
(
default
=
0
,
description
=
"The CTS value of the device"
)
rts
:
int
=
Field
(
default
=
0
,
description
=
"The RTS value of the device"
)
lts
:
int
=
Field
(
default
=
0
,
description
=
"The LTS value of the device"
)
ats
:
int
=
Field
(
default
=
0
,
description
=
"The ATS value of the device"
)
status
:
str
=
Field
(
default
=
""
,
description
=
"The status of the device"
)
clear_sd
:
bool
=
Field
(
default
=
False
,
description
=
"The status of clearing the SD card of the device"
)
eth_ip
:
str
=
Field
(
default
=
""
,
description
=
"The Ethernet IP address of the device"
)
username
:
str
=
Field
(
default
=
""
,
description
=
"The username of the device"
)
date
:
str
=
Field
(
default
=
""
,
description
=
"The date of the device"
)
network_name
:
str
=
Field
(
default
=
""
,
description
=
"The network name of the device"
)
signal_quality
:
str
=
Field
(
default
=
""
,
description
=
"The signal quality of the device"
)
firmware
:
dict
=
Field
(
default
=
{},
description
=
"The firmware details of the device"
)
app
:
dict
=
Field
(
default
=
{},
description
=
"The app details of device"
)
try_count
:
int
=
Field
(
default
=
0
,
description
=
"Try count details of device"
)
board_version
:
str
=
Field
(
default
=
""
,
description
=
"Board version of the device"
)
terminal
:
str
=
Field
(
default
=
""
,
description
=
"terminal url of the device"
)
translator.py
0 → 100644
View file @
28acb8fc
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment