mirror of
https://github.com/itsdave-de/msp.git
synced 2025-05-06 07:25:13 +02:00
urbaxkup wip
This commit is contained in:
parent
9d81f13cf6
commit
eed95e596f
0
msp/msp/doctype/msp_report/__init__.py
Normal file
0
msp/msp/doctype/msp_report/__init__.py
Normal file
8
msp/msp/doctype/msp_report/msp_report.js
Normal file
8
msp/msp/doctype/msp_report/msp_report.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('MSP Report', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
75
msp/msp/doctype/msp_report/msp_report.json
Normal file
75
msp/msp/doctype/msp_report/msp_report.json
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "MSPREP-.#####",
|
||||||
|
"creation": "2022-12-14 20:33:18.124149",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"report_generation",
|
||||||
|
"period",
|
||||||
|
"report_content",
|
||||||
|
"report_module",
|
||||||
|
"customer",
|
||||||
|
"landscape"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "report_generation",
|
||||||
|
"fieldtype": "Datetime",
|
||||||
|
"label": "Report Generation"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "period",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Period"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "report_content",
|
||||||
|
"fieldtype": "Text Editor",
|
||||||
|
"label": "Report Content"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "report_module",
|
||||||
|
"fieldtype": "Select",
|
||||||
|
"label": "Report Module",
|
||||||
|
"options": "urbackup"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer",
|
||||||
|
"options": "Customer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "landscape",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Landscape",
|
||||||
|
"options": "IT Landscape"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-12-14 20:35:01.430039",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "MSP Report",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC"
|
||||||
|
}
|
8
msp/msp/doctype/msp_report/msp_report.py
Normal file
8
msp/msp/doctype/msp_report/msp_report.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class MSPReport(Document):
|
||||||
|
pass
|
8
msp/msp/doctype/msp_report/test_msp_report.py
Normal file
8
msp/msp/doctype/msp_report/test_msp_report.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestMSPReport(unittest.TestCase):
|
||||||
|
pass
|
0
msp/msp/doctype/urbackup_client/__init__.py
Normal file
0
msp/msp/doctype/urbackup_client/__init__.py
Normal file
8
msp/msp/doctype/urbackup_client/test_urbackup_client.py
Normal file
8
msp/msp/doctype/urbackup_client/test_urbackup_client.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestUrBackupClient(unittest.TestCase):
|
||||||
|
pass
|
8
msp/msp/doctype/urbackup_client/urbackup_client.js
Normal file
8
msp/msp/doctype/urbackup_client/urbackup_client.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('UrBackup Client', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
193
msp/msp/doctype/urbackup_client/urbackup_client.json
Normal file
193
msp/msp/doctype/urbackup_client/urbackup_client.json
Normal file
@ -0,0 +1,193 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "URBACKCL-.#####",
|
||||||
|
"creation": "2022-12-14 20:43:01.256112",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"it_object",
|
||||||
|
"customer",
|
||||||
|
"landscape",
|
||||||
|
"urbackup_instance",
|
||||||
|
"client_name",
|
||||||
|
"urbackup_client_data_section",
|
||||||
|
"client_version_string",
|
||||||
|
"delete_pending",
|
||||||
|
"file_ok",
|
||||||
|
"groupname",
|
||||||
|
"id",
|
||||||
|
"image_ok",
|
||||||
|
"ip",
|
||||||
|
"last_filebackup_issues",
|
||||||
|
"lastbackup",
|
||||||
|
"lastbackup_image",
|
||||||
|
"lastseen",
|
||||||
|
"online",
|
||||||
|
"os_simple",
|
||||||
|
"os_version_string",
|
||||||
|
"processes",
|
||||||
|
"client_status",
|
||||||
|
"image_disabled"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "client_name",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Client Name"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "customer",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "Customer",
|
||||||
|
"options": "Customer"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "landscape",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Landscape",
|
||||||
|
"options": "IT Landscape"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "urbackup_instance",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"label": "UrBackup Instance",
|
||||||
|
"options": "UrBackup Instance"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "urbackup_client_data_section",
|
||||||
|
"fieldtype": "Section Break",
|
||||||
|
"label": "UrBackup Client Data"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "client_version_string",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Client Version String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "delete_pending",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Delete Pending"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "file_ok",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "File OK"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "groupname",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Groupname"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "id",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "ID"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "image_ok",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Image OK"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "ip",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "IP"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "last_filebackup_issues",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Last Filebackup Issues"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lastbackup",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Lastbackup"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lastbackup_image",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Lastbackup Image"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "lastseen",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Lastseen"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "it_object",
|
||||||
|
"fieldtype": "Link",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "IT Object",
|
||||||
|
"options": "IT Object"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"default": "0",
|
||||||
|
"fieldname": "online",
|
||||||
|
"fieldtype": "Check",
|
||||||
|
"in_list_view": 1,
|
||||||
|
"in_standard_filter": 1,
|
||||||
|
"label": "Online"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "os_simple",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "OS Simple"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "os_version_string",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "OS Version String"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "processes",
|
||||||
|
"fieldtype": "Long Text",
|
||||||
|
"label": "Processes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "client_status",
|
||||||
|
"fieldtype": "Int",
|
||||||
|
"label": "Client Status"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "image_disabled",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Image Disabled"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-12-14 22:47:53.540884",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "UrBackup Client",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC"
|
||||||
|
}
|
8
msp/msp/doctype/urbackup_client/urbackup_client.py
Normal file
8
msp/msp/doctype/urbackup_client/urbackup_client.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
from frappe.model.document import Document
|
||||||
|
|
||||||
|
class UrBackupClient(Document):
|
||||||
|
pass
|
0
msp/msp/doctype/urbackup_instance/__init__.py
Normal file
0
msp/msp/doctype/urbackup_instance/__init__.py
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and Contributors
|
||||||
|
# See license.txt
|
||||||
|
|
||||||
|
# import frappe
|
||||||
|
import unittest
|
||||||
|
|
||||||
|
class TestUrBackupInstance(unittest.TestCase):
|
||||||
|
pass
|
8
msp/msp/doctype/urbackup_instance/urbackup_instance.js
Normal file
8
msp/msp/doctype/urbackup_instance/urbackup_instance.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
// Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
// For license information, please see license.txt
|
||||||
|
|
||||||
|
frappe.ui.form.on('UrBackup Instance', {
|
||||||
|
// refresh: function(frm) {
|
||||||
|
|
||||||
|
// }
|
||||||
|
});
|
61
msp/msp/doctype/urbackup_instance/urbackup_instance.json
Normal file
61
msp/msp/doctype/urbackup_instance/urbackup_instance.json
Normal file
@ -0,0 +1,61 @@
|
|||||||
|
{
|
||||||
|
"actions": [],
|
||||||
|
"allow_rename": 1,
|
||||||
|
"autoname": "URBACK-.#####",
|
||||||
|
"creation": "2022-12-14 20:40:21.525094",
|
||||||
|
"doctype": "DocType",
|
||||||
|
"editable_grid": 1,
|
||||||
|
"engine": "InnoDB",
|
||||||
|
"field_order": [
|
||||||
|
"address",
|
||||||
|
"user",
|
||||||
|
"password",
|
||||||
|
"import_clients"
|
||||||
|
],
|
||||||
|
"fields": [
|
||||||
|
{
|
||||||
|
"fieldname": "address",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "Address"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "user",
|
||||||
|
"fieldtype": "Data",
|
||||||
|
"label": "User"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "password",
|
||||||
|
"fieldtype": "Password",
|
||||||
|
"label": "Password"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"fieldname": "import_clients",
|
||||||
|
"fieldtype": "Button",
|
||||||
|
"label": "Import Clients",
|
||||||
|
"options": "import_clients"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"index_web_pages_for_search": 1,
|
||||||
|
"links": [],
|
||||||
|
"modified": "2022-12-14 21:05:51.257205",
|
||||||
|
"modified_by": "Administrator",
|
||||||
|
"module": "MSP",
|
||||||
|
"name": "UrBackup Instance",
|
||||||
|
"owner": "Administrator",
|
||||||
|
"permissions": [
|
||||||
|
{
|
||||||
|
"create": 1,
|
||||||
|
"delete": 1,
|
||||||
|
"email": 1,
|
||||||
|
"export": 1,
|
||||||
|
"print": 1,
|
||||||
|
"read": 1,
|
||||||
|
"report": 1,
|
||||||
|
"role": "System Manager",
|
||||||
|
"share": 1,
|
||||||
|
"write": 1
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"sort_field": "modified",
|
||||||
|
"sort_order": "DESC"
|
||||||
|
}
|
73
msp/msp/doctype/urbackup_instance/urbackup_instance.py
Normal file
73
msp/msp/doctype/urbackup_instance/urbackup_instance.py
Normal file
@ -0,0 +1,73 @@
|
|||||||
|
# Copyright (c) 2022, itsdave GmbH and contributors
|
||||||
|
# For license information, please see license.txt
|
||||||
|
|
||||||
|
import frappe
|
||||||
|
import urbackup_api
|
||||||
|
from frappe.model.document import Document
|
||||||
|
from pprint import pprint
|
||||||
|
from json import dumps
|
||||||
|
|
||||||
|
class UrBackupInstance(Document):
|
||||||
|
@frappe.whitelist()
|
||||||
|
def import_clients(self):
|
||||||
|
server = urbackup_api.urbackup_server(self.address, self.user, self.get_password())
|
||||||
|
clients = server.get_status()
|
||||||
|
if not clients:
|
||||||
|
frappe.throw("No Data Returned. Check credentials and connectivity to address.")
|
||||||
|
|
||||||
|
existing_clients = self._get_existing_clients()
|
||||||
|
|
||||||
|
for client in clients:
|
||||||
|
client_dict = self._get_client_dict(client)
|
||||||
|
if str(client["name"]).lower() in existing_clients:
|
||||||
|
print(str(client["name"]).lower() + " allready exists")
|
||||||
|
self._check_for_client_update(client_dict)
|
||||||
|
client_status = server.get_clientbackups(client["id"])
|
||||||
|
pprint(client_status)
|
||||||
|
|
||||||
|
continue
|
||||||
|
|
||||||
|
client_doc = frappe.get_doc(client_dict)
|
||||||
|
client_doc.insert()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def _get_existing_clients(self):
|
||||||
|
client_list = []
|
||||||
|
existing_clients = frappe.get_all("UrBackup Client", filters={"urbackup_instance": self.name}, fields=["client_name"])
|
||||||
|
for ec in existing_clients:
|
||||||
|
client_list.append(str(ec["client_name"]).lower())
|
||||||
|
return client_list
|
||||||
|
|
||||||
|
def _get_client_dict(self, client):
|
||||||
|
client["processes"] = dumps(client["processes"])
|
||||||
|
client_dict = {
|
||||||
|
"doctype": "UrBackup Client",
|
||||||
|
"client_name": str(client["name"]).lower(),
|
||||||
|
"urbackup_instance": self.name,
|
||||||
|
"client_status": client["status"],
|
||||||
|
**client
|
||||||
|
}
|
||||||
|
return client_dict
|
||||||
|
|
||||||
|
def _check_for_client_update(self, client_dict):
|
||||||
|
clients_for_name = frappe.get_all("UrBackup Client", filters={"client_name": client_dict["client_name"]})
|
||||||
|
if len(clients_for_name) != 1:
|
||||||
|
frappe.throw("Multiple Clients found for Client Name: " + str(client_dict["client_name"]))
|
||||||
|
name = clients_for_name[0]["name"]
|
||||||
|
existing_client_doc = frappe.get_doc("UrBackup Client", name)
|
||||||
|
for k in client_dict.keys():
|
||||||
|
if k in ("doctype", "client_name", "urbackup_instance", "name"):
|
||||||
|
continue
|
||||||
|
if isinstance(client_dict[k], bool):
|
||||||
|
client_dict[k] = 1 if client_dict[k] == True else 0
|
||||||
|
if k == "status":
|
||||||
|
k = "client_status"
|
||||||
|
|
||||||
|
old = client_dict[k]
|
||||||
|
new = getattr(existing_client_doc, k)
|
||||||
|
|
||||||
|
if new != old:
|
||||||
|
print("change found for " + k + ": old=" + str(old) + " new=" + str(new))
|
||||||
|
|
||||||
|
|
@ -1,3 +1,4 @@
|
|||||||
frappe
|
frappe
|
||||||
ipaddress
|
ipaddress
|
||||||
passwordgenerator
|
passwordgenerator
|
||||||
|
urbackup-server-web-api-wrapper
|
||||||
|
Loading…
x
Reference in New Issue
Block a user