예제 #1
0
def configure_storage_flex_flash_controller(handle,
                                            parent_dn,
                                            flex_id,
                                            operation_request,
                                            admin_slot_number="NA",
                                            wait_operation_completion=True):
    """
    This method configures the storage card for flex controller.

    Args:
        handle (UcsHandle)
        parent_dn (string): Parent Dn of the controller
        operation_request (string): format/reset/pair
        admin_slot_number (string): 1/2/NA
        flex_id : ID of Storage Flex
        wait_operation_completion : True/False

    Returns:
        None

    Raises:
        ValueError: If StorageFlexFlashController is not present

    Example:
        a. To Reset the SD Card.
        configure_storage_flex_flash_controller(handle,flex_id="1",
                                                operation_request="reset",
                                                admin_slot_number="NA")
        b. To Format the SD Card.
        configure_storage_flex_flash_controller(handle,flex_id="1",
                                                operation_request="format",
                                                admin_slot_number="NA")

        c. To Auto-Sync the SD Card.
        configure_storage_flex_flash_controller(handle,flex_id="1",
                                                operation_request="pair",
                                                admin_slot_number="1")

    """

    from ucsmsdk.mometa.storage.StorageFlexFlashController import \
        StorageFlexFlashController

    dn = parent_dn + "/board"
    q_mo = handle.query_dn(dn)
    if q_mo is not None:
        mo = StorageFlexFlashController(parent_mo_or_dn=dn,
                                        id=flex_id,
                                        operation_request=operation_request,
                                        admin_slot_number=admin_slot_number)
        handle.add_mo(mo, True)
        handle.commit()
        if wait_operation_completion:
            # add a watch on sp
            event_handle = UcsEventHandle(handle)
            _operation_monitor(handle=handle, event_handle=event_handle, mo=mo)
            while not end_script:
                time.sleep(1)
    else:
        raise ValueError("Storage Flex controller does not exists.")
예제 #2
0
def setup_module():
    from ucsmsdk.ucseventhandler import UcsEventHandle
    from ucsmsdk.mometa.ls.LsServer import LsServer

    global handle, sp, ueh
    handle = custom_setup()
    ueh = UcsEventHandle(handle)
    org = handle.query_dn("org-root")

    sp = LsServer(org, name="eventhandle", descr="")
    handle.add_mo(sp, True)
    handle.commit()
예제 #3
0
def sp_disassociate(handle, sp_dn):
    """
    Dissociates a service profile from server

    Args:
        handle (UcsHandle)
        sp_dn (string): dn of service profile

    Returns:
        None

    Raises:
        ValueError: If LsServer is not present Or
                    ComputeBlade or ComputeRack not present Or
                    Service profile is already dissociated Or

    Example:
        sp_disassociate(handle, sp_dn="org-root/ls-chassis1-blade1")
    """

    # check if sp exists
    sp = handle.query_dn(sp_dn)
    if sp is None:
        raise ValueError("Service profile '%s' does not exist." % sp_dn)

    dn = sp.dn + "/pn"
    mo = handle.query_dn(dn)
    if mo is None:
        raise ValueError("Service Profile '%s' already dissociated." % dn)

    handle.remove_mo(mo)
    handle.commit()

    # add a watch on sp
    event_handle = UcsEventHandle(handle)
    _sp_disassociate_monitor(event_handle=event_handle, mo=sp)

    while not end_script:
        time.sleep(1)
    event_handle.clean()
예제 #4
0
def sp_disassociate(handle, sp_dn):
    """
    Dissociates a service profile from server

    Args:
        handle (UcsHandle)
        sp_dn (string): dn of service profile

    Returns:
        None

    Raises:
        ValueError: If LsServer is not present Or
                    ComputeBlade or ComputeRack not present Or
                    Service profile is already dissociated Or

    Example:
        sp_disassociate(handle, sp_dn="org-root/ls-chassis1-blade1")
    """

    # check if sp exists
    sp = handle.query_dn(sp_dn)
    if sp is None:
        raise ValueError("Service profile '%s' does not exist." % sp_dn)

    dn = sp.dn + "/pn"
    mo = handle.query_dn(dn)
    if mo is None:
        raise ValueError("Service Profile '%s' already dissociated." % dn)

    handle.remove_mo(mo)
    handle.commit()

    # add a watch on sp
    event_handle = UcsEventHandle(handle)
    _sp_disassociate_monitor(event_handle=event_handle, mo=sp)

    while not end_script:
        time.sleep(1)
    event_handle.clean()
