I've tried replace with nothing and remove.
After some sleep and not looking at it for two days the correct result was easy. Replace worked. I was trying to replace all asterisks in the list at once. Instead of going through them one at at time.
Here is my final code that producing a list without the asterisks.
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
from pprint import pprint
import getpass,csv,sys,pprint
from jnpr.junos.factory.factory_loader import FactoryLoader
import yaml,sys
from jnpr.junos.op.ethport import EthPortTable
z=0
yaml.warnings({'YAMLLoadWarning': False})
with open("lldp-neighbors.yml", 'r') as tvs:
globals().update(FactoryLoader().load(yaml.load(tvs)))
#host = input("Host :")
host = '10.44.2.3'
username=raw_input("\nEnter your device username: ")
password=getpass.getpass(prompt="\nEnter your device password: ")
nvlanlist=[]
count=0
#with Device(host=host, user='enumber', password='password',gather_facts=True) as dev:
with Device(host=host, user=username, password=password,gather_facts=True) as dev:
vlanlocal = VlanInformationTable(dev)
vlanlocalELS=VlanInformationTableELS(dev)
vlanlocal.get()
vlanlocalELS.get()
model = (dev.facts['model'])
if '4600' in model or '3400' in model or '4300' in model or '2300' in model:
for item in vlanlocalELS:
if item.tag != '0':
for y in item.members:
if len(y) == 1:
if count ==0:
nvlanlist.append([item.name,item.members.replace('*','')])
count = count +1
else:
nvlanlist.append([item.name,item.members[z].replace('*','')])
z=z+1
z=0
else:
for item in vlanlocal:
if item.tag != '0':
count = 0
for y in item.members:
if len(y) == 1:
if count ==0:
nvlanlist.append([item.name,item.members.replace('*','')])
count = count +1
else:
nvlanlist.append([item.name,item.members[z].replace('*','')])
z=z+1
z=0
for item in nvlanlist:
print (item[0]+','+item[1])
Sorry here is my code correctly entered into the thread.
from jnpr.junos import Device
from jnpr.junos.utils.config import Config
from pprint import pprint
import getpass,csv,sys,pprint
from jnpr.junos.factory.factory_loader import FactoryLoader
import yaml,sys
from jnpr.junos.op.ethport import EthPortTable
import re
z=0
yaml.warnings({'YAMLLoadWarning': False})
with open("lldp-neighbors.yml", 'r') as tvs:
globals().update(FactoryLoader().load(yaml.load(tvs)))
#host = input("Host :")
host = '10.44.2.3'
#username=raw_input("\nEnter your device username: ")
username="e061462"
#password=getpass.getpass(prompt="\nEnter your device password: ")
password="1970.Bmac8"
nvlanlist=[]
string="*"
count=0
#with Device(host=host, user='enumer', password='password',gather_facts=True) as dev:
with Device(host=host, user=username, password=password,gather_facts=True) as dev:
vlanlocal = VlanInformationTable(dev)
vlanlocalELS=VlanInformationTableELS(dev)
vlanlocal.get()
vlanlocalELS.get()
model = (dev.facts['model'])
if '4600' in model or '3400' in model or '4300' in model or '2300' in model:
for item in vlanlocalELS:
if item.tag != '0':
for y in item.members:
if len(y) == 1:
if count ==0:
nvlanlist.append([item.name,item.members.replace('*','')])
count = count +1
else:
nvlanlist.append([item.name,item.members[z].replace('*','')])
z=z+1
z=0
else:
for item in vlanlocal:
if item.tag != '0':
count = 0
for y in item.members:
if len(y) == 1:
if count ==0:
nvlanlist.append([item.name,item.members.replace('*','')])
count = count +1
else:
nvlanlist.append([item.name,item.members[z].replace('*','')])
z=z+1
z=0
for item in nvlanlist:
print (item[0]+','+item[1])