Example #1
0
def firmware_add_remote(handle,
                        remote_path,
                        file_name,
                        protocol,
                        hostname,
                        username="",
                        password=""):
    '''
    Import the firmware to UcsCentral from remote location

    Args:
        remote_path (str): Remote path where image resides
        file_name (str): Name of the image in the remote directory
        protocol (str): Protocol for the remote communication
        hostname (str): IP address or the host name of the remote server
        username (str): Username for the remote server access
        password  (str): Password for the remote server access
    Example:
        firmware_add_remote(handle,
                            file_name="ucs-k9-bundle-b-series.3.1.1h.B.bin",
                            remote_path="/remote_path/", hostname="10.10.1.1",
                            protocol="scp",username="******",password="******")
    '''
    if not hostname:
        raise UcscValidationException("Missing hostname argument")
    if not remote_path:
        raise UcscValidationException("Missing remote_path argument")
    if not file_name:
        raise UcscValidationException("Missing file_name argument")
    if not protocol:
        raise UcscValidationException("Missing protocol argument")

    if protocol is not FirmwareDownloaderConsts.PROTOCOL_TFTP:
        if not username:
            raise UcscValidationException("Missing username argument")
        if not password:
            raise UcscValidationException("Missing password argument")

    top_system = TopSystem()
    firmware_catalogue = FirmwareCatalogue(parent_mo_or_dn=top_system)
    firmware_downloader = FirmwareDownloader(
        parent_mo_or_dn=firmware_catalogue, file_name=file_name)
    firmware_downloader.remote_path = remote_path
    firmware_downloader.protocol = protocol
    firmware_downloader.server = hostname
    firmware_downloader.user = username
    firmware_downloader.pwd = password
    firmware_downloader.admin_state = \
        FirmwareDownloaderConsts.ADMIN_STATE_RESTART

    handle.add_mo(firmware_downloader, modify_present=True)
    handle.commit()
Example #2
0
def firmware_add_remote(handle, remote_path, file_name, protocol, hostname,
                        username="", password=""):
    '''
    Import the firmware to UcsCentral from remote location

    Args:
        remote_path (str): Remote path where image resides
        file_name (str): Name of the image in the remote directory
        protocol (str): Protocol for the remote communication
        hostname (str): IP address or the host name of the remote server
        username (str): Username for the remote server access
        password  (str): Password for the remote server access
    Example:
        firmware_add_remote(handle,
                            file_name="ucs-k9-bundle-b-series.3.1.1h.B.bin",
                            remote_path="/remote_path/", hostname="10.10.1.1",
                            protocol="scp",username="******",password="******")
    '''
    if not hostname:
        raise UcscValidationException("Missing hostname argument")
    if not remote_path:
        raise UcscValidationException("Missing remote_path argument")
    if not file_name:
        raise UcscValidationException("Missing file_name argument")
    if not protocol:
        raise UcscValidationException("Missing protocol argument")

    if protocol is not FirmwareDownloaderConsts.PROTOCOL_TFTP:
        if not username:
            raise UcscValidationException("Missing username argument")
        if not password:
            raise UcscValidationException("Missing password argument")

    top_system = TopSystem()
    firmware_catalogue = FirmwareCatalogue(parent_mo_or_dn=top_system)
    firmware_downloader = FirmwareDownloader(
        parent_mo_or_dn=firmware_catalogue,
        file_name=file_name)
    firmware_downloader.remote_path = remote_path
    firmware_downloader.protocol = protocol
    firmware_downloader.server = hostname
    firmware_downloader.user = username
    firmware_downloader.pwd = password
    firmware_downloader.admin_state = \
        FirmwareDownloaderConsts.ADMIN_STATE_RESTART

    handle.add_mo(firmware_downloader, modify_present=True)
    handle.commit()