blob: 7b2dcf5e43dc4772ef35be601b0b3fe45dfc7a49 [file] [log] [blame]
magnussonl2b0e2d72020-02-04 10:52:46 +01001% Copyright 2020 ArctosLabs Scandinavia AB
2%
3% Licensed under the Apache License, Version 2.0 (the "License");
4% you may not use this file except in compliance with the License.
5% You may obtain a copy of the License at
6%
7% http://www.apache.org/licenses/LICENSE-2.0
8%
9% Unless required by applicable law or agreed to in writing, software
10% distributed under the License is distributed on an "AS IS" BASIS,
11% WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12% implied.
13% See the License for the specific language governing permissions and
14% limitations under the License.
15{%- macro vim_accounts(vim_accounts) -%}
16enum Vims = {
17{%- for vim in vim_accounts %}
18{{vim}}{% if loop.nextitem is defined%},{% endif %}
19{%- endfor -%}
20}; % The vim-accounts
21{%- endmacro -%}
22
23{%- macro variables_vnf(ns_desc) -%}
24{%- for vnf in ns_desc -%}
25{%- if vnf.vim_account %}
26Vims: VNF{{vnf.vnf_id}} = {{vnf.vim_account}};
27{%- else %}
28var Vims: VNF{{vnf.vnf_id}};
29{%- endif -%}
30{% endfor -%}
31{%- endmacro -%}
32
33{%- macro trp_link_latency(trp_link_latency) -%}
34array[Vims, Vims] of int: trp_link_latency = [
35{%- for row in trp_link_latency -%}
36|
37{%- for col in row -%}
38{{col}},
39{%- endfor %}
40{% endfor -%}
41|]; % Transport link latency between data centers
42{%- endmacro -%}
43
44{%- macro trp_link_jitter(trp_link_jitter) -%}
45array[Vims, Vims] of int: trp_link_jitter = [
46{%- for row in trp_link_jitter -%}
47|
48{%- for col in row -%}
49{{col}},
50{%- endfor %}
51{% endfor -%}
52|]; % Transport link jitter between data centers
53{%- endmacro -%}
54
55{%- macro trp_link_price_list(trp_link_price_list) -%}
56array[Vims, Vims] of int: trp_link_price_list = [
57{%- for row in trp_link_price_list -%}
58|
59{%- for col in row -%}
60{{col}},
61{%- endfor %}
62{% endfor -%}
63|]; % Transport link price list
64{%- endmacro -%}
65
66{%- macro vnf_price_list_per_vim(ns_desc) -%}
67{%- for vnf in ns_desc -%}
68array[Vims] of int: vim_price_list_{{vnf.vnf_id}} = [
69{%- for price in vnf.vnf_price_per_vim -%}
70{{price}}{% if loop.nextitem is defined%},{% endif %}
71{%- endfor -%}
72];
73{% endfor %}
74{%- endmacro -%}
75
76{%- macro vld_constraints(vld_desc) -%}
77{%- for cp in vld_desc -%}
78{%- if 'latency' in cp.keys()%}
79constraint trp_link_latency[VNF{{cp.cp_refs[0]}}, VNF{{cp.cp_refs[1]}}] <= {{cp.latency}};
80{% endif -%}
81{% endfor -%}
82{%- for cp in vld_desc -%}
83{%- if 'jitter' in cp.keys()%}
84constraint trp_link_jitter[VNF{{cp.cp_refs[0]}}, VNF{{cp.cp_refs[1]}}] <= {{cp.jitter}};
85{% endif -%}
86{% endfor -%}
87{%- endmacro -%}
88
89{% macro transport_cost(vld_desc) -%}
90var int: used_transport_cost =
91{%- if not vld_desc -%}
920;
93{% else %}
94{%- for cp in vld_desc -%}
95trp_link_price_list[VNF{{cp.cp_refs[0]}}, VNF{{cp.cp_refs[1]}}]{% if loop.nextitem is defined %}+{% else %};{% endif %}
96{% endfor -%}
97{% endif -%}
98{%- endmacro -%}
99
100{%- macro used_vim_cost(ns_desc) -%}
101var int: used_vim_cost =
102{%- for vnf in ns_desc -%}
103vim_price_list_{{vnf.vnf_id}}[VNF{{vnf.vnf_id}}]{% if loop.nextitem is defined %}+{% else %};{% endif %}
104{% endfor -%}
105{%- endmacro -%}