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

Diagram class related to #127 #135

Open
wants to merge 14 commits into
base: main
Choose a base branch
from
Open

Diagram class related to #127 #135

wants to merge 14 commits into from

Conversation

sunami09
Copy link
Collaborator

  • Added graphviz to the list of installed dependencies
  • Updated the Python dependencies to include the diagrams package.
  • Added two new icons (host.png, switch.png) in /srv/icons/ for use in the diagram generation.
  • A new DiagramWorker class in RTMonLibs/DiagramWorker.py responsible for generating network topology diagrams using the diagrams package.
  • Added logic in worker.py to delete generated diagram images when executions are deleted.
  • Integrated DiagramWorker into the template creation process
  • The generated diagrams are saved under /srv/images with a unique reference ID for easy tracking.

@sunami09 sunami09 requested a review from juztas October 21, 2024 04:57
Copy link
Collaborator

@juztas juztas left a comment

Choose a reason for hiding this comment

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

Please run pylint on your python code and fix issues.

************* Module test
test.py:1:0: C0114: Missing module docstring (missing-module-docstring)
test.py:12:0: C0115: Missing class docstring (missing-class-docstring)
test.py:60:12: W0106: Expression "val1['obj'] >> Edge(label=self.d_LinkLabel(val1, val2)) << val2['obj']" is assigned to nothing (expression-not-assigned)
test.py:69:35: R1733: Unnecessary dictionary index lookup, use 'vals' instead (unnecessary-dict-index-lookup)
test.py:74:39: R1733: Unnecessary dictionary index lookup, use 'vals' instead (unnecessary-dict-index-lookup)
test.py:79:39: R1733: Unnecessary dictionary index lookup, use 'vals' instead (unnecessary-dict-index-lookup)
test.py:81:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:94:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:94:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
test.py:108:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:108:4: R1710: Either all return statements in a function should return an expression, or none of them should. (inconsistent-return-statements)
test.py:117:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:125:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:126:38: C0121: Comparison 'self.popreverse == None' should be 'self.popreverse is None' (singleton-comparison)
test.py:128:40: C0121: Comparison 'self.popreverse == False' should be 'self.popreverse is False' if checking for the singleton value False, or 'not self.popreverse' if testing for falsiness (singleton-comparison)
test.py:130:40: C0121: Comparison 'self.popreverse == True' should be 'self.popreverse is True' if checking for the singleton value True, or 'bool(self.popreverse)' if testing for truthiness (singleton-comparison)
test.py:133:4: C0116: Missing function or method docstring (missing-function-docstring)
test.py:140:19: R1714: Consider merging these comparisons with 'in' by using 'self.popreverse in (None, False)'. Use a set instead if elements are hashable. (consider-using-in)
test.py:140:19: C0121: Comparison 'self.popreverse == None' should be 'self.popreverse is None' (singleton-comparison)
test.py:140:46: C0121: Comparison 'self.popreverse == False' should be 'self.popreverse is False' if checking for the singleton value False, or 'not self.popreverse' if testing for falsiness (singleton-comparison)
test.py:142:21: C0121: Comparison 'self.popreverse == True' should be 'self.popreverse is True' if checking for the singleton value True, or 'self.popreverse' if testing for truthiness (singleton-comparison)

------------------------------------------------------------------
Your code has been rated at 8.26/10 (previous run: 6.03/10, +2.23)

for rcfile - use this one: https://github.com/sdn-sense/siterm/blob/master/standarts/pylintrc (We should also upload rcfile to this repo too)

autogole-api/packaging/Dockerfile Outdated Show resolved Hide resolved
autogole-api/src/python/RTMonLibs/DiagramWorker.py Outdated Show resolved Hide resolved
Sunami Dasgupta added 2 commits October 21, 2024 18:49
@juztas
Copy link
Collaborator

juztas commented Oct 28, 2024

@sunami09
Copy link
Collaborator Author

sunami09 commented Nov 8, 2024

@juztas I added the BGP

