QuestionQ80

VerifiedController-Based Network Automation

Drag the code snippets onto the boxes in the code to complete the attach_feature_template function, which attaches a configuration template by using the vManage Configuration API. The template is new and has not been modified. Not every option is used.

Drag & Drop
def attach_feature_template(self):
    mount_point = "template/device//attachfeature"
    payload = {
        "deviceTemplateList":[
            {
                "templateId":"41f6a440-c5cc-4cc6-9ca1-af18e332a781",
                "device":[
                    {
                        "":"complete",
                        "csv-deviceId":"CSR-61CD2335-4775-650F-8538-4EC7BDFFD04C",
                        "csv-deviceIP":"10.10.1.11",
                        "csv-host-name":"dc-cedge01",
                        "//system/host-name":"dc-cedge01",
                        "//system/system-ip":"10.10.1.11",
                        "//system/site-id":"100",
                        "csv-templateId":"41f6a440-c5cc-4cc6-9ca1-af18e332a781",
                        "selected":"true"
                    }
                ],
                "isEdited": False,
                "isMasterEdited":False
            }
        ]
    }
    headers={"Content-Type": ""}
    url = "https://%s/dataservice/%s"%(self.vmanage_ip, mount_point)
    payload = json.dumps(payload)
    response = self.session(self.vmanage_ip).(url=url,
                                                   data=payload,
                                                   headers=headers, verify=True)
    return response
Explanation

Cisco vManage attaches a device configuration template through the POST /dataservice/template/device/config/attachfeature endpoint. The request body’s device entry uses csv-status with the value complete; it is sent as JSON with Content-Type: application/json.

Community Discussion

No comments yet. Be the first to start the discussion!