def slotRtop(self):
     self.Rtop = RtopPanel()
     self.Rtop.exec_()
class TopoClusterLevel(QtGui.QWidget):
    def __init__(self):
        super(TopoClusterLevel, self).__init__()
        self.font = QtGui.QFont()
        self.initUI()

    def slotLCCA(self):
        self.lccaControl = LCCAControl()
        self.lccaControl.exec_()

    def slotClusterNode(self):
        self.clusterNodeControl = ClusterNodeControl()
        self.clusterNodeControl.exec_()

    def slotRtop(self):
        self.Rtop = RtopPanel()
        self.Rtop.exec_()

    def makeActionButton(self, name, tooltip, sizeX, sizeY):
        button = QtGui.QPushButton(name)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        color = button.palette()
        color.setColor(button.backgroundRole(), QtGui.QColor(0, 102, 187))
        color.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255, 255, 255))
        button.setPalette(color)
        return button

    def makeHardwareButton(self, label, tooltip, state, sizeX, sizeY,
                           drillDownData):
        button = QtGui.QPushButton(label)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        buttonsColor = button.palette()
        if state == 0:  #HARDWARE UP AND GOOD STATE
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(0, 102, 0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 1:  #HARDWARE DOWN  OR BAD STATE
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(221, 0, 0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 2:  #HARDWARE HAS NON-CRITICAL ISSUES
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(255, 221, 68))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 3:  #NO HARDWARE PRESENT STATE
            button.setEnabled(False)
        button.setPalette(buttonsColor)
        return button

    def makeBCButton(self, machine, rack, state, sizeX, sizeY, drillDownData,
                     firstBlade, lastBlade):
        if ('001' in machine):
            whichBlades = 'Blade Center 1: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc1Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc1Button, rack)
        elif ('002' in machine):
            whichBlades = 'Blade Center 2: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc2Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc2Button, rack)
        elif ('003' in machine):
            whichBlades = 'Blade Center 3: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc3Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc3Button, rack)
        elif ('004' in machine):
            whichBlades = 'Blade Center 4: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc4Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc4Button, rack)
        elif ('005' in machine):
            whichBlades = 'Blade Center 5: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc5Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc5Button, rack)
        elif ('006' in machine):
            whichBlades = 'Blade Center 6: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc6Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc6Button, rack)
        elif ('007' in machine):
            whichBlades = 'Blade Center 7: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc7Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc7Button, rack)
        elif ('008' in machine):
            whichBlades = 'Blade Center 8: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc8Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc8Button, rack)
        elif ('009' in machine):
            whichBlades = 'Blade Center 9: Blades %i-%i' % (firstBlade,
                                                            lastBlade)
            self.bc9Button = self.makeHardwareButton(machine, whichBlades,
                                                     state, sizeX, sizeY,
                                                     drillDownData)
            self.placeBCButton(self.bc9Button, rack)
        elif ('010' in machine):
            whichBlades = 'Blade Center 10: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc10Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc10Button, rack)
        elif ('011' in machine):
            whichBlades = 'Blade Center 11: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc11Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc11Button, rack)
        elif ('012' in machine):
            whichBlades = 'Blade Center 12: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc12Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc12Button, rack)
        elif ('013' in machine):
            whichBlades = 'Blade Center 13: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc13Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc13Button, rack)
        elif ('014' in machine):
            whichBlades = 'Blade Center 14: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc14Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc14Button, rack)
        elif ('015' in machine):
            whichBlades = 'Blade Center 15: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc15Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc15Button, rack)
        elif ('016' in machine):
            whichBlades = 'Blade Center 16: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc16Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc16Button, rack)
        elif ('017' in machine):
            whichBlades = 'Blade Center 17: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc17Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc17Button, rack)
        elif ('018' in machine):
            whichBlades = 'Blade Center 18: Blades %i-%i' % (firstBlade,
                                                             lastBlade)
            self.bc18Button = self.makeHardwareButton(machine, whichBlades,
                                                      state, sizeX, sizeY,
                                                      drillDownData)
            self.placeBCButton(self.bc18Button, rack)

    def placeBCButton(self, button, rack):
        if (rack == 1):
            self.rack1Layout.addWidget(button)
        elif (rack == 2):
            self.rack2Layout.addWidget(button)
        elif (rack == 3):
            self.rack3Layout.addWidget(button)

    def initUI(self):
        # This will be used to to set the window's layout
        self.layout = QtGui.QVBoxLayout()

        # Make the top nav bar for switching views and opening rtop
        topBarLayout = QtGui.QHBoxLayout()
        topBarFrame = QtGui.QFrame()
        topBarFrame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.rtopButton = self.makeActionButton(
            'RTOP',
            'Launch blade, LCCA,\nand management node\nmonitor utility', 330,
            60)
        self.rtopButton.clicked.connect(self.slotRtop)

        topBarLayout.addWidget(self.rtopButton)
        topBarFrame.setLayout(topBarLayout)

        hardwareLayout = QtGui.QHBoxLayout()
        self.hardwareList = ClusterData.managementNodeData

        for i in self.hardwareList:
            if ('LCCA' in i[0]):
                lccaButton = self.makeHardwareButton(
                    i[0], 'Open LCCA Control Panel', i[1], 130, 440, i[2])
                lccaButton.clicked.connect(self.slotLCCA)
            else:
                clusterManageButton = self.makeHardwareButton(
                    i[0], 'Open Cluster Management Control Panel', i[1], 130,
                    440, i[2])
                clusterManageButton.clicked.connect(self.slotClusterNode)
        # Placement requires that the Cluster Management button be placed farthest left.
        # followed by the LCCA and then the Blade Racks with the Blade Center buttons stacked vertically
        hardwareLayout.addWidget(clusterManageButton)
        hardwareLayout.addWidget(lccaButton)
        #lccaButton.clicked.connect(lambda: self.slotLCCA(*PASS DATA THROUGH HERE*))
        #clusterManagementButton.clicked.connect(lambda: self.slotClusterNode(*PASS DATA THROUGH HERE*))

        self.rack1Layout = QtGui.QVBoxLayout()
        rack1Frame = QtGui.QFrame()
        rack1Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.rack2Layout = QtGui.QVBoxLayout()
        rack2Frame = QtGui.QFrame()
        rack2Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.rack3Layout = QtGui.QVBoxLayout()
        rack3Frame = QtGui.QFrame()
        rack3Frame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.rackData = ClusterData.topographData

        sizeX = 115
        sizeY = 65
        for i in self.rackData:
            #self.makeBCButton(machine, rack, state, sizeX, sizeY, drilldownData, firstBlade, lastBlade)
            self.makeBCButton(i[0], i[1], i[2], sizeX, sizeY, i[3], i[4], i[5])

        rack1Frame.setLayout(self.rack1Layout)
        rack2Frame.setLayout(self.rack2Layout)
        rack3Frame.setLayout(self.rack3Layout)
        hardwareLayout.addWidget(rack1Frame)
        hardwareLayout.addWidget(rack2Frame)
        hardwareLayout.addWidget(rack3Frame)

        # Pack widgets and layouts
        self.layout.addWidget(topBarFrame)
        self.layout.addLayout(hardwareLayout)

        # Finalize layout of window and show
        self.setLayout(self.layout)
        self.move(300, 150)
        self.setWindowTitle('CLUSTER MAIN VIEW')
        self.setGeometry(50, 50, 725, 500)
        self.show()
 def slotRtop(self):
     self.Rtop = RtopPanel()
     self.Rtop.exec_()
class TopoClusterLevel(QtGui.QWidget):
    def __init__(self):
        super(TopoClusterLevel, self).__init__()
        self.font = QtGui.QFont()
        self.initUI()

    def slotLCCA(self):
         self.lccaControl = LCCAControl()
         self.lccaControl.exec_()

    def slotClusterNode(self):
        self.clusterNodeControl = ClusterNodeControl()
        self.clusterNodeControl.exec_()

    def slotRtop(self):
        self.Rtop = RtopPanel()
        self.Rtop.exec_()

    def makeActionButton(self, name, tooltip, sizeX, sizeY):
        button = QtGui.QPushButton(name)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        color = button.palette()
        color.setColor(button.backgroundRole(), QtGui.QColor(0,102,187))
        color.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        button.setPalette(color)
        return button

    def makeHardwareButton(self, label, tooltip, state, sizeX, sizeY, drillDownData):
        button = QtGui.QPushButton(label)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        buttonsColor = button.palette()
        if state == 0: #HARDWARE UP AND GOOD STATE
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(0,102,0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 1: #HARDWARE DOWN  OR BAD STATE
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(221,0,0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 2: #HARDWARE HAS NON-CRITICAL ISSUES 
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(255,221,68))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 3: #NO HARDWARE PRESENT STATE
            button.setEnabled(False)
        button.setPalette(buttonsColor)
        return button

    def makeBCButton(self, machine, rack, state,  sizeX, sizeY, drillDownData, firstBlade, lastBlade):
        if ('001' in machine):
            whichBlades = 'Blade Center 1: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc1Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc1Button, rack)
        elif ('002' in machine):
            whichBlades = 'Blade Center 2: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc2Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc2Button, rack)
        elif ('003' in machine):
            whichBlades = 'Blade Center 3: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc3Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc3Button, rack)
        elif ('004' in machine):
            whichBlades = 'Blade Center 4: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc4Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc4Button, rack)
        elif ('005' in machine):
            whichBlades = 'Blade Center 5: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc5Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc5Button, rack)
        elif ('006' in machine):
            whichBlades = 'Blade Center 6: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc6Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc6Button, rack)
        elif ('007' in machine):
            whichBlades = 'Blade Center 7: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc7Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc7Button, rack)
        elif ('008' in machine):
            whichBlades = 'Blade Center 8: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc8Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc8Button, rack)
        elif ('009' in machine):
            whichBlades = 'Blade Center 9: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc9Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc9Button, rack)
        elif ('010' in machine):
            whichBlades = 'Blade Center 10: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc10Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc10Button, rack)
        elif ('011' in machine):
            whichBlades = 'Blade Center 11: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc11Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc11Button, rack)
        elif ('012' in machine):
            whichBlades = 'Blade Center 12: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc12Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc12Button, rack)
        elif ('013' in machine):
            whichBlades = 'Blade Center 13: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc13Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc13Button, rack)
        elif ('014' in machine):
            whichBlades = 'Blade Center 14: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc14Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc14Button, rack)
        elif ('015' in machine):
            whichBlades = 'Blade Center 15: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc15Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc15Button, rack)
        elif ('016' in machine):
            whichBlades = 'Blade Center 16: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc16Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc16Button, rack)
        elif ('017' in machine):
            whichBlades = 'Blade Center 17: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc17Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc17Button, rack)
        elif ('018' in machine):
            whichBlades = 'Blade Center 18: Blades %i-%i' % (firstBlade, lastBlade)
            self.bc18Button = self.makeHardwareButton(machine, whichBlades, state, sizeX, sizeY, drillDownData)
            self.placeBCButton(self.bc18Button, rack)


    def placeBCButton(self, button, rack):
        if (rack == 1):
            self.rack1Layout.addWidget(button)
        elif (rack == 2):
            self.rack2Layout.addWidget(button)
        elif (rack == 3):
            self.rack3Layout.addWidget(button)

    def initUI(self):
        # This will be used to to set the window's layout
        self.layout = QtGui.QVBoxLayout()

        # Make the top nav bar for switching views and opening rtop
        topBarLayout = QtGui.QHBoxLayout()
        topBarFrame = QtGui.QFrame()
        topBarFrame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.rtopButton = self.makeActionButton('RTOP', 'Launch blade, LCCA,\nand management node\nmonitor utility', 330, 60)
        self.rtopButton.clicked.connect(self.slotRtop)

        topBarLayout.addWidget(self.rtopButton)
        topBarFrame.setLayout(topBarLayout)

        hardwareLayout = QtGui.QHBoxLayout()
        self.hardwareList = ClusterData.managementNodeData

        for i in self.hardwareList:
            if ('LCCA' in i[0]):
                lccaButton = self.makeHardwareButton(i[0], 'Open LCCA Control Panel', i[1], 130, 440, i[2])
                lccaButton.clicked.connect(self.slotLCCA)
            else:
                clusterManageButton = self.makeHardwareButton(i[0], 'Open Cluster Management Control Panel', i[1], 130, 440, i[2])
                clusterManageButton.clicked.connect(self.slotClusterNode)
        # Placement requires that the Cluster Management button be placed farthest left.
        # followed by the LCCA and then the Blade Racks with the Blade Center buttons stacked vertically
        hardwareLayout.addWidget(clusterManageButton)
        hardwareLayout.addWidget(lccaButton)
        #lccaButton.clicked.connect(lambda: self.slotLCCA(*PASS DATA THROUGH HERE*))
        #clusterManagementButton.clicked.connect(lambda: self.slotClusterNode(*PASS DATA THROUGH HERE*))

        self.rack1Layout = QtGui.QVBoxLayout()
        rack1Frame = QtGui.QFrame()
        rack1Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.rack2Layout = QtGui.QVBoxLayout()
        rack2Frame = QtGui.QFrame()
        rack2Frame.setFrameShape(QtGui.QFrame.StyledPanel)
        self.rack3Layout = QtGui.QVBoxLayout()
        rack3Frame = QtGui.QFrame()
        rack3Frame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.rackData = ClusterData.topographData

        sizeX = 115
        sizeY = 65
        for i in self.rackData:
            #self.makeBCButton(machine, rack, state, sizeX, sizeY, drilldownData, firstBlade, lastBlade)
            self.makeBCButton(i[0], i[1], i[2], sizeX, sizeY, i[3], i[4], i[5])

        rack1Frame.setLayout(self.rack1Layout)
        rack2Frame.setLayout(self.rack2Layout)
        rack3Frame.setLayout(self.rack3Layout)
        hardwareLayout.addWidget(rack1Frame)
        hardwareLayout.addWidget(rack2Frame)
        hardwareLayout.addWidget(rack3Frame)

        # Pack widgets and layouts
        self.layout.addWidget(topBarFrame)
        self.layout.addLayout(hardwareLayout)

        # Finalize layout of window and show 
        self.setLayout(self.layout)
        self.move(300, 150)
        self.setWindowTitle('CLUSTER MAIN VIEW')
        self.setGeometry(50, 50, 725, 500)
        self.show()
Example #5
0
class TopoBCenterLevel(QtGui.QWidget):
    def __init__(self, data):
        super(TopoBCenterLevel, self).__init__()
        self.font = QtGui.QFont()
        self.initUI(data)

    def slotBlade(self, dynamicData):
        self.blade = BladeControl(dynamicData)
        self.blade.exec_()

    def slotAMM(self):
        self.AMM = AMMControl()
        self.AMM.exec_()

    def slotSwitch(self):
        self.Switch = SwitchControl()
        self.Switch.exec_()

    def slotBCPanel(self):
        self.bcControl = BladeCenterPanel()
        self.bcControl.exec_()

    def slotRtop(self):
        self.Rtop = RtopPanel()
        self.Rtop.exec_()

    def slotMediaTray(self, bladeAssign):
        self.trayAssignment = ClusterMediaTray(bladeAssign)
        self.trayAssignment.exec_()

    def makeActionButton(self, name, tooltip, sizeX, sizeY):
        button = QtGui.QPushButton(name)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        color = button.palette()
        color.setColor(button.backgroundRole(), QtGui.QColor(0, 102, 187))
        color.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255, 255, 255))
        button.setPalette(color)
        return button

    def makeHardwareButton(self, label, state, sizeX, sizeY, drillDownData,
                           statusInfoArray):
        button = QtGui.QPushButton(label)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)

        # Make Tooltip to display status of hardware button
        # checkIfLast - check if last element being added to the string; removes the '\n' from last line
        statusString = ''
        checkIfLast = 0
        for i in statusInfoArray:
            if checkIfLast != len(statusInfoArray) - 1:
                statusString += i + '\n'
            else:
                statusString += i
            checkIfLast += 1
        button.setToolTip(statusString)

        buttonsColor = button.palette()
        if state == 0:  #HARDWARE UP AND GOOD STATE
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(0, 102, 0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 1:  #HARDWARE DOWN  OR BAD STATE
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(221, 0, 0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 2:  #HARDWARE HAS NON-CRITICAL ISSUES
            buttonsColor.setColor(button.backgroundRole(),
                                  QtGui.QColor(255, 221, 68))
            buttonsColor.setColor(QtGui.QPalette.ButtonText,
                                  QtGui.QColor(255, 255, 255))
        elif state == 3:  #NO HARDWARE PRESENT STATE
            button.setEnabled(False)
        button.setPalette(buttonsColor)

        # What are we connecting the button to?
        if ('ADVANCED\nMANAGEMENT\nMODULE' == label):
            button.clicked.connect(self.slotAMM)
        elif ('SWITCH\nMODULE\n001' == label):
            button.clicked.connect(self.slotSwitch)
        elif ('SWITCH\nMODULE\n002' == label):
            button.clicked.connect(self.slotSwitch)
        # The media tray is a special case and the drillDown data passed for its call
        # is meant to set a parameter to the first blade in the bladecenter as default
        # for the media tray assignment, this will need to be swapped for the actual assignment of
        # the media tray, when the backend in implemented
        elif ('MEDIA\nTRAY' == label):
            button.clicked.connect(
                lambda: self.slotMediaTray(drillDownData[0][0]))
        else:
            button.clicked.connect(lambda: self.slotBlade(drillDownData))
        return button

    def initUI(self, data):
        # This will be used to to set the window's layout
        self.layout = QtGui.QVBoxLayout()

        topBarLayout = QtGui.QHBoxLayout()
        topLeftLayout = QtGui.QHBoxLayout()
        topRightLayout = QtGui.QHBoxLayout()

        topLeftFrame = QtGui.QFrame()
        topRightFrame = QtGui.QFrame()
        topLeftFrame.setFrameShape(QtGui.QFrame.StyledPanel)
        topRightFrame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.backButton = self.makeActionButton('BACK',
                                                'Return to high-level view',
                                                158, 60)
        self.bladeRebootButton = self.makeActionButton(
            'REBOOT\nERROR BLADES',
            'Perform automated shutdown\nand boot up procedures\nto all blades with errors\nin this blade center',
            156, 60)
        self.bcPanelButton = self.makeActionButton(
            'BLADE CENTER\nPANEL',
            'Open information panel\nfor the blade center', 158, 60)
        self.rtopButton = self.makeActionButton(
            'RTOP',
            'Launch blade, LCCA,\nand management node\nmonitor utility', 158,
            60)

        self.bcPanelButton.clicked.connect(self.slotBCPanel)
        self.rtopButton.clicked.connect(self.slotRtop)

        topLeftLayout.addWidget(self.backButton)
        topRightLayout.addWidget(self.bcPanelButton)
        topRightLayout.addWidget(self.bladeRebootButton)
        topRightLayout.addWidget(self.rtopButton)
        topLeftFrame.setLayout(topLeftLayout)
        topRightFrame.setLayout(topRightLayout)

        topBarLayout.addWidget(topLeftFrame)
        topBarLayout.addWidget(topRightFrame)

        # Make grid layout for the array buttons
        bladeGrid = QtGui.QGridLayout()
        hardwareGrid = QtGui.QGridLayout()

        # ----------------- THE DATA! ---------------------
        # machineDataArray - based on the data passed in
        #
        # Template, each entry - [ bladeNum, bladeState, [ cpuRate, memoryRate, rx, tx ] ]
        #dynamicInfo = [ [ '1', 0, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '2', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '3', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '4', 2, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '5', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '6', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '7', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '8', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '9', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '10', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '11', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '12', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '13', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '14', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'AMM', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'SWITCH\nMODULE\n001', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'SWITCH\nMODULE\n002', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'MEDIA\nTRAY', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ] ]

        j = 0  # Check for the first 14 blades
        k = 0  # Incrementor
        machineDataArray = data[3]
        mediaTrayAssignment = data[3][0][
            0]  # NEEDS TO BE UPDATED (PLACEHOLDER)
        for i in machineDataArray:
            if (j < 14):
                button = self.makeHardwareButton(i[0], i[1], 43, 300, i, i[3])
                bladeGrid.addWidget(button, 0, j)
                j = j + 1
            else:
                if ('ADVANCED' in i[0]):
                    button = self.makeHardwareButton(i[0], i[1], 169, 135, i,
                                                     i[3])
                elif ('SWITCH' in i[0]):
                    button = self.makeHardwareButton(i[0], i[1], 169, 135, i,
                                                     i[3])
                elif ('MEDIA' in i[0]):
                    # MUST CHANGE: Defaulting to giving the first blade in a blade center as the
                    # assignment of the media tray. When the back end is implemented, this value
                    # will need to be changed to whatever the media tray gives back for its assignment
                    button = self.makeHardwareButton(i[0], i[1], 169, 135,
                                                     machineDataArray, i[3])
                # else: Throw an error
                hardwareGrid.addWidget(button, 0, k)
                k = k + 1

        # -------------Matryoshka Assembly!---------------------
        # Widgets: should each be contained in a layout
        # Layouts: each get added to the main layout
        self.layout.addLayout(topBarLayout)
        self.layout.addLayout(bladeGrid)
        self.layout.addLayout(hardwareGrid)

        # Finalize layout of window and show
        self.setLayout(self.layout)
        self.move(300, 150)
        self.setWindowTitle('BLADE CENTER VIEW')
        self.setGeometry(50, 50, 700, 500)
        self.show()
class TopoBCenterLevel(QtGui.QWidget):
    def __init__(self, data):
        super(TopoBCenterLevel, self).__init__()
        self.font = QtGui.QFont() 
        self.initUI(data)

    def slotBlade(self, dynamicData):
        self.blade = BladeControl(dynamicData)
        self.blade.exec_()

    def slotAMM(self):
        self.AMM = AMMControl()
        self.AMM.exec_()

    def slotSwitch(self):
        self.Switch = SwitchControl()
        self.Switch.exec_()

    def slotBCPanel(self):
        self.bcControl = BladeCenterPanel()
        self.bcControl.exec_()

    def slotRtop(self):
        self.Rtop = RtopPanel()
        self.Rtop.exec_()

    def slotMediaTray(self, bladeAssign):
        self.trayAssignment = ClusterMediaTray(bladeAssign)
        self.trayAssignment.exec_()

    def makeActionButton(self, name, tooltip, sizeX, sizeY):
        button = QtGui.QPushButton(name)
        button.setToolTip(tooltip)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)
        color = button.palette()
        color.setColor(button.backgroundRole(), QtGui.QColor(0,102,187))
        color.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))        
        button.setPalette(color)
        return button

    def makeHardwareButton(self, label, state, sizeX, sizeY, drillDownData, statusInfoArray):
        button = QtGui.QPushButton(label)
        button.setMinimumSize(sizeX, sizeY)
        self.font.setBold(True)
        button.setFont(self.font)

        # Make Tooltip to display status of hardware button
        # checkIfLast - check if last element being added to the string; removes the '\n' from last line
        statusString = ''
        checkIfLast = 0
        for i in statusInfoArray:
            if checkIfLast != len(statusInfoArray) - 1:
                statusString += i + '\n'
            else:
                statusString += i
            checkIfLast += 1
        button.setToolTip(statusString)

        buttonsColor = button.palette()
        if state == 0: #HARDWARE UP AND GOOD STATE
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(0,102,0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 1: #HARDWARE DOWN  OR BAD STATE
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(221,0,0))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 2: #HARDWARE HAS NON-CRITICAL ISSUES 
            buttonsColor.setColor(button.backgroundRole(), QtGui.QColor(255,221,68))
            buttonsColor.setColor(QtGui.QPalette.ButtonText, QtGui.QColor(255,255,255))
        elif state == 3: #NO HARDWARE PRESENT STATE
            button.setEnabled(False)
        button.setPalette(buttonsColor)

        # What are we connecting the button to?
        if ('ADVANCED\nMANAGEMENT\nMODULE' == label):
            button.clicked.connect(self.slotAMM)
        elif ('SWITCH\nMODULE\n001' == label):
            button.clicked.connect(self.slotSwitch)
        elif ('SWITCH\nMODULE\n002' == label):
            button.clicked.connect(self.slotSwitch)
        # The media tray is a special case and the drillDown data passed for its call
        # is meant to set a parameter to the first blade in the bladecenter as default
        # for the media tray assignment, this will need to be swapped for the actual assignment of
        # the media tray, when the backend in implemented
        elif ('MEDIA\nTRAY' == label):
            button.clicked.connect(lambda: self.slotMediaTray(drillDownData[0][0]))
        else:
            button.clicked.connect(lambda: self.slotBlade(drillDownData))            
        return button

    def initUI(self, data):
        # This will be used to to set the window's layout
        self.layout = QtGui.QVBoxLayout()

        topBarLayout = QtGui.QHBoxLayout()
        topLeftLayout = QtGui.QHBoxLayout()
        topRightLayout = QtGui.QHBoxLayout()

        topLeftFrame = QtGui.QFrame()
        topRightFrame = QtGui.QFrame()
        topLeftFrame.setFrameShape(QtGui.QFrame.StyledPanel)
        topRightFrame.setFrameShape(QtGui.QFrame.StyledPanel)

        self.backButton = self.makeActionButton('BACK', 'Return to high-level view', 158, 60)
        self.bladeRebootButton = self.makeActionButton('REBOOT\nERROR BLADES', 'Perform automated shutdown\nand boot up procedures\nto all blades with errors\nin this blade center', 156, 60)
        self.bcPanelButton = self.makeActionButton('BLADE CENTER\nPANEL', 'Open information panel\nfor the blade center', 158, 60)
        self.rtopButton = self.makeActionButton('RTOP', 'Launch blade, LCCA,\nand management node\nmonitor utility', 158, 60)

        self.bcPanelButton.clicked.connect(self.slotBCPanel)
        self.rtopButton.clicked.connect(self.slotRtop)

        topLeftLayout.addWidget(self.backButton)
        topRightLayout.addWidget(self.bcPanelButton)
        topRightLayout.addWidget(self.bladeRebootButton)
        topRightLayout.addWidget(self.rtopButton)
        topLeftFrame.setLayout(topLeftLayout)
        topRightFrame.setLayout(topRightLayout)

        topBarLayout.addWidget(topLeftFrame)
        topBarLayout.addWidget(topRightFrame)

        # Make grid layout for the array buttons
        bladeGrid = QtGui.QGridLayout()
        hardwareGrid = QtGui.QGridLayout()

        # ----------------- THE DATA! ---------------------
        # machineDataArray - based on the data passed in
        #
        # Template, each entry - [ bladeNum, bladeState, [ cpuRate, memoryRate, rx, tx ] ]  
        #dynamicInfo = [ [ '1', 0, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '2', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '3', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '4', 2, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '5', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '6', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '7', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '8', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '9', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '10', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '11', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '12', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '13', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ '14', 1, [ 100, 10, '85KB', '100KB' ], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'AMM', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'SWITCH\nMODULE\n001', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'SWITCH\nMODULE\n002', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ],
        #                [ 'MEDIA\nTRAY', 1, [], ['ON', 'PING-ABLE', 'SSH-ABLE', 'NO ERRORS'] ] ]

        j = 0 # Check for the first 14 blades
        k = 0 # Incrementor
        machineDataArray = data[3] 
        mediaTrayAssignment = data[3][0][0] # NEEDS TO BE UPDATED (PLACEHOLDER)
        for i in machineDataArray:
            if (j < 14):
                button = self.makeHardwareButton(i[0], i[1], 43, 300, i, i[3])
                bladeGrid.addWidget(button, 0, j)
                j = j + 1
            else:
                if ('ADVANCED' in i[0]):
                    button = self.makeHardwareButton(i[0], i[1], 169, 135, i, i[3])
                elif ('SWITCH' in i[0]):
                    button = self.makeHardwareButton(i[0], i[1], 169, 135, i, i[3])
                elif ('MEDIA' in i[0]):
                    # MUST CHANGE: Defaulting to giving the first blade in a blade center as the
                    # assignment of the media tray. When the back end is implemented, this value
                    # will need to be changed to whatever the media tray gives back for its assignment 
                    button = self.makeHardwareButton(i[0], i[1], 169, 135, machineDataArray, i[3])
                # else: Throw an error
                hardwareGrid.addWidget(button, 0, k)
                k = k + 1

        # -------------Matryoshka Assembly!---------------------
        # Widgets: should each be contained in a layout
        # Layouts: each get added to the main layout
        self.layout.addLayout(topBarLayout)
        self.layout.addLayout(bladeGrid)
        self.layout.addLayout(hardwareGrid)

        # Finalize layout of window and show 
        self.setLayout(self.layout)
        self.move(300, 150)
        self.setWindowTitle('BLADE CENTER VIEW')
        self.setGeometry(50, 50, 700, 500)
        self.show()