def main():
    global handle
    global ucs_event_handler
    global assoc_done

    handle = ucs_login()
    ucs_event_handler = UcsEventHandle(handle)

    sp_create()
    sp_assoc()

    # Wait for the background processing to complete.
    # quit when end_script flag is set to True
    while not end_script:
        time.sleep(1)
예제 #6
0
def setup_module():
    from ucsmsdk.ucseventhandler import UcsEventHandle
    from ucsmsdk.mometa.ls.LsServer import LsServer

    global handle, sp, ueh
    handle = custom_setup()
    if not handle:
        msg = get_skip_msg()
        raise SkipTest(msg)
    ueh = UcsEventHandle(handle)
    org = handle.query_dn("org-root")

    sp = LsServer(org, name="eventhandle-test", descr="")
    handle.add_mo(sp, True)
    handle.commit()
예제 #7
0
def sp_disassociate(handle, sp_dn):

    # check if sp exists
    sp = handle.query_dn(sp_dn)
    if sp is None:
        raise ValueError("Service profile '%s' does not exist." % sp_dn)

    dn = sp.dn + "/pn"
    mo = handle.query_dn(dn)
    if mo is None:
        raise ValueError("Service Profile '%s' already dissociated." % dn)

    handle.remove_mo(mo)
    handle.commit()

    # add a watch on sp
    event_handle = UcsEventHandle(handle)
    _sp_disassociate_monitor(event_handle=event_handle, mo=sp)

    while not end_script:
        time.sleep(1)
예제 #8
0
def sp_associate(handle, sp_dn, server_dn, wait_assoc_completion=True):

    from ucsmsdk.mometa.ls.LsBinding import LsBinding

    # check if sp exists
    sp = handle.query_dn(sp_dn)
    if sp is None:
        raise ValueError("Service profile '%s' does not exist." % sp_dn)

    # check if dn exists
    blade = handle.query_dn(server_dn)
    if blade is None:
        raise ValueError("Server '%s' does not exist." % server_dn)

    # check if sp is already associated with blade
    if sp.assoc_state == LsServerConsts.ASSOC_STATE_ASSOCIATED \
            and sp.pn_dn == server_dn:
        raise ValueError("Service Profile is already associated with Server %s" % (server_dn))

    # check if sp already has lsBinding with blade
    binding = handle.query_dn(sp_dn + "/pn")
    if binding is not None and binding.pn_dn == server_dn:
        raise ValueError("Service Profile is already administratively associated with Server %s" % (server_dn))

    mo = LsBinding(parent_mo_or_dn=sp_dn, pn_dn=server_dn,
                   restrict_migration="no")
    handle.add_mo(mo, modify_present=True)
    handle.commit()

    if wait_assoc_completion:
		# add a watch on sp
		event_handle = UcsEventHandle(handle)
		_sp_associate_monitor(event_handle=event_handle, mo=sp)

		while not end_script:
			time.sleep(1)
