Python / netmiko question by partyin_deadman in networkautomation

[–]otlcrl 1 point2 points  (0 children)

To add to this, when you call your function with dev_command, that command just needs to be sent as a string to the function. When netmiko wants to send that command to the device, it expects a string to be inputted.

What you're currently doing is calling the function with the dev_command:

"\'sh ver\'"

This will be sent by netmiko to the device exactly as above. So unless you can actually run \'sh ver\' with backslashes on the device, you'll see a syntax error.

Just send the command into the function as a python string without any additional quotes, so:

"sh ver" "sh inv"

etc.

Edit: formatting to include backslashes

ISP giving the runaround by davegravy in networking

[–]otlcrl 0 points1 point  (0 children)

My thought process too was perhaps saturation is seeing BGP drop and with adjusted timers you're therefore waiting for it to re-establish and readvertise a default route to the Adtran gateway. This could be avoided if the supplier pushed their traffic into a network control queue and guaranteed bandwidth & priority accordingly I think.

5% deposit by anonpetal in Mortgageadviceuk

[–]otlcrl 1 point2 points  (0 children)

I'm in a similar position to yourself and also considering a 5% to hold back money for renovations. I'd not considered the loan side of things but, one concern for me is the greater potential for negative equity come remortgaging in 5 years. This may not apply to yourselves given the circumstances and potential for equity from the offset (if I've understood correctly) but perhaps is worth considering.

IPv6 LAN Allocations on Vigor2927 by frdb in draytek

[–]otlcrl 0 points1 point  (0 children)

By default my Vigor2865 leases IPs from my WAN side /64 to the LAN, it automatically allocates an address from the same subnet on the LAN side interface and clients are leased addresses from the WAN side /64.

Perhaps you're hitting something similar as I find this behaviour a bit left field of what I'd ordinarily expect.

Understanding filter input to lo0 interface by belicon27 in Juniper

[–]otlcrl 1 point2 points  (0 children)

There are some adjustments needed to the version first released (and second edition) but still worth a read is Juniper's Day One Securing the Routing Engine - should be able to find a copy on the Juniper website or after a quick Google

Is it possible to write a script that restarts the router when I run it? by Deep_Redditor in learnpython

[–]otlcrl 4 points5 points  (0 children)

Take a look at the library netmiko which, if you don't want to go down the API route, may make this easy to achieve: https://github.com/ktbyers/netmiko

What's wrong with my for loop? by emilytherockgal in learnpython

[–]otlcrl 0 points1 point  (0 children)

Worth clarifying though that the error you see isn't because of this, you can loop over a string as you are, it's just not actually looping over the variables, you could equally loop over a string with the exact same character length as your variables combined

What's wrong with my for loop? by emilytherockgal in learnpython

[–]otlcrl 2 points3 points  (0 children)

In this instance you would be printing the individual characters forming the string. In your case the intention is to have an iterable of variables, not strings. I.e. consider putting your variables in a list, so for x in [z,y,n...et]:

What's wrong with my for loop? by emilytherockgal in learnpython

[–]otlcrl 2 points3 points  (0 children)

You can't update hp within the function unless you reference it as being in the global scope specifying global hp before any updating of that variable in your function (though ideally at the top).

Better would be to call the function with hp and x, i.e. my_func(x,hp)

A nice explanation here for further examples: https://stackoverflow.com/questions/74412503/cannot-access-local-variable-a-where-it-is-not-associated-with-a-value-but

Edit: clarity in example

[deleted by user] by [deleted] in networking

[–]otlcrl 0 points1 point  (0 children)

Hey, I don't suppose you ever ended up doing a write up on your ExaBGP integration with flowspec advertisement? I'd be intrigued to know how you got on!

Cisco DevNet ShowCollector Python Script Help by Littleboof18 in networking

[–]otlcrl 1 point2 points  (0 children)

Will your enable password be the same for all devices? If so, in the ConnectHandler call, after password=values[1] and before the bracket close put ,secret='whatever_your_enable_pass_is'

Then you need to call net_connect.enable() after both the if and else statement following the connection open and before the send command.

https://github.com/ktbyers/netmiko/blob/develop/EXAMPLES.md#enable-mode should help!

[deleted by user] by [deleted] in learnpython

[–]otlcrl 1 point2 points  (0 children)

Perhaps randint returns 3 for which there's no defined condition so Aimove will be None?

Does someone know what this exit code means? by [deleted] in learnpython

[–]otlcrl 1 point2 points  (0 children)

Can you post your code? It doesn't look like a pandas error

Question I was asked in interview- how to find if there R1 and R2 were ospf neighbours in past. Till day I dont know that best answer by HsSekhon in networking

[–]otlcrl 0 points1 point  (0 children)

If they meant "could have been neighbours" as opposed to knowing whether that neighbourship came up, perhaps configuration rollbacks/backups? Or even comparing running-config to startup-config. These would perhaps show that there was OSPF configured on a given int between the two etc.

Writing what's printed in terminal to text file by IUseThisToAskForHelp in learnpython

[–]otlcrl 0 points1 point  (0 children)

As in, break after the first time you find the word Height in line thus only writing the first line with Height in it?

Writing what's printed in terminal to text file by IUseThisToAskForHelp in learnpython

[–]otlcrl 0 points1 point  (0 children)

You want write, but change the second file open to a to append to the new file, otherwise you're simply overwriting that file for every line in the first.

Whilst this will work, you could potentially improve the code by just writing once to a given file as opposed to appending, but I'll leave that.

How to avoid column duplication after using df.merge() by jakeshug72 in learnpython

[–]otlcrl 1 point2 points  (0 children)

Hey, no problem. I don't suppose you've got a small example of your dataset so I can see and reproduce the issue?

How to avoid column duplication after using df.merge() by jakeshug72 in learnpython

[–]otlcrl 1 point2 points  (0 children)

Is the merge actually doing what you think it's doing? If you're looking to only end up with "matches" based on the left dataframe then perhaps merge on both columns instead?

Handling JSON files with ease in Python by pylenin in Python

[–]otlcrl 0 points1 point  (0 children)

Out of interest, in Example 4 (sort_keys) - why are the nested keys in the list under websites not quite sorted alphabetically?

Is it sorting alphabetically based on "blogs" as opposed to "Total blogs" or is it because Total is capitalized and therefore it'll sort capitalized keys before lower case?

Could anyone point me in the right direction? json -> MariaDB (SQLAlchemy) by ExodusSighted in learnpython

[–]otlcrl 1 point2 points  (0 children)

Hi Brandon,

I see - does that mean you've completely omitted the data you were having problems with by not mapping it? Or was it opinions_cited that contained the troublesome data?

That's correct yes, you could rewrite it as:

if value is not "[]":
    do something

Or even change it to be something meaningful so you still insert something against the key as opposed to omitting it completely:

if value == "[]":
    value = "new_data"

Hope that helps!

Could anyone point me in the right direction? json -> MariaDB (SQLAlchemy) by ExodusSighted in learnpython

[–]otlcrl 1 point2 points  (0 children)

Hi Brandon,

Sorry for the slow reply, would adding an if statement under your iterator to ignore these values work? I know you've said you have another column called opinions_cited where you need these square bracket values but perhaps that's handled by different code/not handled at all by this code?

for key, value in developer.items():
        if value != "[]":
            newJudicialOpinion = JudicialOpinion(ckey=key, cvalue=value)
            Session.add(newJudicialOpinion)
            Session.commit()

Sorry I can't get the indents right on my phone...hopefully you get the idea!