예제 #1
0
def verify_db_tables(conn):
    try:
        verify_db_machine_state(conn)
        verify_db_table(conn, 'disk_results')
        verify_db_table(conn, 'job_results')
    except RqlRuntimeError:
        print("LocalDB: wanwipe database verified.")
예제 #2
0
def create_db(device, db_device):
    """Creates a document to update with progress_db.
    :param device: The device object
    :param db_device: The bare name of the device ('sda', 'sdb')
    """
    verify_db_table(conn, 'wipe_results')
    # Insert Data
    inserted = r.db('wanwipe').table('wipe_results').insert({
        'started_at': r.now(),
        'updated_at': r.now(),
        'boot_id': get_boot_id(),
        'machine_id': get_dbus_machine_id(),
        'ip': get_global_ip(),
        'device': device.device_node,
        'name': device.name,
        'model': device.model,
        'serial': device.serial_no,
        'wwn': device.wwn_id,
        'wwn_long': device.wwn_long,
        'finished': False,
        'completed': False,
        'bus_type': device.bus_type,
        'bus_path': device.bus_path,
        'bus_topology': device.bus_topology,
        'in_progress': True,
        'progress': "  0%",
        'progress_bar': "==============================",
        'time_elapsed': "0:00:00",
        'time_remaining': "0:00:00",
        'total_bytes': device.size,
        'read_bytes': 0,
        'read_megs': 0,
        'total_megs': (device.size / (1024 * 1024)),
        'long_info': "{}".format(device)
    }).run(conn)
    print("diskaction: LocalDB: Writing to key: {}".format(inserted['generated_keys'][0]))
    # noinspection PyUnusedLocal
    machine_updated = r.db('wanwipe').table('machine_state').get(machine_state_uuid).update({ 'disks': {
        db_device: {'available': False, 'busy': True, 'wipe_results': inserted['generated_keys'][0],
                    'updated_at': r.now()}},
        'updated_at': r.now()}).run(conn)  # Update the record timestamp.
    return inserted['generated_keys'][0]
예제 #3
0
import re

from simplejson import dumps

from datetime import datetime as dt

# RethinkDB imports
import rethinkdb as r
from rethinkdb.errors import RqlRuntimeError, RqlDriverError

from components.utils.basedb import connect_db, find_machine_state, verify_db_table, verify_db_index

db_conn = connect_db(None)

machine_state_uuid = find_machine_state(db_conn)  # Verifies DB Automatically.
verify_db_table(db_conn, "disks")
verify_db_index(db_conn, "disks", "serial_no")
print("LocalDB: DiskMonitor found a machine state: {}".format(machine_state_uuid))

from components.utils.hosttools import get_global_ip, get_boot_id, get_dbus_machine_id
from components.utils.disktools import get_disk_sdinfo, get_disk_serial
from components.utils.smarttools import get_disk_smart, get_disk_realtime_status

from dbus import Array, SystemBus, Interface
from dbus.exceptions import DBusException
from dbus.mainloop.glib import DBusGMainLoop
# noinspection PyUnresolvedReferences
from gi.repository import GObject, GLib

__all__ = ['UDisks2Observer', 'UDisks2Model', 'main_shield', 'Signal']
예제 #4
0
def verify_db_tables():
    try:
        verify_db_table(conn, 'wipe_results')
    except RqlRuntimeError:
        print("smart2json: LocalDB: wanwipe database verified.")