def NewBusHandler(self, bus_name, a, b): if (len(b) > 0 and bus_name.find(Openbmc.BUS_PREFIX) == 0): objects = {} try: Openbmc.get_objs(bus,bus_name,"",objects) for instance_name in objects.keys(): obj_path = objects[instance_name]['PATH'] #obj = bus.get_object("org.openbmc.managers.Property", # "/org/openbmc/managers/Property") #intf = dbus.Interface(obj,"org.openbmc.managers.Property") #intf.loadFromCache(bus_name,obj_path) self.bus_name_lookup[obj_path] = bus_name if (System.EXIT_STATE_DEPEND[self.current_state].has_key(obj_path) == True): System.EXIT_STATE_DEPEND[self.current_state][obj_path] = 1 except Exception as e: pass if (System.SYSTEM_CONFIG.has_key(bus_name)): for instance_name in objects.keys(): obj_path = objects[instance_name]['PATH'] for instance in System.SYSTEM_CONFIG[bus_name]['instances']: if (instance.has_key('properties') and instance['name'] == instance_name): props = instance['properties'] print "Load Properties: "+obj_path self.property_manager.loadProperties(bus_name,obj_path,props) ## If object has an init method, call it for init_intf in objects[instance_name]['INIT']: obj = bus.get_object(bus_name,obj_path) intf = dbus.Interface(obj,init_intf) print "Calling init method: " +obj_path+" : "+init_intf intf.init() ## check if all objects are started to move to next state try: state = 1 for obj_path in System.EXIT_STATE_DEPEND[self.current_state]: if (System.EXIT_STATE_DEPEND[self.current_state][obj_path] == 0): state = 0 ## all required objects have started so go to next state if (state == 1): self.gotoNextState() except: pass
def NewBusHandler(self, bus_name, a, b): if (len(b) > 0 and bus_name.find(Openbmc.BUS_PREFIX) == 0): objects = {} Openbmc.get_objs(bus,bus_name,"",objects) for instance_name in objects.keys(): self.bus_name_lookup[objects[instance_name]['PATH']] = bus_name if (System.SYSTEM_CONFIG.has_key(bus_name)): System.SYSTEM_CONFIG[bus_name]['heartbeat_count'] = 0 for instance_name in objects.keys(): obj_path = objects[instance_name]['PATH'] for instance in System.SYSTEM_CONFIG[bus_name]['instances']: if (instance.has_key('properties') and instance['name'] == instance_name): props = instance['properties'] print "Load Properties: "+obj_path self.property_manager.loadProperties(bus_name,obj_path,props) ## If object has an init method, call it for init_intf in objects[instance_name]['INIT']: obj = bus.get_object(bus_name,obj_path) intf = dbus.Interface(obj,init_intf) print "Calling init method: " +obj_path+" : "+init_intf intf.init()
try: tar = tarfile.open(outfile, "r") tar.extractall(UPDATE_PATH, members=doExtract(tar, copy_files)) tar.close() if (self.Get(DBUS_NAME, "clear_persistent_files") == False): print "Removing persistent files" os.unlink(UPDATE_PATH + "/whitelist") if (self.Get(DBUS_NAME, "preserve_network_settings") == True): print "Preserving network settings" shutil.copy2("/dev/mtd2", UPDATE_PATH + "image-u-boot-env") except Exception as e: print e self.Set(DBUS_NAME, "status", "Update Error") self.Set(DBUS_NAME, "status", "Update Success. Please reboot.") if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = Openbmc.getDBus() name = dbus.service.BusName(DBUS_NAME, bus) obj = BmcFlashControl(bus, OBJ_NAME) mainloop = gobject.MainLoop() print "Running Bmc Flash Control" mainloop.run()
self.Set(IFACE_NAME,"floor",250) self.Set(IFACE_NAME,"ceiling",255) self.fan_intf = [] ## create interface proxies to all fans for fan in FAN_OBJS: print "Initializing fan: "+fan obj = bus.get_object(FAN_BUS,fan) self.fan_intf.append(dbus.Interface(obj,FAN_IFACE)) self.InterfacesAdded(name,self.properties) @dbus.service.method(DBUS_NAME, in_signature='', out_signature='') def setMax(self): print "Setting fans to max" for intf in self.fan_intf: intf.setValue(dbus.UInt32(255)) if __name__ == '__main__': dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = Openbmc.getDBus() name = dbus.service.BusName(DBUS_NAME,bus) fan_control = FanControl(bus,OBJ_PATH) mainloop = gobject.MainLoop() print "Starting fan control" fan_control.setMax() mainloop.run()
def getChassisControl(): obj = bus.get_object("org.openbmc.control.Chassis", "/org/openbmc/control/chassis0") intf = dbus.Interface(obj, "org.openbmc.control.Chassis") return intf def prettyPrint(data): for k in data.keys(): print k for k2 in data[k].keys(): print "\t" + k2 + " = " + str(data[k][k2]) if __name__ == "__main__": # dbus.mainloop.glib.DBusGMainLoop(set_as_default=True) bus = Openbmc.getDBus() # name = dbus.service.BusName(DBUS_NAME,bus) # mainloop = gobject.MainLoop() cmd = sys.argv[1] data = None ipmi_id = dbus.Byte(0) if len(sys.argv) > 2: ipmi_id = sys.argv[2] if len(sys.argv) > 3: data = sys.argv[3] if cmd == "poweron": intf = getChassisControl() intf.powerOn()