Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added pywbemlistener command #971

Merged
merged 1 commit into from
May 21, 2021
Merged

Conversation

andy-maier
Copy link
Contributor

@andy-maier andy-maier commented May 11, 2021

At this point, the new 'pywbemlistener' command is ready for review and merge.
For details, see commit message.

DEFERRED to separate issues:

DROPPED:

  • Rename those of the PYWBEMCLI_* environment variables that are common. It seems that for the same reason we keep the CERTFILE/KEYFILE variables separate, we should also keep the other two variables for PDB and LOG separate.

@andy-maier andy-maier self-assigned this May 11, 2021
@andy-maier andy-maier added this to the 1.0.0 milestone May 11, 2021
@andy-maier andy-maier changed the title Added pywbemlistener command [WIP] Added pywbemlistener command May 11, 2021
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 7 times, most recently from 62ecc4f to 4cddb41 Compare May 13, 2021 06:09
@andy-maier andy-maier requested a review from KSchopmeyer May 13, 2021 06:17
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from 4cddb41 to 714bfc1 Compare May 13, 2021 06:40
@coveralls
Copy link

coveralls commented May 13, 2021

Coverage Status

Coverage decreased (-11.1%) to 81.719% when pulling 3850827 on andy/pywbemlistener-command into c0b4b35 on master.

@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from 714bfc1 to 1432e95 Compare May 13, 2021 06:43
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 3 times, most recently from a880e4c to e7f3d9b Compare May 13, 2021 07:35
@andy-maier
Copy link
Contributor Author

andy-maier commented May 13, 2021

DISCUSSION-DONE: How to specify the indication processing options

Proposal:

  • Separate options that can all be specified -> each indication can have multiple processors
  • --indi-file FILE - append to FILE, in a one-line format
  • --indi-display - display on stdout, in a one-line format
  • --indi-call MODULE.FUNC - call a Python function
  • --indi-format FORMAT - define one-line format using new string formatting

The latest update of the PR implements this proposal.

Update: We decided to go with this proposal for now and adjust as we learn.

@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 2 times, most recently from 993b3e5 to cdacaeb Compare May 13, 2021 19:38
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 3 times, most recently from d31a3e6 to 1b4aa55 Compare May 14, 2021 06:19
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from 1b4aa55 to 3d10953 Compare May 14, 2021 15:03
@andy-maier andy-maier changed the title [WIP] Added pywbemlistener command Added pywbemlistener command May 15, 2021
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 2 times, most recently from 79307aa to e779ae2 Compare May 15, 2021 08:14
@andy-maier
Copy link
Contributor Author

andy-maier commented May 15, 2021

DISCUSSION: How to specify logging

There are some differences to pywbemcli: In pywbemcli, logging is basically deferred to pywbem which makes sense for that command. One pywbemcli invocation deals with one WBEM server, and each invocation can specify a separate log file if needed. In case of pywbemlistener, there are multiple listeners running, each of which should log to a separate file. Another difference is that in pywbemlistener we want to simply log stdout/stderr of the run commands and not internal APIs or HTTP protocol (even though that could be added at some point).

Proposal:

  • Instead of using the logging specification from pywbemcli, use a simple --logdir option that specifies the path name of a log directory. The file name is automatically generated from the listener name and is pywbemlistener_NAME.log in that directory. Not specifying the --logdir option disables logging.

The latest update of the PR implements this proposal.

COMMENT:KS I have no problems with this proposal.

@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from ef2f931 to f831765 Compare May 15, 2021 14:45
@KSchopmeyer
Copy link
Contributor

I did some review and made some comments. I am testing with open pegasus but getting inconsistent results from pegasus test indcation provider for some reason. I have gotten display in some cases but not all.

@KSchopmeyer
Copy link
Contributor

I thin a flag that would provide summary results either to a running listener or to one closing (number received, starttim, end time,)
would be logical. Since we cannot sync start / end of listener against start/end of sending indications from server anything like indications/sec may well be meaningless unless presented as a table (i.e per some period) but would be nice

I am going to continue to test with openpegasus to sort out why I am having issues getting indications on consistent basis.

@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from f831765 to 0bad58e Compare May 15, 2021 15:08
@KSchopmeyer
Copy link
Contributor

Some test results from pegasus

===================================

pywbemlistener run lis1 --port 50000 --protocol http --indi-display --indi-format "{dt} {c}"
Running listener lis1 at http://localhost:50000
2021-05-15 10:11:56.323227-05:00 Test_IndicationProviderClass
2021-05-15 10:11:56.326560-05:00 Test_IndicationProviderClass
...

==================================================


$ pywbemlistener run lis1 --port 50000 --protocol http --indi-display
Running listener lis1 at http://localhost:50000
2021-05-15 10:13:12.414368-05:00 127.0.0.1 Test_IndicationProviderClass IndicationIdentifier='41' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 13, 12, 406809, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621091592338226' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 0)
2021-05-15 10:13:12.418567-05:00 127.0.0.1 Test_IndicationProviderClass IndicationIdentifier='42' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 13, 12, 408907, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621091592338226' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 1)

. . .

============================================


pywbemlistener run lis1 --port 50000 --protocol http --indi-display --indi-format "{dt} {h} {p}"
Running listener lis1 at http://localhost:50000
2021-05-15 10:16:52.945235-05:00 127.0.0.1 IndicationIdentifier='61' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 16, 52, 938319, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621091812873408' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 0)
2021-05-15 10:16:52.949150-05:00 127.0.0.1 IndicationIdentifier='62' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 16, 52, 940260, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621091812873408' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 1)

