Update CMDB2CSV_Aufbaumaster.py

This commit is contained in:
2024-10-23 09:56:17 +00:00
parent 1407f27dd1
commit d56e46b390

View File

@@ -69,36 +69,33 @@ class MainUI(QDialog): # erbt von QDialog
# Einfügen von Spalten in die CMDB-Tabelle
self.dfb = self.df_vte.merge(self.df_cmdb, on=['Hostname'], how='left')
# Zeile einfügen für HE
self.dfb.insert(loc=11, column='HE', value='')
# Spalte für Segmente
self.dfb.insert(loc=8, column='Segment', value='')
# Spalte für Domains
self.dfb.insert(loc=9, column='Domain', value='')
# Spalte einfügen für HE
self.dfb.insert(loc=13, column='HE', value='')
# Führende Leerzeichen in allen Spalten entfernen
self.dfb = self.dfb.apply(lambda x: x.str.lstrip() if x.dtype == "object" else x)
self.dfb = self.dfb.apply(self.prüfe_und_setze_wert, axis=1)
# Setzen von int für HE und Anz. HE
self.dfb['HE'] = self.dfb['HE'].apply(lambda x: x if pd.isnull(x) else str(int(x)))
self.dfb['belegte\nHE'] = self.dfb['belegte\nHE'].apply(lambda x: x if pd.isnull(x) else str(int(x)))
#self.dfb = self.dfb.T.drop_duplicates().T
# self.dfb = self.dfb.drop(columns=['Bestelldatum_y','Hersteller_y','Lieferant_y','RAM_y','SAP-Nr._y'])
# self.dfb = self.dfb.rename(columns={'Bestelldatum_x':'Bestelldatum','Hersteller_x':'Hersteller','Lieferant_x':'Lieferant'})
# ic(self.df_cmdb)
# Zusammenfassen aller geänderten Werte
# Wenn Gruppierung nicht ausgewählt wurde, muss es separat ausgelesen werden
#self.changegroup()
#ic(self.changegroup())
#self.changegtyp()
#ic(self.changegtyp())
#if self.filter: # Wenn True dann nur mit Hostnamen
# print("Filter ", self.filter)
#ic(self.filter)
def prüfe_und_setze_wert(self, zeile):
ic(zeile)
# Fehlerbereinigung
if zeile['ID\nStandort'] not in ("Ber-PS","Bon-BTW"):
print("Kein Standort P40 oder BTW")
sys.exit(0)
@@ -119,6 +116,156 @@ class MainUI(QDialog): # erbt von QDialog
zeile['Hersteller'] = "Digi International Inc."
else:
pass
################################################################
if zeile['Hostname'][4:6] == "10":
zeile['ID\nMandanten'] = 'm10 CMP Plattform / iM.0 / iM.4 / PAP sIMCP'
elif zeile['Hostname'][4:6] == "19":
zeile['ID\nMandanten'] = 'm19 Testumgebung'
elif zeile['Hostname'][4:6] == "20":
zeile['ID\nMandanten'] = 'm20 iM.1 Interner Mandant (Schutzbedarf sehr hoch)'
elif zeile['Hostname'][4:6] == "21":
zeile['ID\nMandanten'] = 'm21 iM.2 Interner Mandant (Schutzbedarf normal)'
elif zeile['Hostname'][4:6] == "22":
zeile['ID\nMandanten'] = 'm22 iM.3 Interner Mandant (Schutzbedarf hoch)'
elif zeile['Hostname'][4:6] == "50":
zeile['ID\nMandanten'] = 'm50 sEMCP.Instanz-1 (CMP Zentral)'
elif zeile['Hostname'][4:6] == "51":
zeile['ID\nMandanten'] = 'm51 Classified OPS'
elif zeile['Hostname'][4:6] == "73":
zeile['ID\nMandanten'] = 'm73 FWP Lüftersteuerung'
elif zeile['Hostname'][4:6] == "75":
zeile['ID\nMandanten'] = 'm75 Fawkes'
elif zeile['Hostname'][4:6] == "76":
zeile['ID\nMandanten'] = 'm76 Demo'
elif zeile['Hostname'][4:6] == "77":
zeile['ID\nMandanten'] = 'm77 Fritz54 '
elif zeile['Hostname'][4:6] == "78":
zeile['ID\nMandanten'] = 'm78 ITZBund mSBC'
elif zeile['Hostname'][4:6] == "79":
zeile['ID\nMandanten'] = 'm79 BOS-Spur'
elif zeile['Hostname'][4:6] == "99":
zeile['ID\nMandanten'] = 'm99 Releasemanagement'
elif zeile['Hostname'][4:6] == "80":
zeile['ID\nMandanten'] = 'm80 ACDC'
################################################################
if zeile['Hostname'][6:8] == "00":
zeile['Segment'] = 'm10 mgmt CMP Core'
elif zeile['Hostname'][6:8] == "01":
zeile['Segment'] = 'm10 mgmt Infrastructure'
elif zeile['Hostname'][6:8] == "02":
zeile['Segment'] = 'm10 mgmt Administration'
elif zeile['Hostname'][6:8] == "03":
zeile['Segment'] = 'm10 mgmt zLightsOut'
elif zeile['Hostname'][6:8] == "04":
zeile['Segment'] = 'm10 CTS'
elif zeile['Hostname'][6:8] == "05":
zeile['Segment'] = 'm10-OSS'
elif zeile['Hostname'][6:8] == "10":
zeile['Segment'] = 'm10 CMP2sIM'
elif zeile['Hostname'][6:8] == "11":
zeile['Segment'] = 'm10 Intern-CMP iM0'
elif zeile['Hostname'][6:8] == "12":
zeile['Segment'] = 'm20 iM.1 Interner Mandant 1 (SB sehr hoch)'
elif zeile['Hostname'][6:8] == "13":
zeile['Segment'] = 'm21 iM.2 Interner Mandant 2 (SB normal)'
elif zeile['Hostname'][6:8] == "14":
zeile['Segment'] = 'm22 iM.3 Interner Mandant 3 (SB hoch)'
elif zeile['Hostname'][6:8] == "15":
zeile['Segment'] = 'm10 iM.4 Interner Mandant 4 (CNMS2CMP)'
elif zeile['Hostname'][6:8] == "20":
zeile['Segment'] = 'VRD-Plattform (PAP-Anbindung)'
elif zeile['Hostname'][6:8] == "21":
zeile['Segment'] = 'VRD-Plattform (LightsOut + Basisinfrastruktur + Cache)'
elif zeile['Hostname'][6:8] == "22":
zeile['Segment'] = 'VRD-Plattform (Admin)'
elif zeile['Hostname'][6:8] == "23":
zeile['Segment'] = 'VRD-Plattform (Basisinfrastruktur Mandant zentral)'
elif zeile['Hostname'][6:8] == "24":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "25":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "26":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "27":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "28":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "29":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "30":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "31":
zeile['Segment'] = 'VRD-Mandant (Infrastruktur)'
elif zeile['Hostname'][6:8] == "32":
zeile['Segment'] = 'VRD-Mandant (Admin)'
elif zeile['Hostname'][6:8] == "33":
zeile['Segment'] = 'VRD-Mandant (Anbindung)'
elif zeile['Hostname'][6:8] == "34":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "35":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "36":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "37":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "38":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "39":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "40":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "41":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "42":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "43":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "44":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "45":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "46":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "47":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "48":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "49":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "50":
zeile['Segment'] = 'Spare'
elif zeile['Hostname'][6:8] == "51":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Infra)'
elif zeile['Hostname'][6:8] == "52":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Admin)'
elif zeile['Hostname'][6:8] == "53":
zeile['Segment'] = 'VRD-Mandant (Kundensegment)'
elif zeile['Hostname'][6:8] == "b0":
zeile['Segment'] = 'mgmt BS Übergang zum CMP Core'
elif zeile['Hostname'][6:8] == "ba":
zeile['Segment'] = 'mgmt BS Bon BTW'
elif zeile['Hostname'][6:8] == "bb":
zeile['Segment'] = 'mgmt BS Bon LRS'
elif zeile['Hostname'][6:8] == "bc":
zeile['Segment'] = 'mgmt BS Ber W55'
elif zeile['Hostname'][6:8] == "bd":
zeile['Segment'] = 'mgmt BS Ber PS'
elif zeile['Hostname'][6:8] == "be":
zeile['Segment'] = 'mgmt BS Ber NDA'
elif zeile['Hostname'][6:8] == "bf":
zeile['Segment'] = 'mgmt BS HanTMX'
elif zeile['Hostname'][6:8] == "bg":
zeile['Segment'] = 'mgmt BS Ber DS'
elif zeile['Hostname'][6:8] == "c0":
zeile['Segment'] = 'mgmt CMP Übergang Internet'
elif zeile['Hostname'][6:8] == "x1":
zeile['Segment'] = 'm10 SecA2sIM'
################################################################
return zeile
@@ -202,155 +349,6 @@ class MainUI(QDialog): # erbt von QDialog
# #return id.get( key= "Hostname")
# pass
""" def prüfe_und_setze_wert(self, zeile):
#ic(zeile)
if zeile['Mandanten ID'][4:6] == "10": # Indexe 4 und 5 entsprechen den Stellen 5 und 6
zeile['Mandanten ID'] = 'm10 CMP Plattform / iM.0 / iM.4 / PAP sIMCP'
elif zeile['Mandanten ID'][4:6] == "19":
zeile['Mandanten ID'] = 'm19 Testumgebung'
elif zeile['Mandanten ID'][4:6] == "20":
zeile['Mandanten ID'] = 'm20 iM.1 Interner Mandant (Schutzbedarf sehr hoch)'
elif zeile['Mandanten ID'][4:6] == "21":
zeile['Mandanten ID'] = 'm21 iM.2 Interner Mandant (Schutzbedarf normal)'
elif zeile['Mandanten ID'][4:6] == "22":
zeile['Mandanten ID'] = 'm22 iM.3 Interner Mandant (Schutzbedarf hoch)'
elif zeile['Mandanten ID'][4:6] == "50":
zeile['Mandanten ID'] = 'm50 sEMCP.Instanz-1 (CMP Zentral)'
elif zeile['Mandanten ID'][4:6] == "51":
zeile['Mandanten ID'] = 'm51 Classified OPS'
elif zeile['Mandanten ID'][4:6] == "73":
zeile['Mandanten ID'] = 'm73 FWP Lüftersteuerung'
elif zeile['Mandanten ID'][4:6] == "75":
zeile['Mandanten ID'] = 'm75 Fawkes'
elif zeile['Mandanten ID'][4:6] == "76":
zeile['Mandanten ID'] = 'm76 Demo'
elif zeile['Mandanten ID'][4:6] == "77":
zeile['Mandanten ID'] = 'm77 Fritz54 '
elif zeile['Mandanten ID'][4:6] == "78":
zeile['Mandanten ID'] = 'm78 ITZBund mSBC'
elif zeile['Mandanten ID'][4:6] == "79":
zeile['Mandanten ID'] = 'm79 BOS-Spur'
elif zeile['Mandanten ID'][4:6] == "99":
zeile['Mandanten ID'] = 'm99 Releasemanagement'
elif zeile['Mandanten ID'][4:6] == "80":
zeile['Mandanten ID'] = 'm80 ACDC'
if zeile['Segment'][6:8] == "00":
zeile['Segment'] = 'm10 mgmt CMP Core'
ic('m10 mgmt CMP Core')
elif zeile['Segment'][6:8] == "01":
zeile['Segment'] = 'm10 mgmt Infrastructure'
elif zeile['Segment'][6:8] == "02":
zeile['Segment'] = 'm10 mgmt Administration'
elif zeile['Segment'][6:8] == "03":
zeile['Segment'] = 'm10 mgmt zLightsOut'
elif zeile['Segment'][6:8] == "04":
zeile['Segment'] = 'm10 CTS'
elif zeile['Segment'][6:8] == "05":
zeile['Segment'] = 'm10-OSS'
elif zeile['Segment'][6:8] == "10":
zeile['Segment'] = 'm10 CMP2sIM'
elif zeile['Segment'][6:8] == "11":
zeile['Segment'] = 'm10 Intern-CMP iM0'
elif zeile['Segment'][6:8] == "12":
zeile['Segment'] = 'm20 iM.1 Interner Mandant 1 (SB sehr hoch)'
elif zeile['Segment'][6:8] == "13":
zeile['Segment'] = 'm21 iM.2 Interner Mandant 2 (SB normal)'
elif zeile['Segment'][6:8] == "14":
zeile['Segment'] = 'm22 iM.3 Interner Mandant 3 (SB hoch)'
elif zeile['Segment'][6:8] == "15":
zeile['Segment'] = 'm10 iM.4 Interner Mandant 4 (CNMS2CMP)'
elif zeile['Segment'][6:8] == "20":
zeile['Segment'] = 'VRD-Plattform (PAP-Anbindung)'
elif zeile['Segment'][6:8] == "21":
zeile['Segment'] = 'VRD-Plattform (LightsOut + Basisinfrastruktur + Cache)'
elif zeile['Segment'][6:8] == "22":
zeile['Segment'] = 'VRD-Plattform (Admin)'
elif zeile['Segment'][6:8] == "23":
zeile['Segment'] = 'VRD-Plattform (Basisinfrastruktur Mandant zentral)'
elif zeile['Segment'][6:8] == "24":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "25":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "26":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "27":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "28":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "29":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "30":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "31":
zeile['Segment'] = 'VRD-Mandant (Infrastruktur)'
elif zeile['Segment'][6:8] == "32":
zeile['Segment'] = 'VRD-Mandant (Admin)'
elif zeile['Segment'][6:8] == "33":
zeile['Segment'] = 'VRD-Mandant (Anbindung)'
elif zeile['Segment'][6:8] == "34":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "35":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "36":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "37":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "38":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "39":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "40":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "41":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "42":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "43":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "44":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "45":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "46":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "47":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "48":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "49":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "50":
zeile['Segment'] = 'Spare'
elif zeile['Segment'][6:8] == "51":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Infra)'
elif zeile['Segment'][6:8] == "52":
zeile['Segment'] = 'VRD-Mandant (Kundensegment Admin)'
elif zeile['Segment'][6:8] == "53":
zeile['Segment'] = 'VRD-Mandant (Kundensegment)'
elif zeile['Segment'][6:8] == "b0":
zeile['Segment'] = 'mgmt BS Übergang zum CMP Core'
elif zeile['Segment'][6:8] == "ba":
zeile['Segment'] = 'mgmt BS Bon BTW'
elif zeile['Segment'][6:8] == "bb":
zeile['Segment'] = 'mgmt BS Bon LRS'
elif zeile['Segment'][6:8] == "bc":
zeile['Segment'] = 'mgmt BS Ber W55'
elif zeile['Segment'][6:8] == "bd":
zeile['Segment'] = 'mgmt BS Ber PS'
elif zeile['Segment'][6:8] == "be":
zeile['Segment'] = 'mgmt BS Ber NDA'
elif zeile['Segment'][6:8] == "bf":
zeile['Segment'] = 'mgmt BS HanTMX'
elif zeile['Segment'][6:8] == "bg":
zeile['Segment'] = 'mgmt BS Ber DS'
elif zeile['Segment'][6:8] == "c0":
zeile['Segment'] = 'mgmt CMP Übergang Internet'
elif zeile['Segment'][6:8] == "x1":
zeile['Segment'] = 'm10 SecA2sIM'
return zeile """
if __name__ == "__main__" :
app = QApplication (sys.argv)