예제 #9
0
def firmware_auto_install(handle,
                          version,
                          image_dir,
                          infra_only=False,
                          infra=True,
                          blade=True,
                          rack=False,
                          require_user_confirmation=True):
    """
    This will do end-to-end processing to update firmware on ucsm.

    Args:
        handle (UcsHandle)
        version (string): firmware version
        image_dir (string): image directory
        infra_only (bool): by default False. If set to True, will update
                          firmware of FI only
        require_user_confirmation (bool): by default True. If False needs no
                                          user intervention.

    Returns:
        None

    Example:
        firmware_auto_install(handle, version="2.2.5b",
                              image_dir="/home/imagedir")
    """

    from ucsmsdk.ucseventhandler import UcsEventHandle

    try:
        bundle_map = get_firmware_file_names(version)

        bundles = []
        cco_image_list = []
        images_to_upload = []

        if infra_only:
            bundles.append(bundle_map['A'][0])
        else:
            if infra:
                bundles.append(bundle_map['A'][0])
            if blade:
                bundles.append(bundle_map['B'][0])
            if rack:
                bundles.append(bundle_map['C'][0])

        for image in bundles:
            if not is_image_available_on_ucsm(handle, image):
                images_to_upload.append(image)

        for image in images_to_upload:
            log.debug("Checking if image file: '%s' is exist in local "
                      "directory" % image)
            file_path = os.path.join(image_dir, image)
            if os.path.exists(file_path):
                log.debug("Image already exist in image directory ")
            else:
                cco_image_list.append(image)

        # if image not available raising exception to download
        if cco_image_list:
            raise ValueError("Download images %s using firmware_download" %
                             cco_image_list)

        # upload images on ucsm
        for image in images_to_upload:
            log.debug("Uploading image '%s' to UCSM." % image)
            firmware = firmware_add_local(handle, image_dir, image)
            eh = UcsEventHandle(handle)
            eh.add(managed_object=firmware,
                   prop="transfer_state",
                   success_value=['downloaded'],
                   poll_sec=30,
                   timeout_sec=600)
            log.debug("Upload of image file '%s' is completed." % image)

        if infra_only:
            # Activate UCSM
            firmware_activate_infra(
                handle,
                version=version,
                require_user_confirmation=require_user_confirmation)
        else:
            if infra:
                # Activate UCSM
                log.debug("Activating Firmware Infra......")
                firmware_activate_infra(
                    handle,
                    version=version,
                    require_user_confirmation=require_user_confirmation)
            if blade:
                # Activate Blade
                log.debug("Activating Firmware Blade......")
                firmware_activate_blade(
                    handle,
                    version=version,
                    require_user_confirmation=require_user_confirmation)
            if rack:
                # Activate Blade
                log.debug("firmware upgrade code for rack is yet to be done.")
                # firmware_activate_blade(
                #     handle, version=version,
                #     require_user_confirmation=require_user_confirmation)

    except:
        log.debug("Error Occurred in Script.")
        handle.logout()
        raise
예제 #10
0
def firmware_auto_install(handle, version, image_dir, infra_only=False,
                          infra=True, blade=True, rack=False,
                          require_user_confirmation=True):
    """
    This will do end-to-end processing to update firmware on ucsm.

    Args:
        handle (UcsHandle)
        version (string): firmware version
        image_dir (string): image directory
        infra_only (bool): by default False. If set to True, will update
                          firmware of FI only
        require_user_confirmation (bool): by default True. If False needs no
                                          user intervention.

    Returns:
        None

    Example:
        firmware_auto_install(handle, version="2.2.5b",
                              image_dir="/home/imagedir")
    """

    from ucsmsdk.ucseventhandler import UcsEventHandle

    try:
        bundle_map = get_firmware_file_names(version)

        bundles = []
        cco_image_list = []
        images_to_upload = []

        if infra_only:
            bundles.append(bundle_map['A'][0])
        else:
            if infra:
                bundles.append(bundle_map['A'][0])
            if blade:
                bundles.append(bundle_map['B'][0])
            if rack:
                bundles.append(bundle_map['C'][0])

        for image in bundles:
            if not is_image_available_on_ucsm(handle, image):
                images_to_upload.append(image)

        for image in images_to_upload:
            log.debug("Checking if image file: '%s' is exist in local "
                      "directory" % image)
            file_path = os.path.join(image_dir, image)
            if os.path.exists(file_path):
                log.debug("Image already exist in image directory ")
            else:
                cco_image_list.append(image)

        # if image not available raising exception to download
        if cco_image_list:
            raise ValueError("Download images %s using firmware_download" %
                             cco_image_list)

        # upload images on ucsm
        for image in images_to_upload:
            log.debug("Uploading image '%s' to UCSM." % image)
            firmware = firmware_add_local(handle, image_dir, image)
            eh = UcsEventHandle(handle)
            eh.add(managed_object=firmware, prop="transfer_state",
                   success_value=['downloaded'], poll_sec=30,
                   timeout_sec=600)
            log.debug("Upload of image file '%s' is completed." % image)

        if infra_only:
            # Activate UCSM
            firmware_activate_infra(
                handle, version=version,
                require_user_confirmation=require_user_confirmation)
        else:
            if infra:
                # Activate UCSM
                log.debug("Activating Firmware Infra......")
                firmware_activate_infra(
                    handle, version=version,
                    require_user_confirmation=require_user_confirmation)
            if blade:
                # Activate Blade
                log.debug("Activating Firmware Blade......")
                firmware_activate_blade(
                    handle, version=version,
                    require_user_confirmation=require_user_confirmation)
            if rack:
                # Activate Blade
                log.debug("firmware upgrade code for rack is yet to be done.")
                # firmware_activate_blade(
                #     handle, version=version,
                #     require_user_confirmation=require_user_confirmation)

    except:
        log.debug("Error Occurred in Script.")
        handle.logout()
        raise
