Re: can not set up wrapper for module: nimclient

Xander Cage <[email protected]> Mon, 8 Jul 2024 06:23:32 -0700 (PDT)
Newsgroups gmane.comp.sysutils.cfengine.general
Message-ID <[email protected]>
the nimclient script returns exactly what the agent requires...

root@nimvie: /root # /var/cfengine/modules/packages/nimclient 
supports-api-version < /dev/null
1




On Monday, July 8, 2024 at 3:05:19 PM UTC+2 [email protected] wrote:

> Hello,
>
> The C code you found is correct as far as I can tell. The "!= 0" condition 
> that comes first is checking that the communication worked, not checking 
> the actual response code which is set in the response variable which is an 
> Rlist and we get the api_version from the first entry in that list.
>
> I will look more at this now and get back with more ideas/suggestions.
>
> -Craig
>
> On Thursday, July 4, 2024 at 9:09:51 AM UTC-5 Xander Cage wrote:
>
>> i took a look at cf-agent/package_module.c...
>>
>> static int NegotiateSupportedAPIVersion(PackageModuleWrapper *wrapper)
>> {
>>     assert(wrapper);
>>
>>     Log(LOG_LEVEL_DEBUG, "Getting supported API version.");
>>
>>     int api_version = -1;
>>
>>     Rlist *response = NULL;
>>     if (PackageWrapperCommunicate(wrapper, "supports-api-version", "",
>>                                   &response) != 0)
>>     {
>>         Log(LOG_LEVEL_INFO,
>>             "Error occurred while getting supported API version.");
>>         return -1;
>>     }
>>
>>     if (response)
>>     {
>>         if (RlistLen(response) == 1)
>>         {
>>             api_version = atoi(RlistScalarValue(response));
>>             Log(LOG_LEVEL_DEBUG, "package wrapper API version: %d", 
>> api_version);
>>         }
>>         RlistDestroy(response);
>>     }
>>     return api_version;
>> }
>>
>>
>> this looks somewhat "weird" to me...
>>
>> if (PackageWrapperCommunicate(wrapper, "supports-api-version", "",
>>                                   &response) != 0) 
>>
>> isnt the returned "1" from the module also not "0", so its always an 
>> error  except the module returns "0"?
>>
>> On Thursday, July 4, 2024 at 2:57:49 PM UTC+2 Xander Cage wrote:
>>
>>> changing the mock part to this fixes the related error...successfully 
>>> stolen from the pksrc module...
>>>
>>> if [ -n "$CFENGINE_TEST_NIMCLIENT_MOCK" ]; then
>>>
>>> still no idea concerning the api check...
>>>
>>> On Thursday, July 4, 2024 at 2:39:17 PM UTC+2 Xander Cage wrote:
>>>
>>>> seems this part in the nimclient script is not working, hence the " 
>>>> cat: cannot open ../../tests/unit/mock_lslpp_Lc " error...
>>>>
>>>> # Set up mock environment if necessary
>>>> # This is not well developed as I don't have continuous access to aix 
>>>> and nim
>>>> # nor am I an expert
>>>> CFENGINE_TEST_NIMCLIENT_MOCK=false
>>>> if [ -n "$CFENGINE_TEST_NIMCLIENT_MOCK"  = "true" ]; then
>>>>     list_installed_packages() {
>>>>         cat ../../tests/unit/mock_lslpp_Lc
>>>>      }
>>>>     nimclient_showres() {
>>>>         # This lists the AVAILABLE packages in the nim repo
>>>>         cat ../../tests/unit/mock_nimclient_showres
>>>>     }
>>>>     nimclient_install_package() {
>>>>         # Ugh, not sure what this should do to mock. I think that 
>>>> nimclient
>>>>         # return codes kind of suck, might need to parse the output?
>>>>         echo nimclient -o cust -a lpp_source=${lpp_source} -a 
>>>> filesets=\"${Name}\" >&2
>>>>     }
>>>>     remove_package() {
>>>>         echo installp -u "${Name}" >&2
>>>>     }
>>>> else
>>>>     list_installed_packages() {
>>>>         lslpp -Lc
>>>>     }
>>>>     nimclient_showres() {
>>>>         /usr/sbin/nimclient -o showres -a resource=${lpp_source} -a 
>>>> installp_flags=L
>>>>     }
>>>>     nimclient_install_package() {
>>>>         /usr/sbin/nimclient -o cust -a lpp_source=${lpp_source} -a 
>>>> filesets=\"${Name}\" 1>&2
>>>>     }
>>>>     remove_package() {
>>>>         installp -u "${Name}" 1>&2
>>>>     }
>>>> fi
>>>>
>>>> no idea why CFENGINE_TEST_NIMCLIENT_MOCK=false is not evaluated 
>>>> correctly...
>>>>
>>>> same for this part...
>>>>
>>>> supports_api_version () {
>>>>     echo 1
>>>> }
>>>>
>>>> should work, but fails...strange
>>>>
>>>>
>>>>
>>>>
>>>>
>>>> On Thursday, July 4, 2024 at 12:20:43 PM UTC+2 Xander Cage wrote:
>>>>
>>>>> fun fact...i noticed on some clients the error changed to this after 
>>>>> upgrading binaries...
>>>>>
>>>>> cat: cannot open ../../tests/unit/mock_lslpp_Lc
>>>>>
>>>>> On Thursday, July 4, 2024 at 12:13:56 PM UTC+2 Xander Cage wrote:
>>>>>
>>>>>> upgrade binaries to 3.21.5...error persists
>>>>>>
>>>>>> On Thursday, July 4, 2024 at 11:08:06 AM UTC+2 Xander Cage wrote:
>>>>>>
>>>>>>> Hi,
>>>>>>>
>>>>>>> after upgrading masterfiles to 3.21.5 cf-agent spills this error...
>>>>>>>
>>>>>>> Q: ".../cf-agent" --de":    error: Unsupported package module 
>>>>>>> wrapper API version: -1
>>>>>>> Q: ".../cf-agent" --de":    error: Can not set up wrapper for 
>>>>>>> module: nimclient
>>>>>>>
>>>>>>> agent is still on 3.21.4...maybe this is the root cause of this...
>>>>>>>
>>>>>>> chris
>>>>>>>
>>>>>>

-- 
You received this message because you are subscribed to the Google Groups "help-cfengine" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/help-cfengine/962cd066-c86a-4f0b-9d52-064916f3412an%40googlegroups.com.