fabric-testbed / InformationModel

FABRIC Information Model library
MIT License
7 stars 1 forks source link

topology.validate() doesn't check the service constraints on a modified topology #168

Closed kthare10 closed 1 year ago

kthare10 commented 1 year ago

Scenario:

# Create topology
t = ExperimentTopology()

# Set capacities
cap = Capacities(core=1, ram=4, disk=10)

site1 = "UKY"
sites = ["UKY", "RENC"]
num_nodes = 2
name="node"
i=0
ifcs = []
# Auto Configure: Setup IP Addresses
network = IPv4Network("192.168.10.0/26")
ips = list(network.hosts())

for x in range(num_nodes):
    # Add node
    nm = f"{name}-{i}"

    n = t.add_node(name=f"{name}-{i}", site=sites[x])

    # Set properties
    n.set_properties(capacities=cap, image_type='qcow2', image_ref='default_rocky_8')
    n.add_component(model_type=ComponentModelType.SharedNIC_ConnectX_6, name=f"{name}-{i}-nic1")
    #n.add_component(model_type=ComponentModelType.SharedNIC_OpenStack_vNIC, name=f"{name}-{i}-nic1")

    # Auto Configure: Setup IP Addresses
    n.interface_list[0].flags = Flags(auto_config=True)
    n.interface_list[0].labels = Labels.update(n.interface_list[0].labels, ipv4=str(ips[i+1]))
    n.interface_list[0].labels = Labels.update(n.interface_list[0].labels, ipv4_subnet=str(network))
    print(n.interface_list[0].labels)
    ifcs.append(n.interface_list[0])

    i += 1
ns = t.add_network_service(name='sts1', nstype=ServiceType.L2STS, interfaces=ifcs)
t.validate() # success

# Remove one node
t.remove_node(name='node-0')
t.validate() #  This still returns success, but should throw an error as network service now only has one interface attached.
ibaldin commented 1 year ago

There are two reasons here:

  1. STS has no limit on the number of interfaces and there is no minimum
  2. Even if I switch to PTP which has a limit of 2 interfaces, the exception isn't thrown because in this line https://github.com/fabric-testbed/InformationModel/blob/98dbca441beec250bfa6991e94bebe2e5da79c91/fim/user/network_service.py#L233 I currently check for > not ==.

I don't remember if there is a deep reason for why i wasn't checking for strict equality. I tested it with strict equality and it works for PTP (for STS, since no limit is set, I still don't see an error and also, possibly, this is not an error condition - unless the service itself doesn't want to run with fewer than 2 ports).

@kthare10 let me know.

  1. I can add the check for equality (will work for PTP, not STS)
  2. I can also add a minimal_number_of_ports constraint and set it to 2 for both - that's if the AMHandler has problems with fewer than 2.
kthare10 commented 1 year ago

@ibaldin - Can we please do both 1 and 2 as the net_handler.py in AMHandlers rejects the request for both PTP/STS for fewer than 2 ports?

ibaldin commented 1 year ago

I'm adding another field to constraints for min_interfaces. This should allow us to check both the minimum and the maximum number of interfaces.