import {JiraTools} from "./JiraModule.js" import {TableInterface} from "./AzureModule.js" const vms = ["la", "sf", "wi", "az"]; const vmstatus = ["In-Progress", "Done", "Queued", "Stopped"]; const names = ["John Deer", "Becky Bowler", "Lil John", "Hollow Knight", "Derik Sonder"]; const locations = ["West US Azure DC", "US-West-1 AWS DC", "Milpitas", "Irvine"]; const vmversions = ["Linux", "Windows"]; const products = ["WD Blue", "WD Black", "WD Yellow", "WD Cyan", "WD Red"]; const status = ["Passing", "Failing", "Passed", "Failed"]; const fwversions = ["0.0.9", "1.6.9", "4.2.0", "2.3.2", "18.3.4"]; const forms = ["M.2", "7.5in", "2ft"]; const serials = [603735, 919120, 411894, 598273, 430917, 299357, 329593]; const role = ["FW", "Dev", "Exe", "Manage"]; const users = ["261678c4e190513d8a19d616b1719729848fc76b4043956a1bbe2fa203a1c871", "30db12dbc135a1c43161a3d787b5568c9ca2bd2a47123eb50727544e0c0c7462", "20d625e4195317f1b7b35ee2fc6ff36a2df94c2c3503332d375ed100ae1872db", "bfde92b2f028815bb58fc9b4c91d8963c665d21e11fe4c3d4277875653dffe3d", "NA"]; const Jira = new JiraTools("wdcapstonetest", "VG"); const Table = new TableInterface("NAUTableStorage"); export class addShit { constructor() { } async addJiraIssuesToDB() { const vms = ["la", "sf", "wi", "az"];; const vmstatus = ["In-Progress", "Completed", "Idle"]; const names = ["John Deer", "Becky Bowler", "Lil John", "Hollow Knight", "Derik Sonder"]; const locations = ["San Francisco", "Madison", "Phoenix", "Austin"]; const vmversions = ["Linux", "Windows", "MacOS"]; const products = ["WD Blue", "WD Black", "WD Yellow", "WD Cyan", "WD Red"]; const status = ["Passing", "Failing", "Passed", "Failed"]; const fwversions = ["0.0.9", "1.6.9", "4.2.0", "2.3.2", "18.3.4"]; const forms = ["M.2", "7.5in", "2ft"]; const serials = [603735, 919120, 411894, 598273, 430917, 299357, 329593]; var issueData = {}; console.log("Updating issues in database..."); Jira.get_all_issues().then( async (issues) => { for (const issue of issues) { let issueID = issue.id; let description = issue.description; issueData = { version: 2.1, id: issueID, desc: description, link: "Placeholder", status: issue.status, closed: issue.closed || "NA", vm: vms[Math.floor(Math.random() * vms.length)] + Math.floor(Math.random() * 10), fw: serials[Math.floor(Math.random() * serials.length)] }; Table.addIssue("FW", issueData); } }); } async clearPartition(partition) { let type = 0; let role = 0; switch (partition) { case "FWE": role = "FW"; break; case "Dev": role = "Dev"; break; case "Exe": role = "Exe"; break; case "FW": type = 2; break; case "VM": type = 1; break; case "System": type = 3; break; case "User": type = 4; break; } Table.getData(type, role).then( entities => { for(const entity of entities.data) { console.log(entity); console.log("removing " + entity.rowKey + " from " + partition); Table.modData(type, entity.rowKey, 0, role); } }); } async addVMsToDB() { var vmData = {}; let status = ''; let startTime = {}; let day = {}; let hour = {}; for(const vm of vms) { for(let i = 0; i < 10; i++) { day = Math.floor(1 + Math.random() * 20); hour = Math.floor(1 + Math.random() * 16); status = vmstatus[Math.floor(Math.random() * vmstatus.length)]; startTime = Date.parse('March ' + day + ', 2022 ' + hour + ':00:00'); console.log(startTime); vmData = { version: 2.3, system: "VICE" + i, vm: vm + i, start: startTime, type: (Math.floor(Math.random() * 2)) ? "debug" : "test", vmlink: "Placeholder", vmstatus: status, owner: names[Math.floor(Math.random() * names.length)], ownerID: users[Math.floor(Math.random() * users.length)], vmlocation: locations[Math.floor(Math.random() * locations.length)], vmversion: vmversions[Math.floor(Math.random() * vmversions.length)], testingDesc: (status === 'Done') ? "PlaceholderLink" : (status === 'Stopped') ? "Testing Environment Stopped" : "N/A", capabilities: "Placeholder", currentTest: "Test" + Math.floor(Math.random() * 20), product: Math.floor(100000 + Math.random() * 899999), fw: (Math.floor(Math.random() * 2)) ? serials[Math.floor(Math.random() * serials.length)] : "NA" }; Table.addVM(vmData); } } } async addFWsToDB() { var fwData = {}; for(const serial of serials) { fwData = { version: 2.0, product: products[Math.floor(Math.random() * products.length)], status: status[Math.floor(Math.random() * status.length)], fwversion: fwversions[Math.floor(Math.random() * fwversions.length)], fwlink: "Placeholder", commitid: Math.floor(Math.random() * 999999), form: forms[Math.floor(Math.random() * forms.length)], fwlocation: locations[Math.floor(Math.random() * locations.length)], serial: serial } Table.addFW(fwData) } } async addSystemsToDB() { var system = {}; var schedule = []; var reservation = {}; var startTime = {}; var endTime = {}; var day = 0; var hour = 0; var user = 0; var location = ""; var localvms = await Table.getAllVMs(); var vmsBySys = []; for(let i = 0; i < 8; i++) { schedule = []; vmsBySys = []; location = locations[Math.floor(i/2)]; for(let vm of localvms.data) { if(vm.system === ("VICE" + i)) { vmsBySys.push(vm.vm); } } system = { version: 2.1, location: location, id: "VICE" + i, vms: JSON.stringify(vmsBySys), schedule: JSON.stringify(schedule), DUTs: JSON.stringify([]) }; await Table.addSystem(system); } for(let i = 0; i < 8; i++) { schedule = []; vmsBySys = []; let sys = "VICE" + i; location = locations[Math.floor(i/2)]; for(let vm of localvms.data) { if(vm.vmlocation === location) { vmsBySys.push(vm.vm); } } for(let vm of vmsBySys) { for(let j = 0; j < 5; j++) { day = Math.floor(1 + Math.random() * 30); hour = Math.floor(1 + Math.random() * 16); startTime = new Date('May ' + day + ', 2022 ' + '00:00'); endTime = new Date('May ' + (day+1) + ', 2022 ' + '00:00'); user = Math.floor(Math.random() * (names.length-1)); reservation = { version: 2.2, priority: Math.floor(2 + Math.random() * 8), user: names[user], userID: users[user], desc: "Reservation details " + Math.floor(Math.random() * 500), start: startTime, end: endTime, vm: vm, fw: (Math.floor(Math.random() * 2)) ? serials[Math.floor(Math.random() * serials.length)] : "NA" }; console.log(reservation); await Table.addReservation(sys, reservation); } } } } async addExeIssuesToDB() { var request = {}; for(let i = 0; i < 15; i++) { request = { version: 2.0, id: serials[Math.floor(Math.random() * serials.length)], desc: "Give good VM name", system: "VICE" + Math.floor(Math.random() * 10) }; Table.addIssue("Exe", request); } } }