Example #1
0
def get_mac_from_eeprom():
    bus = dbus.SystemBus()
    mapper = obmc.mapper.Mapper(bus)

    # Get the inventory subtree, limited
    # to objects that implement NetworkInterface.
    for path, info in \
        mapper.get_subtree(
            path=INVENTORY_ROOT,
            interfaces=[INV_INTF_NAME]).iteritems():
        # Find a NetworkInterface with 'bmc' in the path.
        if 'bmc' not in path:
            continue

        # Only expecting a single service to implement
        # NetworkInterface.  Get the service connection
        # from the mapper response
        conn = info.keys()[0]

        # Get the inventory object implementing NetworkInterface.
        obj = bus.get_object(conn, path)

        # Get the MAC address
        mproxy = obj.get_dbus_method('Get', dbus.PROPERTIES_IFACE)
        return mproxy(INV_INTF_NAME, MAC_PROPERTY)
def get_uuid(bus, prop):
    mapper = obmc.mapper.Mapper(bus)

    # Get the inventory subtree, limited
    # to objects that implement UUID.
    resp = mapper.get_subtree(
        path=INVENTORY_ROOT,
        interfaces=[CHS_INTF_NAME])

    # Only expecting a single object to implement UUID.
    try:
        path, info = resp.items()[0]
    except IndexError as e:
        return None

    # Only expecting a single service to implement
    # UUID.  Get the service connection
    # from the mapper response
    conn = info.keys()[0]

    # Get the inventory object implementing UUID.
    obj = bus.get_object(conn, path)

    # Get the uuid
    mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
    return mproxy(CHS_INTF_NAME, prop)
def get_bmc_mac_address(bus, prop):
    mapper = obmc.mapper.Mapper(bus)

    # Get the inventory subtree, limited
    # to objects that implement NetworkInterface.
    for path, info in \
        mapper.get_subtree(
            path=INVENTORY_ROOT,
            interfaces=[INV_INTF_NAME]).iteritems():

            # Find a NetworkInterface with 'bmc' in the path.
            if 'bmc' not in path:
                continue

            # Only expecting a single service to implement
            # NetworkInterface.  Get the service connection
            # from the mapper response
            conn = info.keys()[0]

            # Get the inventory object implementing NetworkInterface.
            obj = bus.get_object(conn, path)

            # Get the MAC address
            mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
            return mproxy(INV_INTF_NAME, prop)
Example #4
0
def get_network_interface_object(bus):
    mapper = obmc.mapper.Mapper(bus)

    # Get the network subtree, limited
    # to objects that implements EthernetInterface.
    for path, info in \
        mapper.get_subtree(
            path=NETWORK_ROOT,
            interfaces=[ETHERNET_INTF_NAME]).iteritems():

        # Find the one which is having physical interface,it may happen
        # that vlan interface is there and we want the physical
        # interface here.
        if path.split('/')[-1].find('_') < 0:
            service = info.keys()[0]
            net_obj = bus.get_object(service, path)
            return net_obj
Example #5
0
def get_uuid(bus, prop):
    mapper = obmc.mapper.Mapper(bus)

    # Get the inventory subtree, limited
    # to objects that implement UUID.
    resp = mapper.get_subtree(path=INVENTORY_ROOT, interfaces=[CHS_INTF_NAME])

    # Only expecting a single object to implement UUID.
    try:
        path, info = resp.items()[0]
    except IndexError as e:
        return None

    # Only expecting a single service to implement
    # UUID.  Get the service connection
    # from the mapper response
    conn = info.keys()[0]

    # Get the inventory object implementing UUID.
    obj = bus.get_object(conn, path)

    # Get the uuid
    mproxy = obj.get_dbus_method('Get', PROP_INTF_NAME)
    return mproxy(CHS_INTF_NAME, prop)