def update_mac_in_archive(tmpdir): """ Update MAC addresses in system archive file. """ hostname = utils.get_controller_hostname() macs = sysinv_api.get_mac_addresses(hostname) for intf, mac in macs.items(): find_and_replace([os.path.join(tmpdir, 'postgres/sysinv.sql.data')], mac, "CLONEISOMAC_{}{}".format(hostname, intf)) if (tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX or tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX_DIRECT): hostname = utils.get_mate_controller_hostname() macs = sysinv_api.get_mac_addresses(hostname) for intf, mac in macs.items(): find_and_replace( [os.path.join(tmpdir, 'postgres/sysinv.sql.data')], mac, "CLONEISOMAC_{}{}".format(hostname, intf))
def update_disk_serial_id_in_archive(tmpdir): """ Update disk serial id in system archive file. """ hostname = utils.get_controller_hostname() disk_sids = sysinv_api.get_disk_serial_ids(hostname) for d_dnode, d_sid in disk_sids.items(): find_and_replace([os.path.join(tmpdir, 'postgres/sysinv.sql.data')], d_sid, "CLONEISODISKSID_{}{}".format(hostname, d_dnode)) if (tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX or tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX_DIRECT): hostname = utils.get_mate_controller_hostname() disk_sids = sysinv_api.get_disk_serial_ids(hostname) for d_dnode, d_sid in disk_sids.items(): find_and_replace( [os.path.join(tmpdir, 'postgres/sysinv.sql.data')], d_sid, "CLONEISODISKSID_{}{}".format(hostname, d_dnode))
def validate_controller_state(): """ Cloning allowed now? """ # Check if this Controller is enabled and provisioned try: if not sysinv_api.controller_enabled_provisioned( utils.get_controller_hostname()): raise CloneFail("Controller is not enabled/provisioned") if (tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX or tsconfig.system_mode == si_const.SYSTEM_MODE_DUPLEX_DIRECT): if not sysinv_api.controller_enabled_provisioned( utils.get_mate_controller_hostname()): raise CloneFail("Mate controller is not enabled/provisioned") except CloneFail: raise except Exception: raise CloneFail("Controller is not enabled/provisioned") if utils.get_system_type() != si_const.TIS_AIO_BUILD: raise CloneFail("Cloning supported only on All-in-one systems") if len(sysinv_api.get_alarms()) > 0: raise CloneFail("There are active alarms on this system!")