def run(self): """ Draws the screen @rtype: integer @returns: status of operation """ # dhcp if self.__dev.getBootProto() == "dhcp": self.__dhcp.setValue('*') self.__grid.setCurrent(self.__dhcp) # bridge if self.__dev.hasBridge(): self.__bridge.setValue('*') # onboot if self.__hasLink(): if self.__dev.getOnBoot(): self.__enable.setValue('*') else: self.__enable.setFlags(FLAG_DISABLED, FLAGS_SET) self.__grid.setCurrent(self.__bridge) self.__ip.set(Network.removeDoubleQuotes(self.__dev.getIp())) self.__netmask.set(Network.removeDoubleQuotes(self.__dev.getNetmask())) self.__gateway.set(Network.removeDoubleQuotes(self.__dev.getGateway())) self.useDynamicCheckBox() result = self.__grid.run() self.__screen.popWindow() rc = self.__buttonsBar.buttonPressed(result) if rc == "save": if self.__dhcp.selected() or self.__ip.value() != "" or not self.__enable.selected(): self.__saveConfig() msg = TextboxReflowed(40, "Configuring %s interface..." % self.__hwdev.value()) g = GridForm(self.__screen, "IBM PowerKVM", 1, 2) g.add(msg, 0, 0) g.draw() self.__screen.refresh() try: # restart network service Network.restartNetworkService(None, self.__interface) return 0 except Exception as e: Network.disableNIC(None, self.__interface) ButtonChoiceWindow(self.__screen, "ERROR", "Failed to configure %s interface:\n%s" % (self.__interface, e), buttons=[BUTTON_OK], width=40) return -1 finally: self.__screen.popWindow() else: ButtonChoiceWindow(self.__screen, ERROR_INVALID_ENTRY, ERROR_INVALID_ENTRY_MSG, buttons=[BUTTON_OK], width=50) return 1 if rc == "back": return 1