User Tools

Site Tools


infoblox_nios:useful_nios

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
infoblox_nios:useful_nios [2025/09/05 23:00] – [Reset NIOS] bstaffordinfoblox_nios:useful_nios [2025/09/23 13:10] (current) – [Reset NIOS] bstafford
Line 32: Line 32:
 ^ Command ^ Clear NIOS DB and Logs ^ Clear Configuration ^ Clear Network Settings ^ Clear Licenses ^ Clear Network Automation Database ^ ^ Command ^ Clear NIOS DB and Logs ^ Clear Configuration ^ Clear Network Settings ^ Clear Licenses ^ Clear Network Automation Database ^
 | reset all | Yes | Yes | Set to 192.168.1.1/24 | No | N/A | | reset all | Yes | Yes | Set to 192.168.1.1/24 | No | N/A |
 +| reset all secure | Yes | Yes | Set to 192.168.1.1/24 | No | N/A |
 | reset all auto_provision | Yes | Yes | Set to DHCP | Yes | N/A | | reset all auto_provision | Yes | Yes | Set to DHCP | Yes | N/A |
 | reset all licenses | Yes | Yes | Yes | Yes | N/A | | reset all licenses | Yes | Yes | Yes | Yes | N/A |
Line 77: Line 78:
 | show date | Display the date, time and time zone of the appliance |  | show date | Display the date, time and time zone of the appliance | 
 | show debug | Display the status of debugging |  | show debug | Display the status of debugging | 
-| show disk | Display the disk space used | +| [[misc#disk|show disk]] | Display the disk space used | 
 | show file | Display the content(s) of a file(s) |  | show file | Display the content(s) of a file(s) | 
 | show hardware-type | Display hardware type |  | show hardware-type | Display hardware type | 
Line 120: Line 121:
 <code><PROPERTY NAME="name" VALUE="admin"/><PROPERTY NAME="password" VALUE="{ssha}_SAAAAAAddddddddddddddddddddddddddddddddddddddddddddddddd"/></code> <code><PROPERTY NAME="name" VALUE="admin"/><PROPERTY NAME="password" VALUE="{ssha}_SAAAAAAddddddddddddddddddddddddddddddddddddddddddddddddd"/></code>
 NIOS can be very picky about what backup files it will restore onto a version of code. You must always make sure you are running the same version of NIOS that was used to make the Grid backup. However, in a LAB environment, you can edit the first line of the onedb.xml file. This is for LABBING only. NEVER use this in production. Your configuration will not be supported by Infoblox. NIOS can be very picky about what backup files it will restore onto a version of code. You must always make sure you are running the same version of NIOS that was used to make the Grid backup. However, in a LAB environment, you can edit the first line of the onedb.xml file. This is for LABBING only. NEVER use this in production. Your configuration will not be supported by Infoblox.
 +
 +
 +You can script this with 
 +<code>import tarfile
 +import xml.etree.ElementTree as ET
 +import io
 +import shutil
 +import argparse
 +
 +
 +def modify_password_in_tar(tar_path, username, new_password):
 +    # Open tar file
 +    with tarfile.open(tar_path, "r:gz") as tar:
 +        # Extract onedb.xml into memory
 +        xml_member = tar.getmember("onedb.xml")
 +        xml_content = tar.extractfile(xml_member).read()
 +
 +    # Parse XML
 +    root = ET.fromstring(xml_content)
 +
 +    # Extract VERSION and print first 3 parts
 +    version_value = root.attrib.get("VERSION")
 +    if version_value:
 +        version_parts = version_value.split("-")[0]  # take only x.y.z before the dash
 +        version_trimmed = ".".join(version_parts.split(".")[:3])
 +        print(f"Database VERSION: {version_trimmed}")
 +
 +    # Iterate through OBJECT elements
 +    for obj in root.findall(".//OBJECT"):
 +        type_node = obj.find('./PROPERTY[@NAME="__type"]')
 +        name_node = obj.find('./PROPERTY[@NAME="name"]')
 +
 +        if (type_node is not None and type_node.attrib.get("VALUE") == ".com.infoblox.one.admin" and
 +                name_node is not None and name_node.attrib.get("VALUE") == username):
 +
 +            # Find password property
 +            pwd_node = obj.find('./PROPERTY[@NAME="password"]')
 +            if pwd_node is not None:
 +                pwd_node.set("VALUE", new_password)
 +                print(f"Password updated successfully for user: {username}")
 +
 +    # Convert back to string
 +    new_xml_bytes = ET.tostring(root, encoding="utf-8", xml_declaration=True)
 +
 +    # Create a temporary tar
 +    temp_tar_path = tar_path + ".tmp"
 +    with tarfile.open(temp_tar_path, "w:gz") as new_tar:
 +        with tarfile.open(tar_path, "r:gz") as old_tar:
 +            for member in old_tar.getmembers():
 +                if member.name == "onedb.xml":
 +                    # Add modified XML
 +                    info = tarfile.TarInfo(name="onedb.xml")
 +                    info.size = len(new_xml_bytes)
 +                    new_tar.addfile(info, io.BytesIO(new_xml_bytes))
 +                else:
 +                    # Copy other files unchanged
 +                    new_tar.addfile(member, old_tar.extractfile(member) if member.isfile() else None)
 +
 +    # Replace old tar with new tar
 +    shutil.move(temp_tar_path, tar_path)
 +
 +
 +if __name__ == "__main__":
 +    parser = argparse.ArgumentParser(description="Modify password inside onedb.xml in a tar.gz archive")
 +    parser.add_argument("-f", "--file", required=True, help="Path to the tar.gz file")
 +    parser.add_argument("-u", "--username", required=True, help="Username to modify")
 +    parser.add_argument("-p", "--password", required=True, help="New password value")
 +
 +    args = parser.parse_args()
 +
 +    modify_password_in_tar(args.file, args.username, args.password)
 +</code>
  
 In this example, we are making a Grid Backup from 8.6.0 early access NIOS compatible with 8.6.0 GA NIOS. NOTE: We are not actually making it compatible, we are simply tricking NIOS 8.6.0 GA into loading the configuration as best as it can. In this example, we are making a Grid Backup from 8.6.0 early access NIOS compatible with 8.6.0 GA NIOS. NOTE: We are not actually making it compatible, we are simply tricking NIOS 8.6.0 GA into loading the configuration as best as it can.
infoblox_nios/useful_nios.1757113203.txt.gz · Last modified: by bstafford