arista-eosplus / ztpserver

Full service ZTP Server implementation for bootstrapping Arista EOS nodes
Other
70 stars 33 forks source link

allocate plugin doesn't return assigned key #323

Closed phil-dileo closed 9 years ago

phil-dileo commented 9 years ago

This is strange. When using the ztpserver-demo files, the allocate plugin correctly updates the resource pool file, but it doesn't return the right key to the do_resources().

EG

  -
    action: add_config
    attributes:
      url: files/templates/ma1.template
      variables:
        ipaddress: allocate('mgmt_subnet')
    name: "configure ma1"
    onstart: "Starting to configure ma1"
    onsuccess: "SUCCESS: ma1 configure"
    onfailure: "FAIL: IM nick@arista.com for help"

Resource Pool (before provisioning)

172.16.130.50/24: null
172.16.130.51/24: null

Resource Pool (after provisioning)

172.16.130.50/24: 000c296573a7
172.16.130.51/24: 000c29038e12

Both tora and torb are identified via neighbordb, but when they run GET definition the ZTPServer returns the same key from the resources pools, but for ipaddress and hostname.

tora

ul 31 12:44:36 ZTPS - INFO: GET http://172.16.130.10:8080/nodes/000c296573a7
Jul 31 12:44:36 ZTPS - INFO: Server response to GET definition: status=200, contents={u'attributes': {u'variables': {u'ztpserver': u'172.16.130.10'}}, u'actions': [{u'action': u'configure_ansible_client', u'attributes': {u'group': u'eosadmin', u'user': u'ansible', u'key': u'files/ssh/key.pub', u'passwd': u'password', u'root': u'/persist/local/'}, u'name': u'Configure Ansible'}, {u'name': u'configure ma1', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/ma1.template', u'variables': {u'ipaddress': u'172.16.130.51/24'}}, u'onsuccess': u'SUCCESS: ma1 configure', u'onstart': u'Starting to configure ma1'}, {u'name': u'configure global system', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/system.template', u'variables': {u'ztpserver': u'172.16.130.10', u'hostname': u'veos-dc1-pod1-tor2'}}, u'onsuccess': u'SUCCESS: basic config added', u'onstart': u'Starting to add basic system config'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/login.template'}, u'name': u'configure auth'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/ztpprep.template'}, u'name': u'configure ztpprep alias'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/configpush.template', u'variables': {u'ztpserver': u'172.16.130.10'}}, u'name': u'configure config push to server'}, {u'name': u'configure mlag', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/mlag.template', u'variables': {u'subnet': 30, u'domain': u'mlag1', u'peer': u'10.0.0.2', u'ipaddress': u'10.0.0.1', u'vlan': 4094, u'trkgrp': u'mlagpeer', u'po': 10}}, u'onsuccess': u'SUCCESS: MLAG configured', u'onstart': u'Starting to configure MLAG'}, {u'name': u'configure xmpp', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/xmpp.template', u'variables': {u'user': u'veos-dc1-pod1-tor1'}}, u'onsuccess': u'SUCCESS: XMPP configured', u'onstart': u'Starting to configure XMPP'}, {u'name': u'configure MLAG, VARP, BGP', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/l3.template', u'variables': {u'ipvlan100': u'10.100.1.3/24', u'loopback': u'1.1.1.11/32'}}, u'onsuccess': u'SUCCESS: L3 config added', u'onstart': u'Starting to L3 config'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/bgpauto.template'}, u'name': u'configure bgp interface automation event-handler'}, {u'name': u'automate BGP peer interface config', u'attributes': {u'dst_url': u'/mnt/flash/', u'src_url': u'files/automate/bgpautoinf.py', u'mode': 777, u'overwrite': u'if-missing'}, u'action': u'copy_file', u'always_execute': True}, {u'name': u'automate reload', u'attributes': {u'dst_url': u'/mnt/flash/', u'src_url': u'files/automate/ztpprep', u'mode': 777, u'overwrite': u'if-missing'}, u'action': u'copy_file', u'always_execute': True}], u'name': u'tora'}

