class GenerateRouterConfig(View):
def get(self, request, pk, *args, **kwargs):
router = Router.objects.get(pk=pk)
AMERICAS = ("1.2.3.4", "10.23.136.1")
ASIAPAC = ("1.2.3.5", "10.23.136.4")
EMEA = ("1.2.3.6", "10.23.136.3")
if router.REGIONS[1] == ('AMERICAS','AMERICAS'):
calculated_public_ip = AMERICAS[0]
calculated_tunnel_ip = AMERICAS[1]
elif router.REGIONS[2] == ('ASIA','ASIA'):
calculated_public_ip = ASIAPAC[0]
calculated_tunnel_ip = ASIAPAC[1]
elif router.REGIONS[0] == ('EUROPE','EUROPE'):
calculated_public_ip = EMEA[0]
calculated_tunnel_ip = EMEA[1]
print(calculated_public_ip)
print(calculated_tunnel_ip)
Models..
class Router(models.Model):
AsiaPac = 'ASIA'
Americas = 'AMERICAS'
EMEA = 'EUROPE'
REGIONS = [
(EMEA, 'EUROPE'),
(Americas, 'AMERICAS'),
(AsiaPac, 'ASIA'),
]
region = models.CharField(
max_length=8,
choices=REGIONS,
default=Americas,
)
Any hints? Based on the logic I used its not working..... Based on the if else logic I need to select the appropriate region tuples with calculated tunnel and public ip address.
Aucun commentaire:
Enregistrer un commentaire