예제 #11
0
def run(job, resource, *args, **kwargs):
    username = conn.username
    password = conn.password

    organization = "{{ organization }}"
    service_profile_template = "{{ service_profile_template }}"
    create_sp_from_sp_template = "{{ create_sp_from_sp_template }}"
    service_profile_name = "{{ service_profile_name }}"
    service_profile_description = "{{ service_profile_description }}"
    use_blade_servers = "{{ use_blade_servers }}"
    chassis = "{{ chassis }}"
    ucs_server_dn = "{{ ucs_server_dn }}"
    ucs_rack_server = "{{ rack_server }}"
    mac_pool_name = "{{ mac_pool_name }}"

    service_profile_server_dn, _ = CustomField.objects.get_or_create(
        name="service_profile_server_dn",
        label="Service Profile Server DN",
        type="STR",
        show_on_servers=True)

    handler.login()
    ucs_event_handler = UcsEventHandle(handler)

    # create SP in an org
    set_progress(f"Creating service profile named {service_profile_name}")
    if create_sp_from_sp_template == "True":
        dn_set = ucscbasetype.DnSet()
        dn_set.child_add(Dn(value=f"{service_profile_name}"))

        xml_element = mf.ls_instantiate_n_named_template(
            cookie=handler.cookie,
            dn=service_profile_template,
            in_error_on_existing="true",
            in_name_set=dn_set,
            in_target_org=organization)
        handler.process_xml_elem(xml_element)
    else:
        mo = LsServer(parent_mo_or_dn=organization,
                      vmedia_policy_name="",
                      ext_ip_state="none",
                      bios_profile_name="",
                      mgmt_fw_policy_name="",
                      agent_policy_name="",
                      mgmt_access_policy_name="",
                      dynamic_con_policy_name="",
                      kvm_mgmt_policy_name="",
                      sol_policy_name="",
                      uuid="0",
                      descr=service_profile_description,
                      stats_policy_name="default",
                      policy_owner="local",
                      ext_ip_pool_name="ext-mgmt",
                      boot_policy_name="",
                      usr_lbl="",
                      host_fw_policy_name="",
                      vcon_profile_name="",
                      ident_pool_name="",
                      src_templ_name="",
                      local_disk_policy_name="",
                      scrub_policy_name="",
                      power_policy_name="default",
                      maint_policy_name="",
                      name=service_profile_name,
                      resolve_remote="yes")
        mo_1 = LsbootDef(parent_mo_or_dn=mo,
                         descr="",
                         reboot_on_update="no",
                         adv_boot_order_applicable="no",
                         policy_owner="local",
                         enforce_vnic_name="yes",
                         boot_mode="legacy")
        mo_1_1 = LsbootStorage(parent_mo_or_dn=mo_1, order="1")
        mo_1_1_1 = LsbootLocalStorage(parent_mo_or_dn=mo_1_1, )
        mo_1_1_1_1 = LsbootDefaultLocalImage(parent_mo_or_dn=mo_1_1_1,
                                             order="1")
        mo_2 = VnicEther(parent_mo_or_dn=mo,
                         nw_ctrl_policy_name="",
                         name="eth0",
                         admin_host_port="ANY",
                         admin_vcon="any",
                         stats_policy_name="default",
                         admin_cdn_name="",
                         switch_id="A",
                         pin_to_group_name="",
                         mtu="1500",
                         qos_policy_name="",
                         adaptor_profile_name="",
                         ident_pool_name=mac_pool_name,
                         order="unspecified",
                         nw_templ_name="",
                         addr="derived")
        mo_2_1 = VnicEtherIf(parent_mo_or_dn=mo_2,
                             default_net="yes",
                             name="default")
        mo_3 = VnicFcNode(parent_mo_or_dn=mo,
                          ident_pool_name="",
                          addr="pool-derived")
        handler.add_mo(mo)

    # Associate a server to a service profile.
    if use_blade_servers == "True":
        set_progress(
            f"Associating service profile {service_profile_name} with {ucs_server_dn}"
        )
        mo = LsBinding(
            parent_mo_or_dn=f"{organization}/ls-{service_profile_name}",
            pn_dn=ucs_server_dn,
            restrict_migration="no")
    else:
        set_progress(
            f"Associating service profile {service_profile_name} with {ucs_rack_server}"
        )
        mo = LsBinding(
            parent_mo_or_dn=f"{organization}/ls-{service_profile_name}",
            pn_dn=ucs_rack_server,
            restrict_migration="no")

    handler.add_mo(mo)
    handler.commit()
    mo = handler.query_dn(f"{organization}/ls-{service_profile_name}")

    # Save the service profile dn
    resource.service_profile_server_dn = f"{organization}/ls-{service_profile_name}"
    resource.name = service_profile_name
    resource.save()

    return "SUCCESS", f"Created service profile named {service_profile_name}", ""
