api.device_templates
¶
Cisco vManage Device Templates API Methods.
Module Contents¶
-
class
api.device_templates.
DeviceTemplates
(session, host, port=443)[source]¶ Bases:
object
vManage Device Templates API
Responsible for DELETE, GET, POST, PUT methods against vManage Device Templates.
-
delete_device_template
(self, templateId)[source]¶ Obtain a list of all configured device templates.
- Parameters
templateId (str) – Object ID for device template
- Returns
All data associated with a response.
- Return type
result (dict)
-
get_device_templates
(self)[source]¶ Obtain a list of all configured device templates.
- Returns
All data associated with a response.
- Return type
result (dict)
-
get_device_template_object
(self, template_id)[source]¶ Obtain a device template object.
- Parameters
template_id (str) – Object ID for device template
- Returns
All data associated with a response.
- Return type
result (dict)
-
get_device_template_list
(self, factory_default=False, name_list=None)[source]¶ Get the list of device templates.
- Parameters
factory_default (bool) – Include factory default
name_list (list of strings) – A list of template names to retreive.
- Returns
All data associated with a response.
- Return type
result (dict)
-
get_device_template_dict
(self, factory_default=False, key_name='templateName', remove_key=True, name_list=None)[source]¶ Obtain a dictionary of all configured device templates.
- Parameters
factory_default (bool) – Wheter to return factory default templates
key_name (string) – The name of the attribute to use as the dictionary key
remove_key (boolean) – remove the search key from the element
name_list (list of strings) – A list of template names to retreive.
- Returns
All data associated with a response.
- Return type
result (dict)
-
get_template_attachments
(self, template_id, key='host-name')[source]¶ Get the devices that a template is attached to.
- Parameters
template_id (string) – Template ID
key (string) – The key of the device to put in the list (default: host-name)
- Returns
List of keys.
- Return type
result (list)
-
get_template_input
(self, template_id, device_id_list=None)[source]¶ Get the input associated with a device attachment.
- Parameters
template_id (string) – Template ID
device_id_list (list) – list of device UUID’s to get input for
- Returns
All data associated with a response.
- Return type
result (dict)
-
add_device_template
(self, device_template)[source]¶ Add a single device template to Vmanage.
- Parameters
device_template (dict) – Device Template
- Returns
Response from Vmanage
- Return type
result (list)
-
update_device_template
(self, device_template)[source]¶ Update a single device template to Vmanage.
- Parameters
device_template (dict) – Device Template
- Returns
Response from Vmanage
- Return type
result (list)
-
reattach_device_template
(self, template_id, config_type, is_edited=True, is_master_edited=True)[source]¶ Re-Attach a template to the devices it it attached to.
- Parameters
template_id (str) – The template ID to attach to
config_type (str) – Type of template i.e. device or CLI template
is_edited (bool) – True if the template has been edited
is_master_edited (bool) – For CLI device template needs to match is_edited. For device templates using feature templates needs to be set to False.
- Returns
Returns the action id of the attachment
- Return type
action_id (str)
-
attach_to_template
(self, template_id, config_type, uuid)[source]¶ Attach and device to a template
- Parameters
template_id (str) – The template ID to attach to
config_type (str) – Type of template i.e. device or CLI template
uuid (dict) – The UUIDs of the device to attach and mapping for corresponding variables, system-ip, host-name
- Returns
Returns the action id of the attachment
- Return type
action_id (str)
-
detach_from_template
(self, uuid, device_ip, device_type)[source]¶ Detach a device from a template (i.e. Put in CLI mode)
- Parameters
uuid (str) – The UUID of the device to detach
device_ip (str) – The System IP of the system to detach
device_type (str) – The device type of the device to detach
- Returns
Returns the action id of the attachment
- Return type
action_id (str)
-
get_attachments
(self, template_id, key='host-name')[source]¶ Get a list of attachments to a particular template.
- Parameters
template_id (str) – Template ID of the template
key (str) – The key of the elements to return
- Returns
Returns the specified key of the attached devices.
- Return type
result (list)
-
get_device_running_config
(self, uuid)[source]¶ Get the running configuration of a specific device.
- Parameters
uuid (str) – UUID of device
- Returns
The running configuration of the specified device.
- Return type
result (str)
-
reattach_multi_device_templates
(self, template_ids)[source]¶ Re-Attach a template to the devices it it attached to.
- Parameters
template_id (str) – The template ID to attach to
config_type (str) – Type of template i.e. device or CLI template
is_edited (bool) – True if the template has been edited
is_master_edited (bool) – For CLI device template needs to match is_edited. For device templates using feature templates needs to be set to False.
- Returns
Returns the action id of the attachment
- Return type
action_id (str)
-