Example #1
0
def listdc():

    dc_list = list()
    for dc in Datacenter().get_dc():
        dc_list.append(rack_serializers.DCSerializer(dc).data)

    dc_sorted = sorted(dc_list, key=operator.itemgetter('dcname'))

    for dcs in dc_sorted:
        fabric = DatacenterRooms().get_dcrooms(id_dc=dcs.get("id"))
        fabric_list = list()
        for i in fabric:
            fabric_list.append(rack_serializers.DCRoomSerializer(i).data)
        dcs["fabric"] = fabric_list

    return dc_sorted
Example #2
0
def get_fabric(idt=None, name=None, id_dc=None):

    fabric_list = list()
    fabric_obj = DatacenterRooms()

    if idt:
        fabric = [fabric_obj.get_dcrooms(idt=idt)]
    elif name:
        fabric = fabric_obj.get_dcrooms(name=name)

    elif id_dc:
        fabric = fabric_obj.get_dcrooms(id_dc=id_dc)
    else:
        fabric = fabric_obj.get_dcrooms()

    for i in fabric:
        fabric_list.append(rack_serializers.DCRoomSerializer(i).data)

    return fabric_list