예제 #12
0
def firmware_auto_install(handle, version, image_dir, infra_only=False):

    from ucsmsdk.ucseventhandler import UcsEventHandle

    try:
        # create version string
        ver_split = version.split('(')
        version_bundle = ver_split[0] + "." + ver_split[1].strip(')')

        bundles = []
        cco_image_list = []

        # create firmware file name for the respective version
        aseries_bundle = "ucs-k9-bundles-infra." + version_bundle + ".A.bin"
        bundles.append(aseries_bundle)

        if not infra_only:
            bseries_bundle = "ucs-k9-bundles-b-series." + version_bundle + \
                             ".B.bin"
            bundles.append(bseries_bundle)

            cseries_bundle = "ucs-k9-bundles-c-series." + version_bundle + \
                             ".C.bin"
            bundles.append(cseries_bundle)

        print("Starting Firmware download process to local directory: %s" %
              image_dir)

        # adding files to cco image list if not available in local directory
        for bundle in bundles:
            file_path = os.path.join(image_dir, bundle)
            if os.path.exists(file_path):
                print("Image already exist in image directory ")
            else:
                cco_image_list.append(bundle)

        # if image not available raising exception to download
        if cco_image_list:
            raise ValueError("Download images %s using firmware_download" %
                             cco_image_list)

        # check if image is already uploaded to ucs domain
        for image in bundles:
            print("Checking if image file: '%s' is already uploaded to UCS "
                  "Domain" % image)

            deleted = False
            filter_str = '(name, %s, type="eq")' % image
            firmware_package = handle.query_classid(
                class_id="FirmwareDistributable", filter_str=filter_str)[0]
            if firmware_package:
                firmware_dist_image = handle.query_children(
                    in_mo=firmware_package, class_id="FirmwareDistImage")[0]
                if firmware_dist_image:
                    if firmware_dist_image.image_deleted != "":
                        deleted = True

            # image does not exist then upload
            if deleted or not firmware_package:
                print("Uploading file to UCSM.")
                firmware = firmware_add_local(handle, image_dir, image)
                eh = UcsEventHandle(handle)
                eh.add(managed_object=firmware, prop="transfer_state",
                       success_value=['downloaded'], poll_sec=30,
                       timeout_sec=600)
                print("Upload of image file '%s' is completed." % image)

            else:
                print("Image file '%s' is already upload available on UCSM" %
                      image)

        # Activate UCSM
        firmware_activate_ucsm(handle, version=version)

        if not infra_only:
            # Activate Blade
            firmware_activate_blade(handle, version=version)
    except:
        print("Error Occurred in Script.")
        handle.logout()
        raise
