Skip to content

Commit

Permalink
Add IP addresses and friendly names
Browse files Browse the repository at this point in the history
With the subcommand `augment`, the script reads a graphML file and adds information from StellarBeat whenever possible.

(Originally, I didn't include this in PR #2582, but this change turns out to be much smaller than I initially anticipated, so I decided to just throw this in the PR.)
  • Loading branch information
Hidenori committed Jun 15, 2020
1 parent a382c69 commit 2adff5b
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
21 changes: 21 additions & 0 deletions scripts/OverlaySurvey.py
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,15 @@ def analyze(args):
write_graph_stats(G, args.graphStats)
sys.exit(0)

def augment(args):
graph = nx.read_graphml(args.graphmlInput)
data = requests.get("https://api.stellarbeat.io/v1/nodes").json()
for obj in data:
if graph.has_node(obj["publicKey"]):
graph.add_node(obj["publicKey"], ip=obj["ip"], name=obj["name"])
nx.write_graphml(graph, args.graphmlOutput)
sys.exit(0)


def run_survey(args):
G = nx.Graph()
Expand Down Expand Up @@ -244,6 +253,18 @@ def main():
help="input graphml file")
parser_analyze.set_defaults(func=analyze)

parser_augment = subparsers.add_parser('augment',
help="augment the master graph "
"with stellarbeat data")
parser_augment.add_argument("-gmli",
"--graphmlInput",
help="input master graph")
parser_augment.add_argument("-gmlo",
"--graphmlOutput",
required=True,
help="output file for the augmented graph")
parser_augment.set_defaults(func=augment)

args = ap.parse_args()
args.func(args)

Expand Down
6 changes: 5 additions & 1 deletion scripts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ This folder is for storing any scripts that may be helpful for using stellar-cor
### Overlay survey
- Name - `OverlaySurvey.py`
- Description - A Python script that will walk the network using the Overlay survey mechanism to gather connection information. See [admin](./../docs/software/admin.md#overlay-topology-survey) for more information on the overlay survey. The survey will use the peers of the initial node to seed the survey.
- Usage - Ex. `python3 OverlaySurvey.py -gs gs.json survey -n http://127.0.0.1:11626 -d 50 -sr sr.json -gmlw gmlw.graphml` to run the survey or `python3 OverlaySurvey.py -gs gs.json analyze -gmla gmla.graphml` to analyze an existing graph.
- Usage - Ex. `python3 OverlaySurvey.py -gs gs.json survey -n http://127.0.0.1:11626 -d 50 -sr sr.json -gmlw gmlw.graphml` to run the survey, `python3 OverlaySurvey.py -gs gs.json analyze -gmla gmla.graphml` to analyze an existing graph, or `python3 OverlaySurvey.py -gs gs.json augment -gmli gmlw.graphml -gmlo augmented.graphml` to augment the existing graph with data from StellarBeat.

- `-gs GRAPHSTATS`, `--graphStats GRAPHSTATS` - output file for graph stats
- sub command `survey` - run survey and analyze
- `-n NODE`, `--node NODE` - address of initial survey node
Expand All @@ -17,3 +18,6 @@ This folder is for storing any scripts that may be helpful for using stellar-cor
- `-sr SURVEYRESULT`, `--surveyResult SURVEYRESULT` - output file for survey results
- sub command `analyze` - analyze an existing graph
- `-gmla GRAPHMLANALYZE`, `--graphmlAnalyze GRAPHMLANALYZE` - input graphml file
- sub command `augment` - analyze an existing graph
- `-gmli GRAPHMLINPUT` - input graphml file
- `-gmlo GRAPHMLOUTPUT` - output graphml file

5 comments on commit 2adff5b

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

saw approval from MonsieurNicolas
at hidenori-shinohara@2adff5b

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

merging hidenori-shinohara/stellar-core/overlay-pr = 2adff5b into auto

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

hidenori-shinohara/stellar-core/overlay-pr = 2adff5b merged ok, testing candidate = 868e6fe

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

@latobarita
Copy link
Contributor

Choose a reason for hiding this comment

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

fast-forwarding master to auto = 868e6fe

Please sign in to comment.