{"action":"created","issue":{"url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/24","labels_url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/24/labels{/name}","comments_url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/24/comments","events_url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/24/events","html_url":"https://github.com/CiscoDevNet/cosc-learning-labs/issues/24","id":78152278,"number":24,"title":"dynamic http content","user":{"login":"kjarrad","id":12138668,"avatar_url":"https://avatars.githubusercontent.com/u/12138668?v=3","gravatar_id":"","url":"https://api.github.com/users/kjarrad","html_url":"https://github.com/kjarrad","followers_url":"https://api.github.com/users/kjarrad/followers","following_url":"https://api.github.com/users/kjarrad/following{/other_user}","gists_url":"https://api.github.com/users/kjarrad/gists{/gist_id}","starred_url":"https://api.github.com/users/kjarrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjarrad/subscriptions","organizations_url":"https://api.github.com/users/kjarrad/orgs","repos_url":"https://api.github.com/users/kjarrad/repos","events_url":"https://api.github.com/users/kjarrad/events{/privacy}","received_events_url":"https://api.github.com/users/kjarrad/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":{"login":"kjarrad","id":12138668,"avatar_url":"https://avatars.githubusercontent.com/u/12138668?v=3","gravatar_id":"","url":"https://api.github.com/users/kjarrad","html_url":"https://github.com/kjarrad","followers_url":"https://api.github.com/users/kjarrad/followers","following_url":"https://api.github.com/users/kjarrad/following{/other_user}","gists_url":"https://api.github.com/users/kjarrad/gists{/gist_id}","starred_url":"https://api.github.com/users/kjarrad/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kjarrad/subscriptions","organizations_url":"https://api.github.com/users/kjarrad/orgs","repos_url":"https://api.github.com/users/kjarrad/repos","events_url":"https://api.github.com/users/kjarrad/events{/privacy}","received_events_url":"https://api.github.com/users/kjarrad/received_events","type":"User","site_admin":false},"milestone":null,"comments":1,"created_at":"2015-05-19T16:13:45Z","updated_at":"2015-05-19T18:29:37Z","closed_at":null,"body":"We have tried to use simple text templates for http request content/body/payload. See below for an example. This is not sophisticated enough for content where the presence of fields is dynamic. The relevant fields in the example are: shutdown, description, address, netmask - all of which can be present or absent. Note that in the example the field shutdown is absent.\r\n\r\nProposal: build a Python dict dynamically then convert to text using a utilty function from the JSON module.\r\n\r\nWhy is this happening now? It was always a problem for interfaces with no address so we excluded them from the sample code (as a temporary workaround). With the introduction of a new topology in dcloud we now find that the interfaces are configured differently and rather than dig deeper it is time to get out of the hole.\r\n\r\n```\r\n{\r\n  \"interface-configuration\": [\r\n    {\r\n      \"active\": \"%s\",\r\n      \"Cisco-IOS-XR-ipv4-io-cfg:ipv4-network\": {\r\n        \"addresses\": {\r\n          \"primary\": {\r\n            \"netmask\": \"%s\", \r\n            \"address\": \"%s\"\r\n          }\r\n        }\r\n      },%s\r\n      \"interface-name\": \"%s\", \r\n      \"description\": \"%s\"\r\n    }\r\n  ]\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/comments/103624592","html_url":"https://github.com/CiscoDevNet/cosc-learning-labs/issues/24#issuecomment-103624592","issue_url":"https://api.github.com/repos/CiscoDevNet/cosc-learning-labs/issues/24","id":103624592,"user":{"login":"NathanCisco","id":7212288,"avatar_url":"https://avatars.githubusercontent.com/u/7212288?v=3","gravatar_id":"","url":"https://api.github.com/users/NathanCisco","html_url":"https://github.com/NathanCisco","followers_url":"https://api.github.com/users/NathanCisco/followers","following_url":"https://api.github.com/users/NathanCisco/following{/other_user}","gists_url":"https://api.github.com/users/NathanCisco/gists{/gist_id}","starred_url":"https://api.github.com/users/NathanCisco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NathanCisco/subscriptions","organizations_url":"https://api.github.com/users/NathanCisco/orgs","repos_url":"https://api.github.com/users/NathanCisco/repos","events_url":"https://api.github.com/users/NathanCisco/events{/privacy}","received_events_url":"https://api.github.com/users/NathanCisco/received_events","type":"User","site_admin":false},"created_at":"2015-05-19T18:29:37Z","updated_at":"2015-05-19T18:29:37Z","body":" ./03_interface_configuration_update.py \r\ncosc authentication url: https://198.18.1.25/controller-auth\r\ncosc authentication parameters:\r\n   username = admin\r\n   scope = sdn\r\n   password = cisco123\r\n   grant_type = password\r\ncosc authentication status code: 201\r\nPython Library Documentation: function interface_configuration_update in module basics.interface\r\n\r\ninterface_configuration_update(device_name, interface_name, description, address, netmask, active=u'act', shutdown=False)\r\n    Update the configuration of the specified interface of the specified device.\r\n    \r\n    The outcome is undefined if the specified device is not connected.\r\n\r\nInitial configuration:\r\nInterfaceConfiguration(name='GigabitEthernet0/0/0/2', description=None, shutdown=False, address='54.0.0.26', netmask='255.255.255.0', packet_filter_outbound=None, packet_filter_inbound=None, active='act')\r\n\r\nModify configuration:\r\ninterface_configuration_update(por, GigabitEthernet0/0/0/2, Mutable, 101.101.101.101, 255.255.0.0, True)\r\n\r\nModified configuration:\r\nInterfaceConfiguration(name='GigabitEthernet0/0/0/2', description='Mutable', shutdown=True, address='101.101.101.101', netmask='255.255.0.0', packet_filter_outbound=None, packet_filter_inbound=None, active='act')\r\n\r\nRestore configuration:\r\ninterface_configuration_update(por, GigabitEthernet0/0/0/2, None, 54.0.0.26, 255.255.255.0, False)\r\n\r\nRestored configuration:\r\nInterfaceConfiguration(name='GigabitEthernet0/0/0/2', description='None', shutdown=False, address='54.0.0.26', netmask='255.255.255.0', packet_filter_outbound=None, packet_filter_inbound=None, active='act')\r\nTraceback (most recent call last):\r\n  File \"./03_interface_configuration_update.py\", line 91, in <module>\r\n    sys_exit(main())\r\n  File \"./03_interface_configuration_update.py\", line 85, in main\r\n    demonstrate(device_name, interface_config)\r\n  File \"./03_interface_configuration_update.py\", line 69, in demonstrate\r\n    assert restored.description == initial.description, \"Expected '%s' %s got '%s' %s\" % (initial.description, type(initial.description), restored.description, type(restored.description))\r\nAssertionError: Expected 'None' <type 'NoneType'> got 'None' <type 'str'>\r\ncisco@ubuntu:~/git/cosc-learning-labs/src/learning_lab$ "}}