Module pyinventory.api.link

Functions

Connects a link between two ports of two equipments.

Args

equipment_a ( Equipment ): could be retrieved from - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

port_name_a : str
The name of port in equipment type

equipment_b ( Equipment ): could be retrieved from the following apis: - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

port_name_b : str
The name of port in equipment type

Returns

Link object

Raises

AssertionError
if port_name in any of the equipment does not exist, or match more than one port or is already occupied by link
FailedOperationException
for internal inventory error

Example

location1 = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment1 = client.get_equipment(name="indProdCpy1_AIO", location=location1)
location2 = client.get_location({("Country", "LS_IND_Prod")})
equipment2 = client.get_equipment(name="indProd1_AIO", location=location2)
client.add_link(
    equipment_a=equipment1,
    port_name_a="Port A",
    equipment_b=equipment2,
    port_name_b="Port B"
)

Returns all links and port names in equipment.

Args

equipment ( Equipment ): could be retrieved from - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

Returns

List[Tuple[ pyinventory.common.data_class.Link , str]]:

  • Link - link object
  • str - port definition name

Raises

EntityNotFoundError: if link not found
FailedOperationException
for internal inventory error

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment(name="indProdCpy1_AIO", location=location1)
client.get_all_links_and_port_names_of_equipment(equipment=equipment)

Returns link in specific port by name in equipment.

Args

equipment ( Equipment ): could be retrieved from - get_equipment() - get_equipment_in_position() - add_equipment() - add_equipment_to_position()

port_name : str
The name of port in equipment type

Returns

Link object

Raises

LinkNotFoundException
if link not found
FailedOperationException
for internal inventory error

Example

location = client.get_location({("Country", "LS_IND_Prod_Copy")})
equipment = client.get_equipment(name="indProdCpy1_AIO", location=location)
client.get_link_in_port_of_equipment(
    equipment=equipment,
    port_name="Port A"
)