==============================================

Test with indi-call where i created a new package with one very simple function

def myindication(indication, host):
    print(indication.tomof())

Produces


(pycli39issue395) kschopmeyer@leonard:~/pywbem/pycli39issue395/pywbemtools/testlistfun(andy/pywbemlistener-command)$ pywbemlistener run lis1 --port 50000 --protocol http --indi-display --indi-call testlistfun.myindication
Running listener lis1 at http://localhost:50000
instance of Test_IndicationProviderClass {
   IndicationIdentifier = "1";
   IndicationTime = "20210515103810.732697-300";
   CorrelatedIndications = { };
   MethodName = "SendTestIndicationsCount";
   SequenceContext =
      "PG:IndicationService-PG:127-0-1-1-1621091383113453-1621093090648398";
   SequenceNumber = 0;
};

2021-05-15 10:38:10.740901-05:00 127.0.0.1 Test_IndicationProviderClass IndicationIdentifier='1' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 38, 10, 732697, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621093090648398' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 0)
instance of Test_IndicationProviderClass {
   IndicationIdentifier = "2";
   IndicationTime = "20210515103810.734972-300";
   CorrelatedIndications = { };
   MethodName = "SendTestIndicationsCount";
   SequenceContext =
      "PG:IndicationService-PG:127-0-1-1-1621091383113453-1621093090648398";
   SequenceNumber = 1;
};

2021-05-15 10:38:10.745286-05:00 127.0.0.1 Test_IndicationProviderClass IndicationIdentifier='2' IndicationTime=CIMDateTime(cimtype='datetime', datetime=datetime.datetime(2021, 5, 15, 10, 38, 10, 734972, tzinfo=MinutesFromUTC(offset=-300)), timedelta=None, precision=None), minutes_from_utc=-300) CorrelatedIndications=[] MethodName='SendTestIndicationsCount' SequenceContext='PG:IndicationService-PG:127-0-1-1-1621091383113453-1621093090648398' SequenceNumber=Sint64(cimtype='sint64', minvalue=-9223372036854775808, maxvalue=9223372036854775807, 1)

==============================================

@KSchopmeyer
Copy link
Contributor

KSchopmeyer commented May 15, 2021

did first test of the MODULE.FUNCTION capability shown above but to do it I created a temp package. I did not figure out how to defined a module alone. (I assumed it would be a python file at the directory level of the call but that did not work).

When I execute sys.path in python 3.9, the current directory shows up in the list. ..'/home/kschopmeyer/pywbem/pycli39issue395/pywbemtools']

@andy-maier
Copy link
Contributor Author

andy-maier commented May 15, 2021

On using --indi-call: I tried both a single-file module and a package to verify that both work:

Single-file module:

./tmp_display_callback.py - with function display()

$ pywbemlistener start lis1 --protocol http --indi-call tmp_display_callback.display

Package:

./tmp_try/__init__.py - empty
./tmp_try/display_callback.py - with function display()

$ pywbemlistener start lis1 --protocol http --indi-call tmp_try.display_callback.display

Both approaches require that Python includes the current directory in its module search path. I have verified that sys.path contains the current directory at the end, on my macOS, in a virtualenv created with virtualenv:

'/Users/maiera/virtualenvs/pywbemtools38/bin'
'/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python38.zip'
'/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8'
'/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload'
'/Users/maiera/virtualenvs/pywbemtools38/lib/python3.8/site-packages'
'/Users/maiera/PycharmProjects/pywbem/pywbemtools' <-- current directory

DISCUSSION:

Can you please verify whether the current directory is in your sys.path? BTW, strangely enough, invoking just the python command in that same environment in addition has the empty path as the first item in the list, which also is the current directory.

The latest update to this PR adds the current directory to the module search path before we import the module with the callback function.

NOTE: Tested on latest version over weekend and it works. Can use module in current directory or a package.

@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch 3 times, most recently from b0a95f5 to 257e0f9 Compare May 16, 2021 21:27
Copy link
Contributor

@KSchopmeyer KSchopmeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that a number of the comments are ideas. Thus, if we can do the count through the function call, that would be fine with me for now. Most important. I thin that functionally this is very close to merge and merging it is more important that more functionality right now. That way I can work with it while you are gone.

@KSchopmeyer
Copy link
Contributor

NOTE: I have tested most of the functionality using OpenPegasus as indication generator. But this is only with http. Have not tested https at all but I can do that after this commit. We do have an issue between the OpenPegasus test indication and listener when I send significant groups of indications, ex. 100 at a time. Works a few times and then slows down and/or stops. I do not know which side is the issue. Note that the first group passes VERY fast (within a couple of seconds). I suspect OpenPegasus but it is going to take more detailed testing to sort that out.

@andy-maier
Copy link
Contributor Author

We agreed in the meeting to merge this PR with the changes as documented.

Details:

* Added a new 'pywbemlistener' command that manages WBEM indication
  listeners. (see issue #430)

* Removed Python 3.4 on Windows from GitHub Actions tests, because this environment
  does not have the Microsoft Visual C++ 10.0 compiler needed for building the
  'psutils' package.

Signed-off-by: Andreas Maier <[email protected]>
@andy-maier andy-maier force-pushed the andy/pywbemlistener-command branch from 257e0f9 to 3850827 Compare May 21, 2021 16:34
@andy-maier andy-maier merged commit a63045b into master May 21, 2021
@andy-maier andy-maier deleted the andy/pywbemlistener-command branch May 21, 2021 18:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants