- Timestamp:
- May 19, 2010 6:56:37 AM (15 years ago)
- Branches:
- axis_example, compt_changes, info-ops, master, version-3.01, version-3.02
- Children:
- df3179c
- Parents:
- 7ee16b3
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
fedd/compose.py
r7ee16b3 r966c620 167 167 action='store_true', 168 168 help='allow solutions where unrequired constraints fail') 169 self.add_option('--same_node', dest='same_node', action='store_true', 170 default=False, 171 help='Allow loops to the same node to be created.') 172 self.add_option('--same_topology', dest='same_topo', 173 action='store_true', default=False, 174 help='Allow links within the same topology to be created.') 175 self.add_option('--same_pair', dest='multi_pair', 176 action='store_true', default=False, 177 help='Allow multiple links between the same nodes " + \ 178 "to be created.') 169 179 170 180 @staticmethod … … 243 253 i.substrate = [ sub_map.get(ii, ii) for ii in i.substrate ] 244 254 245 def meet_constraints(candidates, provides, accepts): 255 def meet_constraints(candidates, provides, accepts, 256 same_node=False, same_topo=False, multi_pair=False): 246 257 """ 247 258 Try to meet all the constraints in candidates using the information in the … … 261 272 for a in c.accepts: 262 273 for can in provides.get(a,[]): 263 # A constraint cannot satisfy itself, nor do we allow loops 264 # within the same topology. This also excludes matched 265 # constraints. 266 if can.name != c.name and can.topology != c.topology and \ 267 not can.match: 274 # A constraint cannot satisfy itself nor can it match 275 # multiple times. 276 if can != c and not can.match: 277 # Unless same_node is true disallow nodes satisfying 278 # their own constraints. 279 if not same_node and can.name == c.name: 280 continue 281 # Unless same_topo is true, exclude nodes in the same 282 # topology. 283 if not same_topo and can.topology == c.topology: 284 continue 268 285 # Don't allow multiple matches between the same nodes 269 # (the "if" above is already pretty crowded). 270 if c.name in node_match and \ 286 if not multi_pair and c.name in node_match and \ 271 287 can.name in node_match[c.name]: 272 288 continue … … 615 631 616 632 if not meet_constraints([c for c in constraints if c.required], 617 provides, accepts ):633 provides, accepts, opts.same_node, opts.same_topo, opts.multi_pair): 618 634 if opts.lax: 619 635 warn("warning: could not meet all required constraints") … … 622 638 623 639 meet_constraints([ c for c in constraints if not c.match ], 624 provides, accepts )640 provides, accepts, opts.same_node, opts.same_topo, opts.multi_pair) 625 641 626 642 # Add testbed attributes if requested
Note: See TracChangeset
for help on using the changeset viewer.