max scalf wrote:
> Hi Peter,
>
> Could you please explain what i am doing wrong? I did inspected the
> "get_all_security_groups()" object using dir and i do need the get_data
> function for this to work...as i have to parse the output...just getting
> the rule and grants does not work...as it co
On Thursday 23 July 2015 06:40, Mark Lawrence wrote:
> On 22/07/2015 18:57, max scalf wrote:
>> Hi Peter,
>>
>> Could you please explain what i am doing wrong?
>
> Amongst other things you're top posting. That is heavily frowned on
> here. Please intersperse your replies or bottom post, thank y
On 22/07/2015 18:57, max scalf wrote:
Hi Peter,
Could you please explain what i am doing wrong?
Amongst other things you're top posting. That is heavily frowned on
here. Please intersperse your replies or bottom post, thank you.
--
My fellow Pythonistas, ask not what our language can do f
Hi Peter,
Could you please explain what i am doing wrong? I did inspected the
"get_all_security_groups()" object using dir and i do need the get_data
function for this to work...as i have to parse the output...just getting
the rule and grants does not work...as it comes with extra verbiage that i
max scalf wrote:
> I was able to solve the above problem i listed with the following...please
> let me know if that is the correct way of doing this...or i am way off?
>
> >>> for sg in sgs:
> for rule in sg.rules:
> st = sg, sg.id, "inbound:", rule, " source:", rule.grants
>
I was able to solve the above problem i listed with the following...please
let me know if that is the correct way of doing this...or i am way off?
>>> for sg in sgs:
for rule in sg.rules:
st = sg, sg.id, "inbound:", rule, " source:", rule.grants
s = str(st).replace(","," ")
Hi Pablo,
While playing around with the function you gave me(get_data)...i was
thinking to do something like below. For each line create a dictionary
then append that dictionary to a list...but before i even get to that part
i get the below error and while researching it i am unable to figure out
Thank you all. I have gotten some great response, so i am going to play
around with this and see how it turns out. As Pablo pointed out, best way
to learn is to try it out and see how it goes. Thanks again and i will
keep the list posted.
On Tue, Jul 21, 2015 at 8:03 PM, Pablo Lucena wrote:
>
On Wed, Jul 22, 2015 at 11:03 AM, Pablo Lucena wrote:
> str.split and re are a nice quick way to do it:
>
def get_data(data):
> import re
> port_re = re.compile(r'(\w+)\((\S+-\S+)\)')
> cidr_re = re.compile(r'\[(.*?)\]')
> _, proto_port, cidr = data.rsplit(":", 2)
> port_match = port_re.searc
On Wed, 22 Jul 2015 07:12 am, max scalf wrote:
> Hello all,
>
> For Each SecurityGroup, how can i convert that into a List that in turn
> will have a dictionary of the cidr block, protocol type and the port...
Start with this:
def sg_to_list(sg):
return [rule_to_dict(r) for r in sg.rules]
​str.split and re are a nice quick way to do it:
>>> def get_data(data):
import re
port_re = re.compile(r'(\w+)\((\S+-\S+)\)')
cidr_re = re.compile(r'\[(.*?)\]')
_, proto_port, cidr = data.rsplit(":", 2)
port_match = port_re.search(proto_port)
proto, port = port_match.group(1), port_match.group(2)
On Wed, Jul 22, 2015 at 7:12 AM, max scalf wrote:
> SecurityGroup:default sg-e1304484 inbound: IPPermissions:tcp(80-80) source:
> [67.184.225.222/32]
>
>
>
> Here is the output i am looking for
>
>
> rule1 = [{
>
> 'cidr': '67.184.225.222/32',
>
> 'proto': 'tcp',
>
> 'port':
Hello all,
For Each SecurityGroup, how can i convert that into a List that in turn
will have a dictionary of the cidr block, protocol type and the port...so
from output below, the SecurityGroup called "default" had 2
rules...allowing TCP port from 80 and 5500 to the source IP and then
SecurityGrou
13 matches
Mail list logo