@sunami09 sunami09 requested a review from juztas November 8, 2024 02:09
@juztas
Copy link
Collaborator

juztas commented Nov 8, 2024

I see no bgp added

#Generate Diagrams
try:
diagram_filename = f"{self.config.get('image_dir', '/srv/images')}/diagram_{kwargs['referenceUUID']}"
DiagramWorker(self.orderlist).createGraph(diagram_filename)
Copy link
Collaborator

Choose a reason for hiding this comment

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

We should use class inheritance, same as we do for templates and other classes.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

got it

@sunami09
Copy link
Collaborator Author

sunami09 commented Nov 8, 2024

Idk what happened

(base) sunami@Sunamis-MacBook-Pro packaging % git status
On branch imageserver
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   files/etc/grid-security/hostcert.pem
        modified:   files/etc/grid-security/hostkey.pem
        modified:   files/etc/rtmon.yaml
        modified:   files/etc/sense-o-auth.yaml
        modified:   start-dev.sh
        modified:   ../src/python/RTMonLibs/DiagramWorker.py
        modified:   ../src/python/RTMonLibs/imageserver.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        diagram.png
        diagram2.png
        ../src/python/RTMonLibs/__pycache__/

no changes added to commit (use "git add" and/or "git commit -a")
(base) sunami@Sunamis-MacBook-Pro packaging % git add ../src/python/RTMonLibs/DiagramWorker.py
(base) sunami@Sunamis-MacBook-Pro packaging % git add ../src/python/RTMonLibs/DiagramWorker.py
(base) sunami@Sunamis-MacBook-Pro packaging % git commit -m "Added BGP"                       
[imageserver b6fd690] Added BGP
 Committer: Sunami Dasgupta <[email protected]>
Your name and email address were configured automatically based
on your username and hostname. Please check that they are accurate.
You can suppress this message by setting them explicitly:

    git config --global user.name "Your Name"
    git config --global user.email [email protected]

After doing this, you may fix the identity used for this commit with:

    git commit --amend --reset-author

 1 file changed, 43 insertions(+)
(base) sunami@Sunamis-MacBook-Pro packaging % git push origin diagram-branch 
Total 0 (delta 0), reused 0 (delta 0), pack-reused 0 (from 0)
To https://github.com/esnet/sense-rtmon/
   f1fcc5d..98e18f4  diagram-branch -> diagram-branch
(base) sunami@Sunamis-MacBook-Pro packaging % git status                                      
On branch imageserver
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   files/etc/grid-security/hostcert.pem
        modified:   files/etc/grid-security/hostkey.pem
        modified:   files/etc/rtmon.yaml
        modified:   files/etc/sense-o-auth.yaml
        modified:   start-dev.sh
        modified:   ../src/python/RTMonLibs/imageserver.py

Untracked files:
  (use "git add <file>..." to include in what will be committed)
        diagram.png
        diagram2.png
        ../src/python/RTMonLibs/__pycache__/

no changes added to commit (use "git add" and/or "git commit -a")
(base) sunami@Sunamis-MacBook-Pro packaging % 

@sunami09
Copy link
Collaborator Author

sunami09 commented Nov 8, 2024

image

@sunami09
Copy link
Collaborator Author

sunami09 commented Nov 8, 2024

image

@juztas
Copy link
Collaborator

juztas commented Nov 8, 2024

Based on output:

  1. you are on imageserver branch;
  2. you commit in imageserver branch;
  3. you push to origin diagram-branch branch;
    your commit is in imageserver branch (not in diagram-branch)

@sunami09
Copy link
Collaborator Author

sunami09 commented Nov 8, 2024

Oh Got it

@sunami09 sunami09 requested a review from juztas November 8, 2024 19:25
@sunami09
Copy link
Collaborator Author

@juztas Let me do the class inheritance after image server.

@sunami09
Copy link
Collaborator Author

image

Copy link
Collaborator

@juztas juztas left a comment

Choose a reason for hiding this comment

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

I am also missing bgp function in this pull request. Was it by mistake removed?