torb

Jul 31 12:44:42 ZTPS - INFO: GET http://172.16.130.10:8080/nodes/000c29038e12
Jul 31 12:44:42 ZTPS - INFO: Server response to GET definition: status=200, contents={u'attributes': {u'variables': {u'ztpserver': u'172.16.130.10'}}, u'actions': [{u'name': u'configure ma1', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/ma1.template', u'variables': {u'ipaddress': u'172.16.130.51/24'}}, u'onsuccess': u'SUCCESS: ma1 configure', u'onstart': u'Starting to configure ma1'}, {u'name': u'configure global system', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/system.template', u'variables': {u'ztpserver': u'172.16.130.10', u'hostname': u'veos-dc1-pod1-tor2'}}, u'onsuccess': u'SUCCESS: basic config added', u'onstart': u'Starting to add basic system config'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/login.template'}, u'name': u'configure auth'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/ztpprep.template'}, u'name': u'configure ztpprep alias'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/configpush.template', u'variables': {u'ztpserver': u'172.16.130.10'}}, u'name': u'configure config push to server'}, {u'name': u'configure mlag', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/mlag.template', u'variables': {u'subnet': 30, u'domain': u'mlag1', u'peer': u'10.0.0.1', u'ipaddress': u'10.0.0.2', u'vlan': 4094, u'trkgrp': u'mlagpeer', u'po': 10}}, u'onsuccess': u'SUCCESS: MLAG configured', u'onstart': u'Starting to configure MLAG'}, {u'name': u'configure xmpp', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/xmpp.template', u'variables': {u'user': u'veos-dc1-pod1-tor2'}}, u'onsuccess': u'SUCCESS: XMPP configured', u'onstart': u'Starting to configure XMPP'}, {u'name': u'configure MLAG, VARP, BGP', u'onfailure': u'FAIL: IM nick@arista.com for help', u'action': u'add_config', u'attributes': {u'url': u'files/templates/l3.template', u'variables': {u'ipvlan100': u'10.100.1.3/24', u'loopback': u'1.1.1.11/32'}}, u'onsuccess': u'SUCCESS: L3 config added', u'onstart': u'Starting to L3 config'}, {u'action': u'add_config', u'attributes': {u'url': u'files/templates/bgpauto.template'}, u'name': u'configure bgp interface automation event-handler'}, {u'name': u'automate BGP peer interface config', u'attributes': {u'dst_url': u'/mnt/flash/', u'src_url': u'files/automate/bgpautoinf.py', u'mode': 777, u'overwrite': u'if-missing'}, u'action': u'copy_file', u'always_execute': True}, {u'name': u'automate reload', u'attributes': {u'dst_url': u'/mnt/flash/', u'src_url': u'files/automate/ztpprep', u'mode': 777, u'overwrite': u'if-missing'}, u'action': u'copy_file', u'always_execute': True}], u'name': u'torb'}
phil-dileo commented 9 years ago

Same files as always. What's interesting is that after this initial bootstrap (which returns the wrong value) if you delete the nodes dirs and delete the startup-configs on the tors to revert them to ZTP, the next time they go through provisioning the right value is returned. So there's something unique about the initial assignment that's broken.

advornic commented 9 years ago

Ok, sorted - was using the same variable name in too many places and things got messed up. This is now fixed - good catch!

On Tue, Aug 11, 2015 at 12:15 PM, Philip DiLeo notifications@github.com wrote:

Same files as always. What's interesting is that after this initial bootstrap (which returns the wrong value) if you delete the nodes dirs and delete the startup-configs on the tors to revert them to ZTP, the next time they go through provisioning the right value is returned. So there's something unique about the initial assignment that's broken.

— Reply to this email directly or view it on GitHub https://github.com/arista-eosplus/ztpserver/issues/323#issuecomment-129839752 .

phil-dileo commented 9 years ago

Thanks Andrei! Just tested it and things look good.