-
Notifications
You must be signed in to change notification settings - Fork 65
Expand file tree
/
Copy pathcreateL4L7ConcreteInterface.py
More file actions
32 lines (26 loc) · 1.18 KB
/
createL4L7ConcreteInterface.py
File metadata and controls
32 lines (26 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
from cobra.model.vns import CDev, CIf, RsCIfPathAtt
from createMo import *
def input_key_args():
return input_raw_input('Concrete Interface Name', required=True)
def input_optional_args():
args = {}
# TODO
return args
def create_l4l7_concrete_interface(parent_mo, name, **args):
"""Create L4L7 Concrete Interface"""
args = args['optional_args'] if 'optional_args' in args.keys() else args
valid_keys = ['name', 'vnicName']
kwargs = {k: v for k, v in args.items() if (k in valid_keys and v)}
vns_cif = CIf(parent_mo, name, **kwargs)
if 'path' in args:
vns_rscifpathatt = add_source_relation_to_path_endpoint(vns_cif, args['path'])
return vns_cif
def add_source_relation_to_path_endpoint(concrete_interface_mo, path):
"""A source relation to a path endpoint. e.g: 'topology/pod-1/paths-1001/pathep-[eth1/10]' """
return RsCIfPathAtt(concrete_interface_mo, tDn=path)
class CreateL4L7ConcreteInterface(CreateMo):
def __init__(self):
self.description = 'Create an L4-L7 concrete device'
self.tenant_required = True
self.contract = None
super(CreateL4L7ConcreteInterface, self).__init__()