from diagrams import Diagram, Cluster, Edge
from diagrams.custom import Custom
from RTMonLibs.GeneralLibs import _processName
# # change later:
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove this code

HOST_ICON_PATH = '/srv/icons/host.png'
SWITCH_ICON_PATH = '/srv/icons/switch.png'
# # TEmp
# HOST_ICON_PATH = '/Users/sunami/Desktop/publish/sense-rtmon/autogole-api/packaging/icons/host.png'
Copy link
Collaborator

Choose a reason for hiding this comment

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

remove too


from RTMonLibs.GeneralLibs import loadJson, dumpJson, dumpYaml, escape, getUUID, _processName
from RTMonLibs.DiagramWorker import DiagramWorker
#import json
Copy link
Collaborator

Choose a reason for hiding this comment

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

same here (why we need this commented line?)

#Generate Diagrams
try:
diagram_filename = f"{self.config.get('image_dir', '/srv/images')}/diagram_{kwargs['referenceUUID']}"
# diagram_json = f"diagram_{kwargs['referenceUUID']}.json"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Similar here

@sunami09 sunami09 requested a review from juztas December 9, 2024 06:45
@sunami09
Copy link
Collaborator Author

sunami09 commented Dec 9, 2024

one time I got this kind of error:

Traceback (most recent call last):
  File "src/python/RTMon/worker.py", line 272, in <module>
    worker.startwork()
  File "src/python/RTMon/worker.py", line 231, in startwork
    self._startwork()
  File "src/python/RTMon/worker.py", line 254, in _startwork
    self.main()
  File "src/python/RTMon/worker.py", line 218, in main
    self.submit_exe(filename, fout)
  File "src/python/RTMon/worker.py", line 50, in submit_exe
    manifest = self.s_getManifest(instance)
  File "/opt/devrtmon/src/python/RTMonLibs/SenseAPI.py", line 79, in s_getManifest
    response = wApi.manifest_create(dumpJson(template, self.logger))
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/workflow_combined_api.py", line 680, in manifest_create
    body_xml, **kwargs)  # noqa: E501
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/workflow_combined_api.py", line 736, in instance_si_uuid_manifest_post_with_http_info
    content_type='xml')
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/requestwrapper.py", line 156, in request
    f"Returned code {ret.status_code} with error '{error_message}'")
ValueError: Returned code 500 with error 'Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 1, column: 2]'

@xi-yang
Copy link
Collaborator

xi-yang commented Dec 9, 2024

one time I got this kind of error:

Traceback (most recent call last):
  File "src/python/RTMon/worker.py", line 272, in <module>
    worker.startwork()
  File "src/python/RTMon/worker.py", line 231, in startwork
    self._startwork()
  File "src/python/RTMon/worker.py", line 254, in _startwork
    self.main()
  File "src/python/RTMon/worker.py", line 218, in main
    self.submit_exe(filename, fout)
  File "src/python/RTMon/worker.py", line 50, in submit_exe
    manifest = self.s_getManifest(instance)
  File "/opt/devrtmon/src/python/RTMonLibs/SenseAPI.py", line 79, in s_getManifest
    response = wApi.manifest_create(dumpJson(template, self.logger))
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/workflow_combined_api.py", line 680, in manifest_create
    body_xml, **kwargs)  # noqa: E501
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/workflow_combined_api.py", line 736, in instance_si_uuid_manifest_post_with_http_info
    content_type='xml')
  File "/usr/local/lib/python3.6/site-packages/sense/common.py", line 21, in wrapper
    result = func(*args, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/sense/client/requestwrapper.py", line 156, in request
    f"Returned code {ret.status_code} with error '{error_message}'")
ValueError: Returned code 500 with error 'Unexpected character ('<' (code 60)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
 at [Source: (io.undertow.servlet.spec.ServletInputStreamImpl); line: 1, column: 2]'

@sunami09 It would be more useful if you can provide the context of this error, such as service instance UUID. If that is gone, let's keep an eye on it and report it sooner next time you see it.

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