def _update_firmware_all(module, kwargs):
    global __changed__
    result = None
    try:
        with connection_object(module, kwargs) as con:
            rep = updatepolicy(con, info="NAMELIST")
            uuid_list = _valid_compliance_policies(rep['policies'])
            if len(uuid_list) == 0:
                module.fail_json(msg="No policy assigned to any device")
                return result

            dev_uuid_list = []
            if 'uuid_list' in kwargs:
                dev_uuid_list = kwargs.get('uuid_list')
                if len(dev_uuid_list) > 0:
                    # getting common uuid of two list
                    uuid_list = list(
                        set(dev_uuid_list).intersection(uuid_list))

            rep = updatecomp(con, query='components')
            ret_dev_list = rep['DeviceList']
            mod_dev_list = _transform_devicelist(ret_dev_list, uuid_list)
            if len(mod_dev_list) == 0:
                module.fail_json(
                    msg="No updateable component with assigned policy found")
                return result

            result = updatecomp(con,
                                mode=kwargs.get('mode'),
                                action=kwargs.get('lxca_action'),
                                dev_list=mod_dev_list)
            __changed__ = True
    except Exception as err:
        module.fail_json(msg="Error updating all device firmware " + str(err))
    return result
Esempio n. 2
0
def _update_firmware_query_comp(module, kwargs):
    result = None
    try:
        with connection_object(module, kwargs) as con:
            result = updatecomp(con, 'info', query='components')
    except Exception as err:
        module.fail_json(msg="Error updating firmware " + str(err))
    return result
Esempio n. 3
0
def _update_firmware_all(module, kwargs):
    global __changed__
    result = None
    try:
        with connection_object(module, kwargs) as con:
            rep = updatepolicy(con, 'query', info="NAMELIST")
            uuid_list = _valid_compliance_policies(rep['policies'])
            if len(uuid_list) == 0:
                module.fail_json(msg="No policy assigned to any device")
                return result

            dev_uuid_list = []
            if 'uuid_list' in kwargs:
                dev_uuid_list = kwargs.get('uuid_list')
                if len(dev_uuid_list) > 0:
                    # getting common uuid of two list
                    uuid_list = list(
                        set(dev_uuid_list).intersection(uuid_list))

            rep = updatecomp(con, 'info', query='components')
            ret_dev_list = rep['DeviceList']
            mod_dev_list = _transform_devicelist(ret_dev_list, uuid_list)
            if len(mod_dev_list) == 0:
                module.fail_json(
                    msg="No updateable component with assigned policy found")
                return result

            # removing component with DoNotUpdate
            rep = updatepolicy(con, 'query', info="RESULT")
            skip_components = _get_do_not_update_components(
                module, rep['policies'])
            _call_remove_components(skip_components, mod_dev_list)

            final_dev = {}
            final_dev['DeviceList'] = mod_dev_list
            dev_json_str = json.dumps(final_dev)
            result = updatecomp(con,
                                'apply',
                                mode=kwargs.get('mode'),
                                action=kwargs.get('lxca_action'),
                                dev_list=dev_json_str)
            __changed__ = True
    except Exception as err:
        module.fail_json(msg="Error updating all device firmware " + str(err))
    return result
def _update_firmware(module, kwargs):
    global __changed__
    result = None
    try:
        with connection_object(module, kwargs) as con:
            result = updatecomp(con,
                                mode=kwargs.get('mode'),
                                action=kwargs.get('lxca_action'),
                                cmm=kwargs.get('cmm'),
                                switch=kwargs.get('switch'),
                                server=kwargs.get('server'),
                                storage=kwargs.get('storage'))
        __changed__ = True
    except Exception as err:
        module.fail_json(msg="Error updating firmware " + str(err))
    return result