예제 #13
0
def firmware_auto_install(handle, version, image_dir, infra_only=False):
    """
    This will do end-to-end processing to update firmware on ucsm.

    Args:
        handle (UcsHandle)
        version (string): firmware version
        image_dir (string): image directory
        infra_only (bool): by default False. If set to True, will update
                          firmware of FI only

    Returns:
        None

    Example:
        firmware_auto_install(handle, version="2.2.5b",
                              image_dir="/home/imagedir")
    """

    from ucsmsdk.ucseventhandler import UcsEventHandle

    try:
        bundle_map = get_firmware_file_names(version)

        bundles = []
        cco_image_list = []

        bundles.append(bundle_map['A'][0])

        if not infra_only:
            bundles.append(bundle_map['B'][0])
            bundles.append(bundle_map['C'][0])

        log.debug("Starting Firmware download process to local directory: %s" %
                  image_dir)

        # adding files to cco image list if not available in local directory
        for bundle in bundles:
            file_path = os.path.join(image_dir, bundle)
            if os.path.exists(file_path):
                log.debug("Image already exist in image directory ")
            else:
                cco_image_list.append(bundle)

        # if image not available raising exception to download
        if cco_image_list:
            raise ValueError("Download images %s using firmware_download" %
                             cco_image_list)

        # check if image is already uploaded to ucs domain
        for image in bundles:
            log.debug("Checking if image file: '%s' is already uploaded to UCS"
                      " Domain" % image)

            deleted = False
            filter_str = '(name, %s, type="eq")' % image
            firmware_package = handle.query_classid(
                class_id="FirmwareDistributable", filter_str=filter_str)
            if firmware_package:
                firmware_dist_image = handle.query_children(
                    in_mo=firmware_package[0], class_id="FirmwareDistImage")
                if firmware_dist_image:
                    firmware_dist_image = firmware_dist_image[0]
                    if firmware_dist_image.image_deleted != "":
                        deleted = True

            # image does not exist then upload
            if deleted or not firmware_package:
                log.debug("Uploading file to UCSM.")
                firmware = firmware_add_local(handle, image_dir, image)
                eh = UcsEventHandle(handle)
                eh.add(managed_object=firmware, prop="transfer_state",
                       success_value=['downloaded'], poll_sec=30,
                       timeout_sec=600)
                log.debug("Upload of image file '%s' is completed." % image)

            else:
                log.debug("Image file '%s' is already upload available on "
                          "UCSM" % image)

        # Activate UCSM
        firmware_activate_infra(handle, version=version)

        if not infra_only:
            # Activate Blade
            firmware_activate_blade(handle, version=version)
    except:
        log.debug("Error Occurred in Script.")
        handle.logout()
        raise
예제 #14
0
def firmware_auto_install(handle, version, image_dir, infra_only=False):

    from ucsmsdk.ucseventhandler import UcsEventHandle

    try:
        # create version string
        ver_split = version.split('(')
        version_bundle = ver_split[0] + "." + ver_split[1].strip(')')

        bundles = []
        cco_image_list = []

        # create firmware file name for the respective version
        aseries_bundle = "ucs-k9-bundles-infra." + version_bundle + ".A.bin"
        bundles.append(aseries_bundle)

        if not infra_only:
            bseries_bundle = "ucs-k9-bundles-b-series." + version_bundle + \
                             ".B.bin"
            bundles.append(bseries_bundle)

            cseries_bundle = "ucs-k9-bundles-c-series." + version_bundle + \
                             ".C.bin"
            bundles.append(cseries_bundle)

        print("Starting Firmware download process to local directory: %s" %
              image_dir)

        # adding files to cco image list if not available in local directory
        for bundle in bundles:
            file_path = os.path.join(image_dir, bundle)
            if os.path.exists(file_path):
                print("Image already exist in image directory ")
            else:
                cco_image_list.append(bundle)

        # if image not available raising exception to download
        if cco_image_list:
            raise ValueError("Download images %s using firmware_download" %
                             cco_image_list)

        # check if image is already uploaded to ucs domain
        for image in bundles:
            print("Checking if image file: '%s' is already uploaded to UCS "
                  "Domain" % image)

            deleted = False
            filter_str = '(name, %s, type="eq")' % image
            firmware_package = handle.query_classid(
                class_id="FirmwareDistributable", filter_str=filter_str)[0]
            if firmware_package:
                firmware_dist_image = handle.query_children(
                    in_mo=firmware_package, class_id="FirmwareDistImage")[0]
                if firmware_dist_image:
                    if firmware_dist_image.image_deleted != "":
                        deleted = True

            # image does not exist then upload
            if deleted or not firmware_package:
                print("Uploading file to UCSM.")
                firmware = firmware_add_local(handle, image_dir, image)
                eh = UcsEventHandle(handle)
                eh.add(managed_object=firmware,
                       prop="transfer_state",
                       success_value=['downloaded'],
                       poll_sec=30,
                       timeout_sec=600)
                print("Upload of image file '%s' is completed." % image)

            else:
                print("Image file '%s' is already upload available on UCSM" %
                      image)

        # Activate UCSM
        firmware_activate_ucsm(handle, version=version)

        if not infra_only:
            # Activate Blade
            firmware_activate_blade(handle, version=version)
    except:
        print("Error Occurred in Script.")
        handle.logout()
        raise