# Get inventory password from qualification
    username = getparam('/invent/username')
    password = getparam('/invent/password')
    barcode = getparam('qual_item/serial')
    cameraname = getparam('~camera_name')
    cameraip = getparam('~camera_ip')
    progip = getparam('~programming_ip')

    # Fail if invalid username/password
    i = Invent(username, password)
    if not i.login():
        failed("Could not connect to invent.")

    # Get camera url
    try:
        camera_url = i.getItemReferences(barcode)["camera_url"]
        if camera_url == '':
            raise KeyError
    except KeyError:
        failed(
            "Could not get camera url from invent. Try setting the  serial and MAC"
        )

    # Set the camera's name
    p = subprocess.Popen([
        "rosrun", "wge100_camera", "set_name", camera_url + "@" + progip,
        cameraname, cameraip
    ],
                         stdout=subprocess.PIPE,
                         stderr=subprocess.PIPE)
    setnameout = p.communicate()
print "Camera url is:", url

# Get inventory password from qualification
username = rospy.get_param('/invent/username', None)
password = rospy.get_param('/invent/password', None)

# Fail if invalid username/password
i = Invent(username, password)
if not i.login():
    print "Could not connect to invent."
    exit(-1)

# Was this camera already put on invent with a different serial?
# Write camera serial number to invent if it is not already there
try:
    prevserial = i.getItemReferences(barcode)["camera_url"]
    if not prevserial in [ url, '']:
        print "This part was already stored in invent with a different serial '%s'. This should never happen."%prevserial
        exit(-1)
except KeyError:
    prevserial = ''
    pass

if prevserial != url:
    print "Writing camera_url to invent"
    i.addItemReference(barcode, "camera_url", url)
else:
    print "camera_url already in invent"

# Get MAC address from invent.
i.generateWGMacaddr(barcode, "lan0")