code
stringlengths
1
18.2k
def get_vnetwork_dvs_output_vnetwork_dvs_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_dvs = ET.Element("get_vnetwork_dvs") config = get_vnetwork_dvs output = ET.SubElement(get_vnetwork_dvs, "output") vnetwork_dvs = ET.SubElement(output, "vnetwork-dvs") interface_type = ET.SubElement(vnetwork_dvs, "interface-type") interface_type.text = kwargs.pop('interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_dvs_output_vnetwork_dvs_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_dvs = ET.Element("get_vnetwork_dvs") config = get_vnetwork_dvs output = ET.SubElement(get_vnetwork_dvs, "output") vnetwork_dvs = ET.SubElement(output, "vnetwork-dvs") interface_name = ET.SubElement(vnetwork_dvs, "interface-name") interface_name.text = kwargs.pop('interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_dvs_output_has_more(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_dvs = ET.Element("get_vnetwork_dvs") config = get_vnetwork_dvs output = ET.SubElement(get_vnetwork_dvs, "output") has_more = ET.SubElement(output, "has-more") has_more.text = kwargs.pop('has_more') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_dvs_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_dvs = ET.Element("get_vnetwork_dvs") config = get_vnetwork_dvs output = ET.SubElement(get_vnetwork_dvs, "output") instance_id = ET.SubElement(output, "instance-id") instance_id.text = kwargs.pop('instance_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_input_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches input = ET.SubElement(get_vnetwork_vswitches, "input") name = ET.SubElement(input, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_input_vcenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches input = ET.SubElement(get_vnetwork_vswitches, "input") vcenter = ET.SubElement(input, "vcenter") vcenter.text = kwargs.pop('vcenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_input_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches input = ET.SubElement(get_vnetwork_vswitches, "input") datacenter = ET.SubElement(input, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_input_last_rcvd_instance(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches input = ET.SubElement(get_vnetwork_vswitches, "input") last_rcvd_instance = ET.SubElement(input, "last-rcvd-instance") last_rcvd_instance.text = kwargs.pop('last_rcvd_instance') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") name = ET.SubElement(vnetwork_vswitches, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_host(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") host = ET.SubElement(vnetwork_vswitches, "host") host.text = kwargs.pop('host') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") datacenter = ET.SubElement(vnetwork_vswitches, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_pnic(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") pnic = ET.SubElement(vnetwork_vswitches, "pnic") pnic.text = kwargs.pop('pnic') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") interface_type = ET.SubElement(vnetwork_vswitches, "interface-type") interface_type.text = kwargs.pop('interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_vnetwork_vswitches_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") vnetwork_vswitches = ET.SubElement(output, "vnetwork-vswitches") interface_name = ET.SubElement(vnetwork_vswitches, "interface-name") interface_name.text = kwargs.pop('interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_has_more(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") has_more = ET.SubElement(output, "has-more") has_more.text = kwargs.pop('has_more') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_vswitches_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_vswitches = ET.Element("get_vnetwork_vswitches") config = get_vnetwork_vswitches output = ET.SubElement(get_vnetwork_vswitches, "output") instance_id = ET.SubElement(output, "instance-id") instance_id.text = kwargs.pop('instance_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_input_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups input = ET.SubElement(get_vnetwork_portgroups, "input") name = ET.SubElement(input, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_input_vcenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups input = ET.SubElement(get_vnetwork_portgroups, "input") vcenter = ET.SubElement(input, "vcenter") vcenter.text = kwargs.pop('vcenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_input_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups input = ET.SubElement(get_vnetwork_portgroups, "input") datacenter = ET.SubElement(input, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_input_last_rcvd_instance(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups input = ET.SubElement(get_vnetwork_portgroups, "input") last_rcvd_instance = ET.SubElement(input, "last-rcvd-instance") last_rcvd_instance.text = kwargs.pop('last_rcvd_instance') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_vnetwork_pgs_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") vnetwork_pgs = ET.SubElement(output, "vnetwork-pgs") name = ET.SubElement(vnetwork_pgs, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_vnetwork_pgs_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") vnetwork_pgs = ET.SubElement(output, "vnetwork-pgs") datacenter = ET.SubElement(vnetwork_pgs, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_vnetwork_pgs_vs_nn(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") vnetwork_pgs = ET.SubElement(output, "vnetwork-pgs") vs_nn = ET.SubElement(vnetwork_pgs, "vs-nn") vs_nn.text = kwargs.pop('vs_nn') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_vnetwork_pgs_vlan(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") vnetwork_pgs = ET.SubElement(output, "vnetwork-pgs") vlan = ET.SubElement(vnetwork_pgs, "vlan") vlan.text = kwargs.pop('vlan') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_vnetwork_pgs_host_nn(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") vnetwork_pgs = ET.SubElement(output, "vnetwork-pgs") host_nn = ET.SubElement(vnetwork_pgs, "host-nn") host_nn.text = kwargs.pop('host_nn') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_has_more(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") has_more = ET.SubElement(output, "has-more") has_more.text = kwargs.pop('has_more') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vnetwork_portgroups_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vnetwork_portgroups = ET.Element("get_vnetwork_portgroups") config = get_vnetwork_portgroups output = ET.SubElement(get_vnetwork_portgroups, "output") instance_id = ET.SubElement(output, "instance-id") instance_id.text = kwargs.pop('instance_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_input_mac(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr input = ET.SubElement(get_vmpolicy_macaddr, "input") mac = ET.SubElement(input, "mac") mac.text = kwargs.pop('mac') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_input_vcenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr input = ET.SubElement(get_vmpolicy_macaddr, "input") vcenter = ET.SubElement(input, "vcenter") vcenter.text = kwargs.pop('vcenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_input_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr input = ET.SubElement(get_vmpolicy_macaddr, "input") datacenter = ET.SubElement(input, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_input_last_rcvd_instance(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr input = ET.SubElement(get_vmpolicy_macaddr, "input") last_rcvd_instance = ET.SubElement(input, "last-rcvd-instance") last_rcvd_instance.text = kwargs.pop('last_rcvd_instance') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_mac(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") mac = ET.SubElement(vmpolicy_macaddr, "mac") mac.text = kwargs.pop('mac') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") name = ET.SubElement(vmpolicy_macaddr, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_datacenter(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") datacenter = ET.SubElement(vmpolicy_macaddr, "datacenter") datacenter.text = kwargs.pop('datacenter') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_dvpg_nn(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") dvpg_nn = ET.SubElement(vmpolicy_macaddr, "dvpg-nn") dvpg_nn.text = kwargs.pop('dvpg_nn') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_port_nn(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") port_nn = ET.SubElement(vmpolicy_macaddr, "port-nn") port_nn.text = kwargs.pop('port_nn') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_vmpolicy_macaddr_port_prof(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") vmpolicy_macaddr = ET.SubElement(output, "vmpolicy-macaddr") port_prof = ET.SubElement(vmpolicy_macaddr, "port-prof") port_prof.text = kwargs.pop('port_prof') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_has_more(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") has_more = ET.SubElement(output, "has-more") has_more.text = kwargs.pop('has_more') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_vmpolicy_macaddr_output_instance_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_vmpolicy_macaddr = ET.Element("get_vmpolicy_macaddr") config = get_vmpolicy_macaddr output = ET.SubElement(get_vmpolicy_macaddr, "output") instance_id = ET.SubElement(output, "instance-id") instance_id.text = kwargs.pop('instance_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id = ET.SubElement(vcenter, "id") id.text = kwargs.pop('id') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_credentials_url(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') credentials = ET.SubElement(vcenter, "credentials") url = ET.SubElement(credentials, "url") url.text = kwargs.pop('url') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_credentials_username(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') credentials = ET.SubElement(vcenter, "credentials") username = ET.SubElement(credentials, "username") username.text = kwargs.pop('username') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_credentials_password(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') credentials = ET.SubElement(vcenter, "credentials") password = ET.SubElement(credentials, "password") password.text = kwargs.pop('password') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_credentials_vrf_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') credentials = ET.SubElement(vcenter, "credentials") vrf_name = ET.SubElement(credentials, "vrf-name") vrf_name.text = kwargs.pop('vrf_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_activate(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') activate = ET.SubElement(vcenter, "activate") callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_interval(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') interval = ET.SubElement(vcenter, "interval") interval.text = kwargs.pop('interval') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_discovery_ignore_delete_all_response_ignore_value(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') discovery = ET.SubElement(vcenter, "discovery") ignore_delete_all_response = ET.SubElement(discovery, "ignore-delete-all-response") ignore_value = ET.SubElement(ignore_delete_all_response, "ignore-value") ignore_value.text = kwargs.pop('ignore_value') callback = kwargs.pop('callback', self._callback) return callback(config)
def vcenter_discovery_ignore_delete_all_response_always(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") vcenter = ET.SubElement(config, "vcenter", xmlns="urn:brocade.com:mgmt:brocade-vswitch") id_key = ET.SubElement(vcenter, "id") id_key.text = kwargs.pop('id') discovery = ET.SubElement(vcenter, "discovery") ignore_delete_all_response = ET.SubElement(discovery, "ignore-delete-all-response") always = ET.SubElement(ignore_delete_all_response, "always") callback = kwargs.pop('callback', self._callback) return callback(config)
def fcoe_fcoe_map_fcoe_map_fabric_map_fcoe_map_fabric_map_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fcoe = ET.SubElement(config, "fcoe", xmlns="urn:brocade.com:mgmt:brocade-fcoe") fcoe_map = ET.SubElement(fcoe, "fcoe-map") fcoe_map_name_key = ET.SubElement(fcoe_map, "fcoe-map-name") fcoe_map_name_key.text = kwargs.pop('fcoe_map_name') fcoe_map_fabric_map = ET.SubElement(fcoe_map, "fcoe-map-fabric-map") fcoe_map_fabric_map_name = ET.SubElement(fcoe_map_fabric_map, "fcoe-map-fabric-map-name") fcoe_map_fabric_map_name.text = kwargs.pop('fcoe_map_fabric_map_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def fcoe_fcoe_fcf_map_fcf_map_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fcoe = ET.SubElement(config, "fcoe", xmlns="urn:brocade.com:mgmt:brocade-fcoe") fcoe_fcf_map = ET.SubElement(fcoe, "fcoe-fcf-map") fcf_map_name = ET.SubElement(fcoe_fcf_map, "fcf-map-name") fcf_map_name.text = kwargs.pop('fcf_map_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def fcoe_fcoe_fcf_map_fcf_map_fcoe_map_fcf_map_fcoe_map_leaf(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fcoe = ET.SubElement(config, "fcoe", xmlns="urn:brocade.com:mgmt:brocade-fcoe") fcoe_fcf_map = ET.SubElement(fcoe, "fcoe-fcf-map") fcf_map_name_key = ET.SubElement(fcoe_fcf_map, "fcf-map-name") fcf_map_name_key.text = kwargs.pop('fcf_map_name') fcf_map_fcoe_map = ET.SubElement(fcoe_fcf_map, "fcf-map-fcoe-map") fcf_map_fcoe_map_leaf = ET.SubElement(fcf_map_fcoe_map, "fcf-map-fcoe-map-leaf") fcf_map_fcoe_map_leaf.text = kwargs.pop('fcf_map_fcoe_map_leaf') callback = kwargs.pop('callback', self._callback) return callback(config)
def fcoe_fcoe_fcf_map_fcf_map_ag_rbid(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") fcoe = ET.SubElement(config, "fcoe", xmlns="urn:brocade.com:mgmt:brocade-fcoe") fcoe_fcf_map = ET.SubElement(fcoe, "fcoe-fcf-map") fcf_map_name_key = ET.SubElement(fcoe_fcf_map, "fcf-map-name") fcf_map_name_key.text = kwargs.pop('fcf_map_name') fcf_map_ag_rbid = ET.SubElement(fcoe_fcf_map, "fcf-map-ag-rbid") fcf_map_ag_rbid.text = kwargs.pop('fcf_map_ag_rbid') callback = kwargs.pop('callback', self._callback) return callback(config)
def gfm(text): """Processes Markdown according to GitHub Flavored Markdown spec.""" extractions = {} def extract_pre_block(matchobj): match = matchobj.group(0) hashed_match = hashlib.md5(match.encode('utf-8')).hexdigest() extractions[hashed_match] = match result = "{gfm-extraction-%s}" % hashed_match return result def escape_underscore(matchobj): match = matchobj.group(0) if match.count('_') > 1: return re.sub('_', '\_', match) else: return match def newlines_to_brs(matchobj): match = matchobj.group(0) if re.search("\n{2}", match): return match else: match = match.strip() return match + " \n" def insert_pre_block(matchobj): string = "\n\n" + extractions[matchobj.group(1)] return string text = re.sub("(?s)<pre>.*?<\/pre>", extract_pre_block, text) text = re.sub("(^(?! {4}|\t)\w+_\w+_\w[\w_]*)", escape_underscore, text) text = re.sub("(?m)^[\w\<][^\n]*\n+", newlines_to_brs, text) text = re.sub("\{gfm-extraction-([0-9a-f]{32})\}", insert_pre_block, text) return text
def markdown(text): """Processes GFM then converts it to HTML.""" text = gfm(text) text = markdown_lib.markdown(text) return text
def get_port_channel_detail_input_last_aggregator_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_port_channel_detail = ET.Element("get_port_channel_detail") config = get_port_channel_detail input = ET.SubElement(get_port_channel_detail, "input") last_aggregator_id = ET.SubElement(input, "last-aggregator-id") last_aggregator_id.text = kwargs.pop('last_aggregator_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_interface_based_request_forwarding_interface_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_interface_based_request = ET.SubElement(request_type, "get-interface-based-request") forwarding_interface = ET.SubElement(get_interface_based_request, "forwarding-interface") interface_type = ET.SubElement(forwarding_interface, "interface-type") interface_type.text = kwargs.pop('interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_interface_based_request_forwarding_interface_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_interface_based_request = ET.SubElement(request_type, "get-interface-based-request") forwarding_interface = ET.SubElement(get_interface_based_request, "forwarding-interface") interface_name = ET.SubElement(forwarding_interface, "interface-name") interface_name.text = kwargs.pop('interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_interface_based_request_mac_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_interface_based_request = ET.SubElement(request_type, "get-interface-based-request") mac_type = ET.SubElement(get_interface_based_request, "mac-type") mac_type.text = kwargs.pop('mac_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_next_request_forwarding_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_next_request = ET.SubElement(request_type, "get-next-request") forwarding_interface_type = ET.SubElement(get_next_request, "forwarding-interface-type") forwarding_interface_type.text = kwargs.pop('forwarding_interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_next_request_forwarding_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_next_request = ET.SubElement(request_type, "get-next-request") forwarding_interface_name = ET.SubElement(get_next_request, "forwarding-interface-name") forwarding_interface_name.text = kwargs.pop('forwarding_interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_address_table_input_request_type_get_next_request_mac_address_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_address_table = ET.Element("get_mac_address_table") config = get_mac_address_table input = ET.SubElement(get_mac_address_table, "input") request_type = ET.SubElement(input, "request-type") get_next_request = ET.SubElement(request_type, "get-next-request") mac_address_type = ET.SubElement(get_next_request, "mac-address-type") mac_address_type.text = kwargs.pop('mac_address_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_standard_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") standard = ET.SubElement(access_list, "standard") name = ET.SubElement(standard, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_standard_hide_mac_acl_std_seq_seq_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") standard = ET.SubElement(access_list, "standard") name_key = ET.SubElement(standard, "name") name_key.text = kwargs.pop('name') hide_mac_acl_std = ET.SubElement(standard, "hide-mac-acl-std") seq = ET.SubElement(hide_mac_acl_std, "seq") seq_id = ET.SubElement(seq, "seq-id") seq_id.text = kwargs.pop('seq_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_standard_hide_mac_acl_std_seq_action(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") standard = ET.SubElement(access_list, "standard") name_key = ET.SubElement(standard, "name") name_key.text = kwargs.pop('name') hide_mac_acl_std = ET.SubElement(standard, "hide-mac-acl-std") seq = ET.SubElement(hide_mac_acl_std, "seq") seq_id_key = ET.SubElement(seq, "seq-id") seq_id_key.text = kwargs.pop('seq_id') action = ET.SubElement(seq, "action") action.text = kwargs.pop('action') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_extended_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") extended = ET.SubElement(access_list, "extended") name = ET.SubElement(extended, "name") name.text = kwargs.pop('name') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_extended_hide_mac_acl_ext_seq_seq_id(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") extended = ET.SubElement(access_list, "extended") name_key = ET.SubElement(extended, "name") name_key.text = kwargs.pop('name') hide_mac_acl_ext = ET.SubElement(extended, "hide-mac-acl-ext") seq = ET.SubElement(hide_mac_acl_ext, "seq") seq_id = ET.SubElement(seq, "seq-id") seq_id.text = kwargs.pop('seq_id') callback = kwargs.pop('callback', self._callback) return callback(config)
def mac_access_list_extended_hide_mac_acl_ext_seq_action(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") mac = ET.SubElement(config, "mac", xmlns="urn:brocade.com:mgmt:brocade-mac-access-list") access_list = ET.SubElement(mac, "access-list") extended = ET.SubElement(access_list, "extended") name_key = ET.SubElement(extended, "name") name_key.text = kwargs.pop('name') hide_mac_acl_ext = ET.SubElement(extended, "hide-mac-acl-ext") seq = ET.SubElement(hide_mac_acl_ext, "seq") seq_id_key = ET.SubElement(seq, "seq-id") seq_id_key.text = kwargs.pop('seq_id') action = ET.SubElement(seq, "action") action.text = kwargs.pop('action') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_input_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf input = ET.SubElement(get_mac_acl_for_intf, "input") interface_type = ET.SubElement(input, "interface-type") interface_type.text = kwargs.pop('interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_input_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf input = ET.SubElement(get_mac_acl_for_intf, "input") interface_name = ET.SubElement(input, "interface-name") interface_name.text = kwargs.pop('interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_input_direction(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf input = ET.SubElement(get_mac_acl_for_intf, "input") direction = ET.SubElement(input, "direction") direction.text = kwargs.pop('direction') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_output_interface_interface_type(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf output = ET.SubElement(get_mac_acl_for_intf, "output") interface = ET.SubElement(output, "interface") interface_name_key = ET.SubElement(interface, "interface-name") interface_name_key.text = kwargs.pop('interface_name') interface_type = ET.SubElement(interface, "interface-type") interface_type.text = kwargs.pop('interface_type') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_output_interface_interface_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf output = ET.SubElement(get_mac_acl_for_intf, "output") interface = ET.SubElement(output, "interface") interface_type_key = ET.SubElement(interface, "interface-type") interface_type_key.text = kwargs.pop('interface_type') interface_name = ET.SubElement(interface, "interface-name") interface_name.text = kwargs.pop('interface_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_mac_acl_for_intf_output_interface_ingress_policy_policy_name(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") get_mac_acl_for_intf = ET.Element("get_mac_acl_for_intf") config = get_mac_acl_for_intf output = ET.SubElement(get_mac_acl_for_intf, "output") interface = ET.SubElement(output, "interface") interface_type_key = ET.SubElement(interface, "interface-type") interface_type_key.text = kwargs.pop('interface_type') interface_name_key = ET.SubElement(interface, "interface-name") interface_name_key.text = kwargs.pop('interface_name') ingress_policy = ET.SubElement(interface, "ingress-policy") policy_name = ET.SubElement(ingress_policy, "policy-name") policy_name.text = kwargs.pop('policy_name') callback = kwargs.pop('callback', self._callback) return callback(config)
def add_log_options(self, verbose_func=None, quiet_func=None): """ A helper for setting up log options """ if not verbose_func: def verbose_func(): return log.config(verbose=True) if not quiet_func: def quiet_func(): return log.config(quiet=True) self.option('-v, --verbose', 'show more logs', verbose_func) self.option('-q, --quiet', 'show less logs', quiet_func) return self
def local_asn(self, **kwargs): """Set BGP local ASN. Args: local_as (str): Local ASN of NOS deice. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. get (bool): Get config instead of editing config. (True, False) callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: Return value of `callback`. Raises: KeyError: if `local_as` is not specified. Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.local_asn(local_as='65535', ... rbridge_id='225') ... dev.bgp.local_asn() # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): KeyError """ is_get_config = kwargs.pop('get', False) if not is_get_config: local_as = kwargs.pop('local_as') else: local_as = ''
rbridge_id = kwargs.pop('rbridge_id', '1') callback = kwargs.pop('callback', self._callback) local_as_args = dict(local_as=local_as, rbridge_id=rbridge_id) enable_bgp = getattr(self._rbridge, 'rbridge_id_router_router_bgp_router_bgp_' 'attributes_local_as')(**local_as_args) bgp = enable_bgp.find('.//*.//*.//*') bgp.remove(bgp.find('.//*')) if not is_get_config: callback(enable_bgp) local_as = getattr(self._rbridge, 'rbridge_id_router_router_bgp_router_bgp_attri' 'butes_local_as') config = local_as(**local_as_args) if is_get_config: return callback(config, handler='get_config') return callback(config)
def as4_capability(self, **kwargs): """Set Spanning Tree state. Args: enabled (bool): Is AS4 Capability enabled? (True, False) callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: Return value of `callback`. Raises: ValueError: if `enabled` are invalid. Examples: >>> import pynos.device >>> switches = ['10.24.39.211', '10.24.39.203'] >>> auth = ('admin', 'password') >>> for switch in switches: ... conn = (switch, '22') ... with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.local_asn(local_as='65535', ... rbridge_id='225') ... output = dev.bgp.as4_capability( ... rbridge_id='225', enabled=True) ... output = dev.bgp.as4_capability( ... rbridge_id='225', enabled=False) """ enabled = kwargs.pop('enabled', True) callback = kwargs.pop('callback', self._callback) if not isinstance(enabled, bool): raise ValueError('%s must be `True` or `False`.' % repr(enabled)) as4_capability_args = dict(vrf_name=kwargs.pop('vrf', 'default'), rbridge_id=kwargs.pop('rbridge_id', '1')) as4_capability =
getattr(self._rbridge, 'rbridge_id_router_router_bgp_router_bgp' '_attributes_capability_as4_enable') config = as4_capability(**as4_capability_args) if not enabled: capability = config.find('.//*capability') capability.set('operation', 'delete') # shutdown = capability.find('.//*as4-enable') # shutdown.set('operation', 'delete') return callback(config)
def remove_bgp(self, **kwargs): """Remove BGP process completely. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: Return value of `callback`. Raises: None Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.local_asn(local_as='65535', ... rbridge_id='225') ... output = dev.bgp.remove_bgp(rbridge_id='225') """ rbridge_id = kwargs.pop('rbridge_id', '1') callback = kwargs.pop('callback', self._callback) disable_args = dict(rbridge_id=rbridge_id, local_as='65000') config = getattr(self._rbridge, 'rbridge_id_router_router_bgp_router_bgp_' 'attributes_local_as')(**disable_args) bgp = config.find('.//*.//*.//*') bgp.remove(bgp.find('.//*')) bgp.set('operation', 'delete') return callback(config)
def neighbor(self, **kwargs): """Add BGP neighbor. Args: ip_addr (str): IP Address of BGP neighbor. remote_as (str): Remote ASN of BGP neighbor. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. delete (bool): Deletes the neighbor if `delete` is ``True``. get (bool): Get config instead of editing config. (True, False) callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. # Returns: Return value of `callback`. Raises: KeyError: if `remote_as` or `ip_addr` is not specified. Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.local_asn(local_as='65535', ... rbridge_id='225') ... output = dev.bgp.neighbor(ip_addr='10.10.10.10', ... remote_as='65535', rbridge_id='225') ...
output = dev.bgp.neighbor(remote_as='65535', ... rbridge_id='225', ... ip_addr='2001:4818:f000:1ab:cafe:beef:1000:1') ... output = dev.bgp.neighbor(ip_addr='10.10.10.10', ... delete=True, rbridge_id='225') ... output = dev.bgp.neighbor(remote_as='65535', ... rbridge_id='225', ... ip_addr='2001:4818:f000:1ab:cafe:beef:1000:1', ... delete=True) ... dev.bgp.neighbor() # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): KeyError """ ip_addr = kwargs.pop('ip_addr') remote_as = kwargs.pop('remote_as', None) rbridge_id = kwargs.pop('rbridge_id', '1') delete = kwargs.pop('delete', False) callback = kwargs.pop('callback', self._callback) ip_addr = ip_interface(unicode(ip_addr)) if not delete and remote_as is None: raise ValueError('When configuring a neighbor, you must specify ' 'its remote-as.') neighbor_args = dict(router_bgp_neighbor_address=str(ip_addr.ip), remote_as=remote_as, rbridge_id=rbridge_id) if ip_addr.version == 6: neighbor_args['router_bgp_neighbor_ipv6_address'] = str(ip_addr.ip) if ip_addr.version == 4: neighbor = getattr(self._rbridge, 'rbridge_id_router_router_bgp_' 'router_bgp_attributes_neighbor_neighbor_ips_' 'neighbor_addr_remote_as') ip_addr_path = './/*remote-as' else: neighbor = getattr(self._rbridge, 'rbridge_id_router_router_bgp_' 'router_bgp_attributes_neighbor_' 'neighbor_ipv6s_neighbor_ipv6_addr_remote_as') ip_addr_path = './/*remote-as' config = neighbor(**neighbor_args) if delete and config.find(ip_addr_path) is not None: if ip_addr.version == 4: config.find(ip_addr_path).set('operation', 'delete') config.find('.//*router-bgp-neighbor-address').set('operation',
'delete') elif ip_addr.version == 6: config.find(ip_addr_path).set('operation', 'delete') config.find('.//*router-bgp-neighbor-ipv6-address').set( 'operation', 'delete') else: if ip_addr.version == 6: callback(config) activate_args = dict(rbridge_id=rbridge_id, af_ipv6_neighbor_address=str(ip_addr.ip)) activate_neighbor = getattr(self._rbridge, 'rbridge_id_router_router_bgp_' 'address_family_ipv6_ipv6_unicast_' 'default_vrf_neighbor_af_ipv6_' 'neighbor_address_holder_af_ipv6_' 'neighbor_address_activate') config = activate_neighbor(**activate_args) if kwargs.pop('get', False): return callback(config, handler='get_config') return callback(config)
def redistribute(self, **kwargs): """Set BGP redistribute properties. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. source (str): Source for redistributing. (connected) afi (str): Address family to configure. (ipv4, ipv6) get (bool): Get config instead of editing config. (True, False) callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: Return value of `callback`. Raises: KeyError: if `source` is not specified. Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.redistribute(source='connected', ... rbridge_id='225') ... output = dev.bgp.redistribute(source='connected', ... rbridge_id='225', get=True) ... output = dev.bgp.redistribute(source='connected',
... rbridge_id='225', delete=True) ... dev.bgp.redistribute() # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): KeyError ... dev.bgp.redistribute(source='connected', rbridge_id='225', ... afi='hodor') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): AttributeError ... dev.bgp.redistribute(source='hodor', rbridge_id='225', ... afi='ipv4') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): AttributeError """ # This method is the same as the base method except for one place. # The class doesn't inherit from the base class, though, so we have # to duplicate. source = kwargs.pop('source') afi = kwargs.pop('afi', 'ipv4') callback = kwargs.pop('callback', self._callback) if afi not in ['ipv4', 'ipv6']: raise AttributeError('Invalid AFI.') args = dict(rbridge_id=kwargs.pop('rbridge_id', '1'), afi=afi, source=source) redistribute = self._redistribute_builder(afi=afi, source=source) config = redistribute(**args) if kwargs.pop('get', False): return callback(config, handler='get_config') if kwargs.pop('delete', False): tag = 'redistribute-%s' % source config.find('.//*%s' % tag).set('operation', 'delete') return callback(config)
def _redistribute_builder(self, afi='ipv4', source=None): """Build BGP redistribute method. Do not use this method directly. You probably want ``redistribute``. Args: source (str): Source for redistributing. (connected) afi (str): Address family to configure. (ipv4, ipv6) Returns: Method to redistribute desired source. Raises: KeyError: if `source` is not specified. Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp._redistribute_builder(source='connected', ... afi='ipv4') ... dev.bgp._redistribute_builder(source='hodor', ... afi='ipv4') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): AttributeError """ if source == 'connected': return getattr(self._rbridge, 'rbridge_id_router_router_bgp_address_family_{0}_' '{0}_unicast_default_vrf_af_{0}_uc_and_vrf_cmds_' 'call_point_holder_redistribute_connected_' 'redistribute_connected'.format(afi)) # TODO: Add support for 'static' and 'ospf' else: raise AttributeError('Invalid source.')
def max_paths(self, **kwargs): """Set BGP max paths property. Args: vrf (str): The VRF for this BGP process. rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. paths (str): Number of paths for BGP ECMP (default: 8). afi (str): Address family to configure. (ipv4, ipv6) get (bool): Get config instead of editing config. (True, False) callback (function): A function executed upon completion of the method. The only parameter passed to `callback` will be the ``ElementTree`` `config`. Returns: Return value of `callback`. Raises: ``AttributeError``: When `afi` is not one of ['ipv4', 'ipv6'] Examples: >>> import pynos.device >>> conn = ('10.24.39.203', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... output = dev.bgp.max_paths(paths='8', ... rbridge_id='225') ... output =
dev.bgp.max_paths(paths='8', ... rbridge_id='225', get=True) ... output = dev.bgp.max_paths(paths='8', ... rbridge_id='225', delete=True) ... output = dev.bgp.max_paths(paths='8', afi='ipv6', ... rbridge_id='225') ... output = dev.bgp.max_paths(paths='8', afi='ipv6', ... rbridge_id='225', get=True) ... output = dev.bgp.max_paths(paths='8', afi='ipv6', ... rbridge_id='225', delete=True) ... output = dev.bgp.max_paths(paths='8', afi='ipv5', ... rbridge_id='225') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): AttributeError """ afi = kwargs.pop('afi', 'ipv4') callback = kwargs.pop('callback', self._callback) if afi not in ['ipv4', 'ipv6']: raise AttributeError('Invalid AFI.') args = dict(rbridge_id=kwargs.pop('rbridge_id', '1'), load_sharing_value=kwargs.pop('paths', '8')) max_paths = getattr(self._rbridge, 'rbridge_id_router_router_bgp_address_family_{0}_' '{0}_unicast_default_vrf_af_common_cmds_holder_' 'maximum_paths_load_sharing_value'.format(afi)) config = max_paths(**args) if kwargs.pop('get', False): return callback(config, handler='get_config') if kwargs.pop('delete', False): tag = 'maximum-paths' config.find('.//*%s' % tag).set('operation', 'delete') return callback(config)
def _multihop_xml(self, **kwargs): """Build BGP multihop XML. Do not use this method directly. You probably want ``multihop``. Args: rbridge_id (str): The rbridge ID of the device on which BGP will be configured in a VCS fabric. neighbor (ipaddress.ip_interface): `ip_interface` object containing peer IP address (IPv4 or IPv6). count (str): Number of hops to allow. (1-255) Returns: ``ElementTree``: XML for configuring BGP multihop. Raises: KeyError: if any arg is not specified. Examples: >>> import pynos.device >>> from ipaddress import ip_interface >>> conn = ('10.24.39.230', '22') >>> auth = ('admin', 'password') >>> with pynos.device.Device(conn=conn, auth=auth) as dev: ... dev.bgp._multihop_xml(neighbor=ip_interface(unicode( ... '10.10.10.10')), count='5', vrf='default', rbridge_id='1') ... dev.bgp._multihop_xml( ... ip='10.10.10.10') # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): KeyError """ ip_addr = kwargs.pop('neighbor') ip = str(ip_addr.ip) rbr_ns = 'urn:brocade.com:mgmt:brocade-rbridge' bgp_ns = 'urn:brocade.com:mgmt:brocade-bgp'
config = ET.Element('config') ele = ET.SubElement(config, 'rbridge-id', xmlns=rbr_ns) ET.SubElement(ele, 'rbridge-id').text = kwargs.pop('rbridge_id') ele = ET.SubElement(ele, 'router') ele = ET.SubElement(ele, 'router-bgp', xmlns=bgp_ns) ele = ET.SubElement(ele, 'router-bgp-attributes') ele = ET.SubElement(ele, 'neighbor') if ip_addr.version == 4: ele = ET.SubElement(ele, 'neighbor-ips') ele = ET.SubElement(ele, 'neighbor-addr') ET.SubElement(ele, 'router-bgp-neighbor-address').text = ip else: ele = ET.SubElement(ele, 'neighbor-ipv6s') ele = ET.SubElement(ele, 'neighbor-ipv6-addr') ET.SubElement(ele, 'router-bgp-neighbor-ipv6-address').text = ip ele = ET.SubElement(ele, 'ebgp-multihop') ET.SubElement(ele, 'ebgp-multihop-count').text = kwargs.pop('count') return config
def return_xml(element_tree): """Return an XML Element. Args: element_tree (Element): XML Element to be returned. If sent as a ``str``, this function will attempt to convert it to an ``Element``. Returns: Element: An XML Element. Raises: TypeError: if `element_tree` is not of type ``Element`` and it cannot be converted from a ``str``. Examples: >>> import pynos.utilities >>> import xml.etree.ElementTree as ET >>> ele = pynos.utilities.return_xml(ET.Element('config')) >>> assert isinstance(ele, ET.Element) >>> ele = pynos.utilities.return_xml('<config />') >>> assert isinstance(ele, ET.Element) >>> ele = pynos.utilities.return_xml( ... ['hodor']) # doctest: +IGNORE_EXCEPTION_DETAIL Traceback (most recent call last): TypeError """ if isinstance(element_tree, ET.Element): return element_tree try: return ET.fromstring(element_tree) except TypeError: raise TypeError('{} takes either {} or {} type.' .format(repr(return_xml.__name__), repr(str.__name__), repr(ET.Element.__name__)))
def valid_vlan_id(vlan_id, extended=True): """Validates a VLAN ID. Args: vlan_id (integer): VLAN ID to validate. If passed as ``str``, it will be cast to ``int``. extended (bool): If the VLAN ID range should be considered extended for Virtual Fabrics. Returns: bool: ``True`` if it is a valid VLAN ID. ``False`` if not. Raises: None Examples: >>> import pynos.utilities >>> vlan = '565' >>> pynos.utilities.valid_vlan_id(vlan) True >>> extended = False >>> vlan = '6789' >>> pynos.utilities.valid_vlan_id(vlan, extended=extended) False >>> pynos.utilities.valid_vlan_id(vlan) True """ minimum_vlan_id = 1 maximum_vlan_id = 4095 if extended: maximum_vlan_id = 8191 return minimum_vlan_id <= int(vlan_id) <= maximum_vlan_id
def merge_xml(first_doc, second_doc): """Merges two XML documents. Args: first_doc (str): First XML document. `second_doc` is merged into this document. second_doc (str): Second XML document. It is merged into the first. Returns: XML Document: The merged document. Raises: None Example: >>> import pynos.utilities >>> import lxml >>> import xml >>> x = xml.etree.ElementTree.fromstring('<config />') >>> y = lxml.etree.fromstring('<config><hello /></config>') >>> x = pynos.utilities.merge_xml(x, y) """ # Adapted from: # http://stackoverflow.com/questions/27258013/merge-two-xml-files-python # Maps each elements tag to the element from the first document if isinstance(first_doc, lxml.etree._Element): first_doc = ET.fromstring(lxml.etree.tostring(first_doc)) if isinstance(second_doc, lxml.etree._Element): second_doc = ET.fromstring(lxml.etree.tostring(second_doc)) mapping = {element.tag: element for element in first_doc} for element in second_doc: if not len(element): # Recursed fully. This element has no children. try: # Update the first document's element's text mapping[element.tag].text = element.text except
KeyError: # The element doesn't exist # add it to the mapping and the root document mapping[element.tag] = element first_doc.append(element) else: # This element has children. Recurse. try: merge_xml(mapping[element.tag], element) except KeyError: # The element doesn't exist # add it to the mapping and the root document mapping[element.tag] = element first_doc.append(element) return lxml.etree.fromstring(ET.tostring(first_doc))
def terminal_cfg_line_sessionid(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") terminal_cfg = ET.SubElement(config, "terminal-cfg", xmlns="urn:brocade.com:mgmt:brocade-terminal") line = ET.SubElement(terminal_cfg, "line") sessionid = ET.SubElement(line, "sessionid") sessionid.text = kwargs.pop('sessionid') callback = kwargs.pop('callback', self._callback) return callback(config)
def terminal_cfg_line_exec_timeout(self, **kwargs): """Auto Generated Code """ config = ET.Element("config") terminal_cfg = ET.SubElement(config, "terminal-cfg", xmlns="urn:brocade.com:mgmt:brocade-terminal") line = ET.SubElement(terminal_cfg, "line") sessionid_key = ET.SubElement(line, "sessionid") sessionid_key.text = kwargs.pop('sessionid') exec_timeout = ET.SubElement(line, "exec-timeout") exec_timeout.text = kwargs.pop('exec_timeout') callback = kwargs.pop('callback', self._callback) return callback(config)
def get_scss_files(self, skip_partials=True, with_source_path=False): """Gets all SCSS files in the source directory. :param bool skip_partials: If True, partials will be ignored. Otherwise, all SCSS files, including ones that begin with '_' will be returned. :param boom with_source_path: If true, the `source_path` will be added to all of the paths. Otherwise, it will be stripped. :returns: A list of the SCSS files in the source directory """ scss_files = [] for root, dirs, files in os.walk(self._source_path): for filename in fnmatch.filter(files, "*.scss"): if filename.startswith("_") and skip_partials: continue full_path = os.path.join(root, filename) if not with_source_path: full_path = full_path.split(self._source_path)[1] if full_path.startswith("/"): full_path = full_path[1:] scss_files.append(full_path) return scss_files
def _or_join(self, terms): """ Joins terms using OR operator. Args: terms (list): terms to join Examples: self._or_join(['term1', 'term2']) -> 'term1 | term2' Returns: str """ from six import text_type if isinstance(terms, (tuple, list)): if len(terms) > 1: return ' | '.join(text_type(t) for t in terms) else: return terms[0] else: return terms
def search(self, search_phrase, limit=None): """ Finds datasets by search phrase. Args: search_phrase (str or unicode): limit (int, optional): how many results to return. None means without limit. Returns: list of DatasetSearchResult instances. """ query, query_params = self._make_query_from_terms(search_phrase, limit=limit) self._parsed_query = (str(query), query_params) assert isinstance(query, TextClause) datasets = {} def make_result(vid=None, b_score=0, p_score=0): res = DatasetSearchResult() res.b_score = b_score res.p_score = p_score res.partitions = set() res.vid = vid return res if query_params: results = self.execute(query, **query_params) for result in results: vid, dataset_score = result datasets[vid] = make_result(vid, b_score=dataset_score) logger.debug('Extending datasets with partitions.') for partition in self.backend.partition_index.search(search_phrase): if partition.dataset_vid not in datasets: datasets[partition.dataset_vid] = make_result(partition.dataset_vid) datasets[partition.dataset_vid].p_score += partition.score datasets[partition.dataset_vid].partitions.add(partition) return list(datasets.values())
def all(self): """ Returns list with all indexed datasets. """ datasets = [] query = text(""" SELECT vid FROM dataset_index;""") for result in self.execute(query): res = DatasetSearchResult() res.vid = result[0] res.b_score = 1 datasets.append(res) return datasets
def _index_document(self, document, force=False): """ Adds dataset document to the index. """ query = text(""" INSERT INTO dataset_index(vid, title, keywords, doc) VALUES(:vid, :title, string_to_array(:keywords, ' '), to_tsvector('english', :doc)); """) self.execute(query, **document)