Exemplo n.º 1
0
"""
This script will load solutionInstanceComponent information.
"""
import logging
from lib import localstore
from lib import my_env
from lib import murcsrest

cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
lcl = localstore.sqliteUtils(cfg)
tablename = "solinstcomp"
logging.info("Handling table: {t}".format(t=tablename))

records = lcl.get_table(tablename)
my_loop = my_env.LoopInfo("Solution Instance Components", 20)
for trow in records:
    my_loop.info_loop()
    row = dict(trow)
    solInstId = row["solutionInstanceId"]
    softInstId = row["softwareInstanceId"]
    solId = row["solutionId"]
    serverId = row["serverId"].lower()
    softId = row["softwareId"]
    validFrom = row["validFrom"]
    if validFrom:
        mode = "FMO"
    else:
        mode = "CMO"
    r.add_solInstComp(solInstId=solInstId,
                      softInstId=softInstId,
Exemplo n.º 2
0
logging.info("Start Application")
ns = neostore.NeoStore(cfg)
vej_file = cfg["Main"]["vej_set"]
df = pandas.read_csv(vej_file)

node_arr = {}

# Collect all known parameter sets
param_nodes = ns.get_nodes()
for node in param_nodes:
    lbl = list(node.labels())[0]
    val = node["waarde"]
    param = "{l}={v}".format(l=lbl, v=val)
    node_arr[param] = node

my_loop = my_env.LoopInfo("Param entries", 20)
for row in df.iterrows():
    cnt = my_loop.info_loop()
    """
    if cnt > 10:
        break
    """
    # Get excel row in dict format
    xl = row[1].to_dict()
    # Check row only if urlquery is available
    urlquery = xl.pop("urlquery")
    if pandas.notnull(urlquery):
        query2process = urlquery[1:].lower()
        # Get node for Person
        person_id = str(xl["id"])
        try:
Exemplo n.º 3
0
"""
This script will load contact persons per server information.
"""
import logging
from lib import localstore
from lib import my_env
from lib import murcsrest

cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
lcl = localstore.sqliteUtils(cfg)
tablename = "contactserver"
logging.info("Handling table: {t}".format(t=tablename))

records = lcl.get_table(tablename)
my_loop = my_env.LoopInfo("Contact persons per server", 20)
for trow in records:
    my_loop.info_loop()
    # Get excel row in dict format
    row = dict(trow)
    email = row.pop("email")
    role = row.pop("role")
    serverId = row.pop("serverId").lower()
    r.add_server_contact(serverId, email, role)
cnt = my_loop.end_loop()
logging.info("End Application, {cnt} records processed.".format(cnt=cnt))
Exemplo n.º 4
0
from lib import my_env
from lib.murcs import *
from lib import murcsrest

# Configure command line arguments
parser = argparse.ArgumentParser(description="Load a Person file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the person file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("Persons", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    email = xl.pop("email")
    payload = dict(email=email)
    for k in xl:
        if pandas.notnull(xl[k]) and k not in excludedprops:
            payload[k] = xl[k]
    r.add_person(email, payload)
my_loop.end_loop()
Exemplo n.º 5
0
import pandas
from lib import my_env
from lib import murcsrest

# Configure command line arguments
parser = argparse.ArgumentParser(
    description="Load a Contact person per solution file into Murcs")
parser.add_argument(
    '-f',
    '--filename',
    type=str,
    required=True,
    help='Please provide the contact person per solution file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename, converters={'solId': str})
my_loop = my_env.LoopInfo("Contact persons per solution", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    email = xl.pop("email")
    role = xl.pop("role")
    solId = xl.pop("solId")
    r.add_solution_contact(solId, email, role)
my_loop.end_loop()
Exemplo n.º 6
0
    fields = fields_str + ", " + all_fields

    query = """
    SELECT {fields}
    FROM {table} t1
    LEFT JOIN server s2 ON s2.id = t1.parentServerId
    LEFT JOIN site ON site.id = t1.siteId
    INNER JOIN client ON client.id=t1.clientId
    WHERE client.clientId="{clientId}"
      AND t1.serverType = "VIRTUAL"
      AND t1.coreCount is not NULL;
    """.format(clientId=cfg["Murcs"]["clientId"], fields=fields, table=table)
    res = mdb.get_query(query)

    loop_info = my_env.LoopInfo("CoreCount", 20)
    for rec in res:
        serverId = rec["serverId"]
        payload = {}
        if rec["siteId"] is not None:
            payload["site"] = dict(siteId=rec["siteId"])
        if rec["parentServer"] is not None:
            payload["parentServer"] = dict(serverId=rec["parentServer"])
        for k in rec:
            # coreCount has been added to the ignore list so that it gets dropped.
            if (k not in ignore) and (rec[k] is not None):
                if k == "primaryIP":
                    payload["primaryIPAddress"] = rec[k]
                else:
                    payload[k] = rec[k]
        r.add_server(serverId=serverId, payload=payload)
Exemplo n.º 7
0
# Get vendors
query = "SELECT distinct softwareVendor from software"
res = lcl.get_query(query)
vendors = [rec["softwareVendor"] for rec in res]
vendor_d = {}
for vendor in vendors:
    if vendor:
        node_params = dict(
            name=vendor
        )
        vendor_d[vendor] = ns.create_node(lbl_vendor, **node_params)

softName_d = {}
# Now handle all lines
my_loop = my_env.LoopInfo("Soft", 20)
for trow in soft_recs:
    my_loop.info_loop()
    # Get excel row in dict format
    row = dict(trow)
    softName = row.pop("softwareName")
    softType = row.pop("softwareType")
    softSubType = row.pop("softwareSubType")
    try:
        soft_node = softName_d[softName]
    except KeyError:
        # Create soft node
        node_params = dict(
            name=softName,
            type=softType,
            subtype=softSubType
Exemplo n.º 8
0
from lib import neostore

ign_srv = ["changedAt", "changedBy", "createdAt", "createdBy", "version", "category", "classification",
           "currentApproach", "futureApproach", "hwModel", "managementRegion", "clientId", "osId", "softName",
           "softVersion", "softVendor", "softSubType", "OSDescription", "primaryIP"]

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
lcl = localstore.sqliteUtils(cfg)
ns = neostore.NeoStore(cfg)

servers = lcl.get_table("server")
parentServer_d = {}
siteId_d = {}
srv_node_d = {}
my_loop = my_env.LoopInfo("Servers", 20)
for trow in servers:
    # Get excel row in dict format
    row = dict(trow)
    # Get server links
    serverType = row.pop("serverType")
    parentServer = row.pop("parentServer")
    if parentServer:
        parentServer_d[row["serverId"]] = parentServer
    siteId = row.pop("siteId")
    if serverType == "PHYSICAL":
        # Remember SiteId only for physical servers.
        if siteId:
            siteId_d[row["serverId"]] = siteId
    # Server link information is handled and removed from row, now handle remaining columns
    node_params = {}
Exemplo n.º 9
0
    return sw_prod_node, f_row


if __name__ == "__main__":
    cfg = my_env.init_env("cmdb", __file__)
    # Get Neo4J Connetion and clean Database
    ns = NeoStore(cfg, refresh="Yes")
    # Get DataStore object
    ds = DataStore(cfg)
    # Initialize ci_type translation
    ci_type = ds.get_ci_type_translation()
    # Then get all Component rows
    rows = ds.get_components()
    node_obj = {}
    loc_obj = {}
    node_info = my_env.LoopInfo("Nodes", 100)
    for row in rows:
        del row["ID"]
        node_label, row = get_component_type(row, ci_type)

        # SW_PROD_INSTALL: Extract Producent - Product - Versie into product_node
        if node_label == 'SW_Prod_Install':
            # component = handle_sw_product(row)
            product_node, row = handle_sw_product(row)

        # Default component handling
        on_location, row = get_location(row)
        # Check for Producent en Product Nodes in System - OS description.
        if node_label in product_component_types:
            product_node, row = get_product_node(row)
        elif node_label != 'SW_Prod_Install':
Exemplo n.º 10
0
logging.info("Start Application")
db = cfg['Main']['db']
ds = sqliteUtils(cfg)

windir = cfg['Main']['windir']
for infotype in infotypes:
    file_ext = "_{t}.csv".format(t=infotype)
    table_name = "wintel_{t}".format(t=infotype)
    nr_fields = -1
    stats[infotype] = dict(ok=0, no_info=0, empty_file=0)
    # ds.create_table(table_name, row)
    filelist = [
        file for file in os.listdir(windir)
        if file[len(file) - len(file_ext):] == file_ext
    ]
    my_loop = my_env.LoopInfo(infotype, 20)
    for file in filelist:
        my_loop.info_loop()
        win_file = os.path.join(windir, file)
        # logging.info("Investigating file {fn} for table {tn}".format(fn=win_file, tn=table_name))
        with open(win_file, 'rb') as win_inv:
            win_reader_utf16 = win_inv.read()
            if len(win_reader_utf16) > 0:
                win_reader = win_reader_utf16.decode('utf-16')
                win_lines = win_reader.split('\r\n')
                if len(win_lines) > 2:
                    title = win_lines[1].split(',')
                    if nr_fields < 0:
                        nr_fields = ds.create_table(table_name, title)
                    if nr_fields == len(title):
                        for line in win_lines[2:]:
Exemplo n.º 11
0
# Configure command line arguments
parser = argparse.ArgumentParser(
    description="Load a Solution Property file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the solution property file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename, converters={'solutionId': str})
my_loop = my_env.LoopInfo("Solution Properties", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    solutionId = xl.pop("solutionId")
    payload = dict(solutionId=solutionId)
    for k in xl:
        if pandas.notnull(xl[k]) and k not in excludedprops:
            if k in fixedprops:
                payload[k] = fixedprops[k]
            elif k in srv_prop2dict:
                payload[srv_prop2dict[k][0]] = {srv_prop2dict[k][1]: xl[k]}
            else:
                payload[k] = xl[k]
    r.add_solution_property(solutionId, payload)
Exemplo n.º 12
0
"""
This script copies the required pictures to the public/original directory.
"""

import csv
import logging
import os
from lib import my_env, pcloud_handler

cfg = my_env.init_env("tuin_migrate", __file__)
pc = pcloud_handler.PcloudHandler(cfg)
logging.info('Start Application')
target_id = "3529968922"

fd = cfg['Main']['report_dir']
fn = 'one_match_list'
li = my_env.LoopInfo("Files handled", 50)
with open(os.path.join(fd, '{}.csv'.format(fn)), 'r', newline='') as csvfile:
    reader = csv.DictReader(csvfile)
    for row in reader:
        li.info_loop()
        file_id = row["pcloud_id"][1:]
        pc.copyfile(fileid=file_id, tofolderid=target_id)
li.end_loop()
Exemplo n.º 13
0
parser = argparse.ArgumentParser(description="Load a Server file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the software Instance file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

excludedprops.append("hostName")

# Read the file
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("Software Instance", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    softwareInstanceId = xl.pop("softwareInstanceId")
    xl["serverId"] = xl["serverId"].lower()
    payload = dict(softwareInstanceId=softwareInstanceId)
    for k in xl:
        if pandas.notnull(xl[k]) and k not in excludedprops:
            if k in softInst_prop2dict:
                payload[softInst_prop2dict[k][0]] = {
                    softInst_prop2dict[k][1]: xl[k]
                }
            else:
                payload[k] = xl[k]
Exemplo n.º 14
0
        type=str,
        required=True,
        help='Please provide the communication plan file to load.')
    args = parser.parse_args()
    cfg = my_env.init_env("bellavista", __file__)
    mdb = murcsstore.Murcs(cfg)
    r = murcsrest.MurcsRest(cfg)
    logging.info("Arguments: {a}".format(a=args))

    df = pandas.read_excel(args.filename, "Participants")
    add_people()
    # Collect contacts from MURCS. Add people/roles that are not in MURCS, remove people/roles in MURCS not in contact
    murcs_roles = murcs_roles()
    exc_roles = []
    p = re.compile("^\d{4}")
    my_loop = my_env.LoopInfo("Communication plan", 20)
    solId_arr = []
    for row in df.iterrows():
        my_loop.info_loop()
        xl = row[1].to_dict()
        email = xl["E-mail"]
        role = xl["Role"]
        if pandas.notnull(email) and pandas.notnull(role):
            app_list = xl["Application"]
            if pandas.notnull(app_list):
                for app in app_list.split(";"):
                    # Find Solution IDs in list column Application.
                    try:
                        solStr = p.search(app.strip()).group()
                    except AttributeError:
                        # SolID not found, ignore item in application list.
Exemplo n.º 15
0
iface_fields = ["duplex", "ifaceName", "macAddress", "negotiation", "netIfaceId", "speedMB"]

# Configure command line arguments
parser = argparse.ArgumentParser(
    description="Load the Network Information file into Murcs"
)
parser.add_argument('-f', '--filename', type=str, required=True,
                    help='Please provide the Network Information file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("Network Information", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    serverId = xl.pop("serverId").lower()
    interfaceId = xl.pop("networkInterfaceId")
    ipAddress = xl.pop("ipAddress")
    payload_if = dict(
        networkInterfaceId=interfaceId,
        serverId=serverId
    )
    payload_ip = dict(
        serverNetworkInterfaceId=interfaceId,
        ipAddress=ipAddress
    )
Exemplo n.º 16
0
query = """
SELECT distinct server.hostName as hostName, server.serverId as serverId, softinst.softwareInstanceId as instId
FROM softinst
INNER JOIN server on server.serverId = softinst.serverId
WHERE softinst.softwareInstanceId LIKE "{src}_%"
""".format(src=src_name)

res = lcl.get_query(query)
for rec in res:
    swinst_in_murcs.append(rec["instId"])
logging.info(
    "{c} Software Instances found in Murcs".format(c=len(swinst_in_murcs)))

# Read the ESL report to load/update software instances in MURCS.
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("ESL Interfaces", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    # Only handle systems from VPC.
    if xl["DC Name"] in dc_names:
        category = xl["Solution Category"]
        if pandas.notnull(category):
            if category in whitelist:
                my_loop.info_loop()
                serverId = fmo_serverId(xl["System Name"])
                legacy_serverId = 'VPC' + serverId[len('vpc'):]

                lbl = "{cat}|{name}|{version}".format(
                    cat=xl["Solution Category"],
Exemplo n.º 17
0
# Configure command line arguments
parser = argparse.ArgumentParser(
    description="Load a Server Property file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the server property file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("Server Properties", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    serverId = xl.pop("serverId").lower()
    payload = dict(serverId=serverId)
    for k in xl:
        if pandas.notnull(xl[k]) and k not in excludedprops:
            if k in fixedprops:
                payload[k] = fixedprops[k]
            elif k in srv_prop2dict:
                payload[srv_prop2dict[k][0]] = {srv_prop2dict[k][1]: xl[k]}
            else:
                payload[k] = xl[k]
    r.add_server_property(serverId, payload)
Exemplo n.º 18
0
    return


# Initialize Environment
projectname = "ansible"
config = my_env.init_env(projectname, __file__)
logging.info("Start application")
cmdb_json = os.getenv('JSONFILE')
ans = ansiblestore.SqliteUtils()

# Collect structure first: attributes related to tables, and how tables are linked to each other.
# Key is the unique table name, value is a list of dictionary attributes
struct_json = os.path.join(os.getenv('STRUCTDIR'), os.getenv('STRUCTFILE'))
with open(struct_json) as struct_file:
    data = json.loads(struct_file.read())

linked_tables = data['tables']
attribs_table = data['attribs']

with open(cmdb_json) as cmdb_file:
    data = json.loads(cmdb_file.read())
    li = my_env.LoopInfo('Servers', 20)
    # Create Server Node
    t_name = 'server'
    for item in data:
        li.info_loop()
        logging.info(f"Working on server {item}")
        handle_dict(data[item], t_name)
    li.end_loop()
logging.info("End Application")
import pandas
from lib import my_env
from lib import murcsrest

if __name__ == "__main__":
    # Configure command line arguments
    parser = argparse.ArgumentParser(
        description="File to process into Murcs"
    )
    parser.add_argument('-f', '--filename', type=str, required=True,
                        help='Please provide the file to load.')
    args = parser.parse_args()
    cfg = my_env.init_env("bellavista", __file__)
    r = murcsrest.MurcsRest(cfg)
    logging.info("Arguments: {a}".format(a=args))

    # Read the file
    df = pandas.read_excel(args.filename)
    my_loop = my_env.LoopInfo("Servers", 20)
    for row in df.iterrows():
        my_loop.info_loop()
        # Get excel row in dict format
        xl = row[1].to_dict()
        solId = xl["solId"]
        solInstId = xl["solInstId"]
        personId = xl["email"]
        role = xl["role"]
        r.remove_solComp_contact(solId, solInstId, personId, role)
        r.add_solution_contact(solId, personId, role)
    my_loop.end_loop()
Exemplo n.º 20
0
from lib import my_env
from lib import mysqlstore as drupal
from lib import tuin_store
from lib.tuin_store import *

cfg = my_env.init_env("tuin_migrate", __file__)
db = cfg['Main']['db']
logging.info("Start application")
ds = drupal.DirectConn(cfg)
tuin = tuin_store.init_session(db=db)
parents = ds.get_parent_for_node()
rev_cnt = ds.get_rev_cnt()

node_info = ds.get_node_info()
pg_info = my_env.LoopInfo("Handle Node", 500)
for rec in node_info:
    pg_info.info_loop()
    if rec['nid'] in parents:
        parent_id = parents[rec['nid']]
    else:
        parent_id = -1
    node = Node(id=rec['nid'],
                parent_id=parent_id,
                created=rec['created'],
                modified=rec['changed'],
                revcnt=rev_cnt[rec['nid']],
                type=rec['type'])
    tuin.add(node)
    content = Content(node_id=rec['nid'],
                      title=rec['title'],
                      body=rec['body_value'])
Exemplo n.º 21
0
# Relations
server2wave = "serverInWave"

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
ns = neostore.NeoStore(cfg)
query = """
    MATCH (wave:Wave)<-[:inWave]-(sol),
    (sol)<-[:fromSolution]-(solComp),
    (solComp)<-[:toComponent]-(instComp),
    (instComp)-[:toInstance]-(inst),
    (inst)<-[:serverInst]-(server)
    return wave, sol, solComp, instComp, inst, server
"""
cursor = ns.get_query(query)
my_loop = my_env.LoopInfo("Server in Wave", 20)
while cursor.forward():
    my_loop.info_loop()
    rec = cursor.current()
    server_node = rec["server"]
    wave_node = rec["wave"]
    ns.create_relation(from_node=server_node,
                       rel=server2wave,
                       to_node=wave_node)
my_loop.end_loop()
"""
query =
match (s:Server)-[r:serverInWave]->()
with s, count(r) as rel_cnt
match (s)-[:serverInWave]->(wave)
where rel_cnt > 1
Exemplo n.º 22
0
cfg = my_env.init_env("tuin_migrate", __file__)
db = cfg['Main']['db']
logging.info('Start Application')
tuindb = localstore.SqliteUtils(cfg['Main']['tuindb'])
pclouddb = localstore.SqliteUtils(cfg['Main']['pclouddb'])

# Get distinct filenames from tuindb.flickrdetails
query = "SELECT distinct(title) FROM flickrdetails"
res = tuindb.get_query(query)
titles = [rec['title'] for rec in res]

no_match = []
one_match = {}
multi_match = {}
# Find each title in pclouddb
cnt = my_env.LoopInfo("Titles", 50)
for title in titles:
    cnt.info_loop()
    query = """
    SELECT name, contenttype, path, size, pcloud_id
    FROM files 
    WHERE name like '{}.%'
      AND (path like '%tuin%' OR path like '%Motorola%')
    """.format(title)
    res = pclouddb.get_query(query)
    if len(res) == 0:
        no_match.append(title)
    elif len(res) == 1:
        one_match[title] = res[0]
    else:
        multi_match[title] = [rec for rec in res]
Exemplo n.º 23
0
    sw_tx = {}
    bv_tx_file = cfg["Main"]["translate"]
    df = pandas.read_excel(bv_tx_file, sheet_name="os")
    for row in df.iterrows():
        xl = row[1].to_dict()
        sw_tx[xl["BellaVistaOs"]] = xl["softId"]

    # Add BellaVista to softId translation
    df = pandas.read_excel(bv_tx_file, sheet_name="sw")
    for row in df.iterrows():
        xl = row[1].to_dict()
        sw_tx[xl["BellaVistaSw"]] = xl["softId"]

    # Read the runbook
    df = pandas.read_excel(args.filename, sheet_name="Server Order", header=1)
    my_loop = my_env.LoopInfo("Runbook", 20)
    for row in df.iterrows():
        my_loop.info_loop()
        # Get excel row in dict format
        xl = row[1].to_dict()
        servername = xl.pop("Server Name")
        if pandas.isnull(servername):
            break

        # Add Server
        serverId = my_env.fmo_serverId(servername)
        payload = dict(serverId=serverId,
                       hostName=serverId,
                       category="Server",
                       classification="Server",
                       hwModel=xl["Server Sizing"].strip(),
Exemplo n.º 24
0
import pandas
from lib import my_env
from lib import murcsrest

# Configure command line arguments
parser = argparse.ArgumentParser(description="Load a Site file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the site file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename)
my_loop = my_env.LoopInfo("Sites", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    siteId = xl.pop("siteId")
    payload = dict(siteId=siteId)
    for k in xl:
        if pandas.notnull(xl[k]):
            payload[k] = xl[k]
    r.add_site(siteId, payload)
my_loop.end_loop()
Exemplo n.º 25
0
SolutionToSolution.__table__.create(bind=engine)
try:
    Solution.__table__.drop(bind=engine)
except:
    pass
Solution.__table__.create(bind=engine)
# First handle solutions
wb = load_workbook(cfg['Main']['solutions'], read_only=True)
sheet = wb['Sheet1']
# Get worksheet data as a list of rows
row_list = list(sheet.rows)
# Get title row in a named row (nr) to handle all data rows as dictionaries
title_row = row_list.pop(0)
nr = my_env.get_named_row("solutions", title_row)
# Then handle each record in the sheet
loop = my_env.LoopInfo("solutions", 25)
for row in map(nr._make, row_list):
    loop.info_loop()
    sol = Solution(solId=row.solId.value,
                   name=row.solName.value,
                   comment=row.comment.value,
                   complexity=row.complexity.value,
                   inScope=row.inScope.value,
                   origin=row.origin.value,
                   customerBusinessUnit=row.customerBusinessUnit.value,
                   customerBusinessDivision=row.customerBusinessDivision.value,
                   supportBusinessUnit=row.supportBusinessUnit.value,
                   supportBusinessDivision=row.supportBusinessDivision.value,
                   longDescription=row.longDescription.value,
                   description=row.description.value,
                   applicationTreatment=row.applicationTreatment.value,
Exemplo n.º 26
0
ignore = excludedprops + ["solId_nr"]

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
ns = neostore.NeoStore(cfg)
lcl = localstore.sqliteUtils(cfg)

# Get solutions
solution_nodes = ns.get_nodes(lbl_solution)
solution_d = {}
for node in solution_nodes:
    solution_d[node["solutionId"]] = node

sol2sol_recs = lcl.get_table("soltosol")
my_loop = my_env.LoopInfo("Sol2sol", 20)
for trow in sol2sol_recs:
    # Get excel row in dict format
    xl = dict(trow)
    # Get solution node
    fromSolId = xl.pop("fromSolutionId")
    from_sol_node = solution_d[str(fromSolId)]
    toSolId = xl.pop("toSolutionId")
    to_sol_node = solution_d[str(toSolId)]
    direction = xl.pop("connectionDirection")
    if direction != "T2S":
        ns.create_relation(from_node=from_sol_node,
                           rel=solution2solution,
                           to_node=to_sol_node)
    if direction != "S2T":
        ns.create_relation(from_node=to_sol_node,
Exemplo n.º 27
0
# Configure command line arguments
parser = argparse.ArgumentParser(description="Load a Solution file into Murcs")
parser.add_argument('-f',
                    '--filename',
                    type=str,
                    required=True,
                    help='Please provide the solution file to load.')
args = parser.parse_args()
cfg = my_env.init_env("bellavista", __file__)
r = murcsrest.MurcsRest(cfg)
logging.info("Arguments: {a}".format(a=args))

# Read the file
df = pandas.read_excel(args.filename, converters={'solutionId': str})
my_loop = my_env.LoopInfo("Solution", 20)
for row in df.iterrows():
    my_loop.info_loop()
    # Get excel row in dict format
    xl = row[1].to_dict()
    solutionId = xl.pop("solutionId")
    payload = dict(solutionId=solutionId)
    for k in xl:
        if pandas.notnull(xl[k]) and k not in excludedprops:
            if k in fixedprops:
                payload[k] = fixedprops[k]
            else:
                payload[k] = xl[k]
    r.add_sol(solutionId, payload)
my_loop.end_loop()
Exemplo n.º 28
0
    parser.add_argument('-f',
                        '--filename',
                        type=str,
                        required=True,
                        help='Please provide the file with Server info..')
    args = parser.parse_args()
    cfg = my_env.init_env("bellavista", __file__)
    mdb = murcsstore.Murcs(cfg)
    r = murcsrest.MurcsRest(cfg)
    logging.info("Arguments: {a}".format(a=args))

    csv.register_dialect('tabdelim', delimiter='\t')
    with open(args.filename, newline='\r\n') as f:
        reader = csv.DictReader(f, dialect='tabdelim')

        my_loop = my_env.LoopInfo("VMWare List", 20)
        for line in reader:
            my_loop.info_loop()
            serverId = line["Name"]
            server_rec = mdb.get_server_from_serverId(serverId)
            if server_rec:
                if str(server_rec["cpuCount"]) != line["CPUs"]:
                    # Update record only if cpuCount is changed.
                    payload = {}
                    if server_rec["siteId"] is not None:
                        siteId = mdb.get_name_id("site", "siteId",
                                                 server_rec["siteId"])
                        if siteId:
                            payload["site"] = dict(siteId=siteId)
                        else:
                            logging.fatal(
Exemplo n.º 29
0
# First write header lines
nf = os.path.join(import_dir, "node_persons_1.csv")
ef = os.path.join(import_dir, "rel_contacts_1.csv")
nhl = "name:ID{delim}:LABEL".format(delim=my_env.delim)
rhl = ":START_ID{delim}:END_ID{delim}:TYPE{delim}weight:INT".format(
    delim=my_env.delim)

nfh = open(nf, "w")
nfh.write(nhl)
nfh.close()

rfh = open(ef, "w")
rfh.write(rhl)
rfh.close()

li = my_env.LoopInfo("Nodes", 1000)
nodes = ""
for node in g.nodes():
    li.info_loop()
    nodes += '"{node}"{delim}Person\n'.format(node=node, delim=my_env.delim)
li.end_loop()

li = my_env.LoopInfo("Relations", 1000)
rels = ""
for rel in g.edges(data=True):
    li.info_loop()
    (sn, en, edata) = rel
    # weight = g.get_edge_data(sn, en)[0]["weight"]
    weight = int(edata["weight"])
    rels += '"{sn}"{delim}"{en}"{delim}contacts{delim}{weight}\n'.format(
        delim=my_env.delim, sn=sn, en=en, weight=weight)
Exemplo n.º 30
0

field_list = ["from_server", "relationship", "counter", "to_servers"]

cfg = my_env.init_env("bellavista", __file__)
logging.info("Start Application")
db = cfg['Main']['db']
ds, engine = localstore.init_session(db=db)
comm_file = cfg['Main']['server2server']
with open(comm_file, newline='') as comm_inv:
    # delimiter defaults to , - quotechar defaults to "
    comm_reader = csv.reader(comm_inv)
    # Skip first 2 lines
    next(comm_reader)
    next(comm_reader)
    loop = my_env.LoopInfo("ServerToServer", 10)
    for row in comm_reader:
        loop.info_loop()
        line = {}
        if len(row) == 4:
            for cnt in range(len(row)):
                line[field_list[cnt]] = row[cnt]
            from_server_id = handle_server(line["from_server"])
            [commtype, port] = line["relationship"].split(":")
            for to_server in line["to_servers"].split(","):
                to_server_id = handle_server(to_server)
                comm = ServerToServer(from_server_id=from_server_id,
                                      to_server_id=to_server_id,
                                      commType=commtype,
                                      port=port)
                ds.add(comm)