예제 #1
0
def _get_osimages(module, kwargs):
    result = None
    try:
        with connection_object(module, kwargs) as con:
            osimages_info = kwargs.get('osimages_info')
            osimages_dict = kwargs.get('osimages_dict')
            if osimages_info and osimages_dict:
                result = osimages(con, osimages_info, **osimages_dict)
            elif osimages_dict:
                result = osimages(con, **osimages_dict)

            elif osimages_info:
                result = osimages(con, osimages_info)
            else:
                result = osimages(con)
    except Exception as err:
        module.fail_json(msg="Error processing osimages " + str(err))
    return result
예제 #2
0
def _get_osimages(module, kwargs):
    result = None
    try:
        with connection_object(module, kwargs) as con:
            subcmd = kwargs.get('subcmd')
            osimages_dict = kwargs.get('osimages_dict')
            if subcmd and osimages_dict:
                json_str = json.dumps(osimages_dict)
                if subcmd in ['import']:
                    result = osimages(con,
                                      subcmd,
                                      imagetype=kwargs.get('imagetype'),
                                      osimages_dict=json_str)
                elif subcmd in ['hostsettings']:
                    result = osimages(con,
                                      subcmd,
                                      action=osimages_dict['action'],
                                      osimages_dict=json_str)
                else:
                    result = osimages(con, subcmd, osimages_dict=json_str)
            elif subcmd in ['delete']:
                result = osimages(con, subcmd, id=kwargs.get('id'))
            elif subcmd in ['import']:
                result = osimages(con,
                                  subcmd,
                                  imagetype=kwargs.get('imagetype'))
            elif subcmd:
                result = osimages(con, subcmd)
    except Exception as err:
        module.fail_json(msg="Error processing osimages " + str(err))
    return result