| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| 4 | # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. |
| 5 | # This file is part of openmano |
| 6 | # All Rights Reserved. |
| 7 | # |
| 8 | # Licensed under the Apache License, Version 2.0 (the "License"); you may |
| 9 | # not use this file except in compliance with the License. You may obtain |
| 10 | # a copy of the License at |
| 11 | # |
| 12 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | # |
| 14 | # Unless required by applicable law or agreed to in writing, software |
| 15 | # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT |
| 16 | # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the |
| 17 | # License for the specific language governing permissions and limitations |
| 18 | # under the License. |
| 19 | # |
| 20 | # For those usages not covered by the Apache License, Version 2.0 please |
| 21 | # contact with: nfvlabs@tid.es |
| 22 | ## |
| 23 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 24 | """ |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 25 | vimconn implement an Abstract class for the vim connector plugins |
| 26 | with the definition of the method to be implemented. |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 27 | """ |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 28 | __author__="Alfonso Tierno, Igor D.C." |
| 29 | __date__ ="$14-aug-2017 23:59:59$" |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 30 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 31 | import logging |
| 32 | |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 33 | #Error variables |
| 34 | HTTP_Bad_Request = 400 |
| 35 | HTTP_Unauthorized = 401 |
| 36 | HTTP_Not_Found = 404 |
| 37 | HTTP_Method_Not_Allowed = 405 |
| 38 | HTTP_Request_Timeout = 408 |
| 39 | HTTP_Conflict = 409 |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 40 | HTTP_Not_Implemented = 501 |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 41 | HTTP_Service_Unavailable = 503 |
| 42 | HTTP_Internal_Server_Error = 500 |
| 43 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 44 | class vimconnException(Exception): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 45 | """Common and base class Exception for all vimconnector exceptions""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 46 | def __init__(self, message, http_code=HTTP_Bad_Request): |
| 47 | Exception.__init__(self, message) |
| 48 | self.http_code = http_code |
| 49 | |
| 50 | class vimconnConnectionException(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 51 | """Connectivity error with the VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 52 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| 53 | vimconnException.__init__(self, message, http_code) |
| 54 | |
| 55 | class vimconnUnexpectedResponse(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 56 | """Get an wrong response from VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 57 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| 58 | vimconnException.__init__(self, message, http_code) |
| 59 | |
| 60 | class vimconnAuthException(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 61 | """Invalid credentials or authorization to perform this action over the VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 62 | def __init__(self, message, http_code=HTTP_Unauthorized): |
| 63 | vimconnException.__init__(self, message, http_code) |
| 64 | |
| 65 | class vimconnNotFoundException(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 66 | """The item is not found at VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 67 | def __init__(self, message, http_code=HTTP_Not_Found): |
| 68 | vimconnException.__init__(self, message, http_code) |
| 69 | |
| 70 | class vimconnConflictException(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 71 | """There is a conflict, e.g. more item found than one""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 72 | def __init__(self, message, http_code=HTTP_Conflict): |
| 73 | vimconnException.__init__(self, message, http_code) |
| 74 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 75 | class vimconnNotSupportedException(vimconnException): |
| 76 | """The request is not supported by connector""" |
| 77 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| 78 | vimconnException.__init__(self, message, http_code) |
| 79 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 80 | class vimconnNotImplemented(vimconnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 81 | """The method is not implemented by the connected""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 82 | def __init__(self, message, http_code=HTTP_Not_Implemented): |
| 83 | vimconnException.__init__(self, message, http_code) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 84 | |
| mirabal | 2935631 | 2017-07-27 12:21:22 +0200 | [diff] [blame] | 85 | |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 86 | class vimconnector(): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 87 | """Abstract base class for all the VIM connector plugins |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 88 | These plugins must implement a vimconnector class derived from this |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 89 | and all these privated methods |
| 90 | """ |
| 91 | def __init__(self, uuid, name, tenant_id, tenant_name, url, url_admin=None, user=None, passwd=None, log_level=None, |
| 92 | config={}, persitent_info={}): |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 93 | """Constructor of VIM |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 94 | Params: |
| 95 | 'uuid': id asigned to this VIM |
| 96 | 'name': name assigned to this VIM, can be used for logging |
| 97 | 'tenant_id', 'tenant_name': (only one of them is mandatory) VIM tenant to be used |
| 98 | 'url_admin': (optional), url used for administrative tasks |
| 99 | 'user', 'passwd': credentials of the VIM user |
| 100 | 'log_level': provider if it should use a different log_level than the general one |
| 101 | 'config': dictionary with extra VIM information. This contains a consolidate version of general VIM config |
| 102 | at creation and particular VIM config at teh attachment |
| 103 | 'persistent_info': dict where the class can store information that will be available among class |
| 104 | destroy/creation cycles. This info is unique per VIM/credential. At first call it will contain an |
| 105 | empty dict. Useful to store login/tokens information for speed up communication |
| 106 | |
| 107 | Returns: Raise an exception is some needed parameter is missing, but it must not do any connectivity |
| 108 | check against the VIM |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 109 | """ |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 110 | self.id = uuid |
| 111 | self.name = name |
| 112 | self.url = url |
| 113 | self.url_admin = url_admin |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 114 | self.tenant_id = tenant_id |
| 115 | self.tenant_name = tenant_name |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 116 | self.user = user |
| 117 | self.passwd = passwd |
| 118 | self.config = config |
| mirabal | 2935631 | 2017-07-27 12:21:22 +0200 | [diff] [blame] | 119 | self.availability_zone = None |
| tierno | 73ad9e4 | 2016-09-12 18:11:11 +0200 | [diff] [blame] | 120 | self.logger = logging.getLogger('openmano.vim') |
| tierno | fe78990 | 2016-09-29 14:20:44 +0000 | [diff] [blame] | 121 | if log_level: |
| 122 | self.logger.setLevel( getattr(logging, log_level) ) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 123 | if not self.url_admin: #try to use normal url |
| 124 | self.url_admin = self.url |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 125 | |
| 126 | def __getitem__(self,index): |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 127 | if index=='tenant_id': |
| 128 | return self.tenant_id |
| 129 | if index=='tenant_name': |
| 130 | return self.tenant_name |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 131 | elif index=='id': |
| 132 | return self.id |
| 133 | elif index=='name': |
| 134 | return self.name |
| 135 | elif index=='user': |
| 136 | return self.user |
| 137 | elif index=='passwd': |
| 138 | return self.passwd |
| 139 | elif index=='url': |
| 140 | return self.url |
| 141 | elif index=='url_admin': |
| 142 | return self.url_admin |
| 143 | elif index=="config": |
| 144 | return self.config |
| 145 | else: |
| 146 | raise KeyError("Invalid key '%s'" %str(index)) |
| 147 | |
| 148 | def __setitem__(self,index, value): |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 149 | if index=='tenant_id': |
| 150 | self.tenant_id = value |
| 151 | if index=='tenant_name': |
| 152 | self.tenant_name = value |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 153 | elif index=='id': |
| 154 | self.id = value |
| 155 | elif index=='name': |
| 156 | self.name = value |
| 157 | elif index=='user': |
| 158 | self.user = value |
| 159 | elif index=='passwd': |
| 160 | self.passwd = value |
| 161 | elif index=='url': |
| 162 | self.url = value |
| 163 | elif index=='url_admin': |
| 164 | self.url_admin = value |
| 165 | else: |
| 166 | raise KeyError("Invalid key '%s'" %str(index)) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 167 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 168 | def check_vim_connectivity(self): |
| 169 | """Checks VIM can be reached and user credentials are ok. |
| 170 | Returns None if success or raised vimconnConnectionException, vimconnAuthException, ... |
| 171 | """ |
| 172 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 173 | |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 174 | def new_tenant(self,tenant_name,tenant_description): |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 175 | """Adds a new tenant to VIM with this name and description, this is done using admin_url if provided |
| 176 | "tenant_name": string max lenght 64 |
| 177 | "tenant_description": string max length 256 |
| 178 | returns the tenant identifier or raise exception |
| 179 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 180 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 181 | |
| 182 | def delete_tenant(self,tenant_id,): |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 183 | """Delete a tenant from VIM |
| 184 | tenant_id: returned VIM tenant_id on "new_tenant" |
| 185 | Returns None on success. Raises and exception of failure. If tenant is not found raises vimconnNotFoundException |
| 186 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 187 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 188 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 189 | def get_tenant_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 190 | """Obtain tenants of VIM |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 191 | filter_dict dictionary that can contain the following keys: |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 192 | name: filter by tenant name |
| 193 | id: filter by tenant uuid/id |
| 194 | <other VIM specific> |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 195 | Returns the tenant list of dictionaries, and empty list if no tenant match all the filers: |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 196 | [{'name':'<name>, 'id':'<id>, ...}, ...] |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 197 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 198 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 199 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 200 | def new_network(self, net_name, net_type, ip_profile=None, shared=False, vlan=None): |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 201 | """Adds a tenant network to VIM |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 202 | Params: |
| 203 | 'net_name': name of the network |
| 204 | 'net_type': one of: |
| 205 | 'bridge': overlay isolated network |
| 206 | 'data': underlay E-LAN network for Passthrough and SRIOV interfaces |
| 207 | 'ptp': underlay E-LINE network for Passthrough and SRIOV interfaces. |
| 208 | 'ip_profile': is a dict containing the IP parameters of the network (Currently only IPv4 is implemented) |
| 209 | 'ip-version': can be one of ["IPv4","IPv6"] |
| 210 | 'subnet-address': ip_prefix_schema, that is X.X.X.X/Y |
| 211 | 'gateway-address': (Optional) ip_schema, that is X.X.X.X |
| 212 | 'dns-address': (Optional) ip_schema, |
| 213 | 'dhcp': (Optional) dict containing |
| 214 | 'enabled': {"type": "boolean"}, |
| 215 | 'start-address': ip_schema, first IP to grant |
| 216 | 'count': number of IPs to grant. |
| 217 | 'shared': if this network can be seen/use by other tenants/organization |
| 218 | 'vlan': in case of a data or ptp net_type, the intended vlan tag to be used for the network |
| 219 | Returns the network identifier on success or raises and exception on failure |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 220 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 221 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 222 | |
| 223 | def get_network_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 224 | """Obtain tenant networks of VIM |
| 225 | Params: |
| 226 | 'filter_dict' (optional) contains entries to return only networks that matches ALL entries: |
| 227 | name: string => returns only networks with this name |
| 228 | id: string => returns networks with this VIM id, this imply returns one network at most |
| 229 | shared: boolean >= returns only networks that are (or are not) shared |
| 230 | tenant_id: sting => returns only networks that belong to this tenant/project |
| 231 | ,#(not used yet) admin_state_up: boolean => returns only networks that are (or are not) in admin state active |
| 232 | #(not used yet) status: 'ACTIVE','ERROR',... => filter networks that are on this status |
| 233 | Returns the network list of dictionaries. each dictionary contains: |
| 234 | 'id': (mandatory) VIM network id |
| 235 | 'name': (mandatory) VIM network name |
| 236 | 'status': (mandatory) can be 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| Pablo Montes Moreno | 3fbff9b | 2017-03-08 11:28:15 +0100 | [diff] [blame] | 237 | 'network_type': (optional) can be 'vxlan', 'vlan' or 'flat' |
| 238 | 'segmentation_id': (optional) in case network_type is vlan or vxlan this field contains the segmentation id |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 239 | 'error_msg': (optional) text that explains the ERROR status |
| 240 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 241 | List can be empty if no network map the filter_dict. Raise an exception only upon VIM connectivity, |
| 242 | authorization, or some other unspecific error |
| 243 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 244 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 245 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 246 | def get_network(self, net_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 247 | """Obtain network details from the 'net_id' VIM network |
| 248 | Return a dict that contains: |
| 249 | 'id': (mandatory) VIM network id, that is, net_id |
| 250 | 'name': (mandatory) VIM network name |
| 251 | 'status': (mandatory) can be 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 252 | 'error_msg': (optional) text that explains the ERROR status |
| 253 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 254 | Raises an exception upon error or when network is not found |
| 255 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 256 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 257 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 258 | def delete_network(self, net_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 259 | """Deletes a tenant network from VIM |
| 260 | Returns the network identifier or raises an exception upon error or when network is not found |
| 261 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 262 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 263 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 264 | def refresh_nets_status(self, net_list): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 265 | """Get the status of the networks |
| 266 | Params: |
| 267 | 'net_list': a list with the VIM network id to be get the status |
| 268 | Returns a dictionary with: |
| 269 | 'net_id': #VIM id of this network |
| 270 | status: #Mandatory. Text with one of: |
| 271 | # DELETED (not found at vim) |
| 272 | # VIM_ERROR (Cannot connect to VIM, authentication problems, VIM response error, ...) |
| 273 | # OTHER (Vim reported other status not understood) |
| 274 | # ERROR (VIM indicates an ERROR status) |
| 275 | # ACTIVE, INACTIVE, DOWN (admin down), |
| 276 | # BUILD (on building process) |
| 277 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 278 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 279 | 'net_id2': ... |
| 280 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 281 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 282 | |
| 283 | def get_flavor(self, flavor_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 284 | """Obtain flavor details from the VIM |
| 285 | Returns the flavor dict details {'id':<>, 'name':<>, other vim specific } |
| 286 | Raises an exception upon error or if not found |
| 287 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 288 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 289 | |
| 290 | def get_flavor_id_from_data(self, flavor_dict): |
| 291 | """Obtain flavor id that match the flavor description |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 292 | Params: |
| 293 | 'flavor_dict': dictionary that contains: |
| 294 | 'disk': main hard disk in GB |
| 295 | 'ram': meomry in MB |
| 296 | 'vcpus': number of virtual cpus |
| 297 | #TODO: complete parameters for EPA |
| 298 | Returns the flavor_id or raises a vimconnNotFoundException |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 299 | """ |
| 300 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 301 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 302 | def new_flavor(self, flavor_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 303 | """Adds a tenant flavor to VIM |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 304 | flavor_data contains a dictionary with information, keys: |
| 305 | name: flavor name |
| 306 | ram: memory (cloud type) in MBytes |
| 307 | vpcus: cpus (cloud type) |
| 308 | extended: EPA parameters |
| 309 | - numas: #items requested in same NUMA |
| 310 | memory: number of 1G huge pages memory |
| 311 | paired-threads|cores|threads: number of paired hyperthreads, complete cores OR individual threads |
| 312 | interfaces: # passthrough(PT) or SRIOV interfaces attached to this numa |
| 313 | - name: interface name |
| 314 | dedicated: yes|no|yes:sriov; for PT, SRIOV or only one SRIOV for the physical NIC |
| 315 | bandwidth: X Gbps; requested guarantee bandwidth |
| 316 | vpci: requested virtual PCI address |
| 317 | disk: disk size |
| 318 | is_public: |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 319 | #TODO to concrete |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 320 | Returns the flavor identifier""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 321 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 322 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 323 | def delete_flavor(self, flavor_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 324 | """Deletes a tenant flavor from VIM identify by its id |
| 325 | Returns the used id or raise an exception""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 326 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 327 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 328 | def new_image(self, image_dict): |
| 329 | """ Adds a tenant image to VIM |
| 330 | Returns the image id or raises an exception if failed |
| 331 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 332 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 333 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 334 | def delete_image(self, image_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 335 | """Deletes a tenant image from VIM |
| 336 | Returns the image_id if image is deleted or raises an exception on error""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 337 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 338 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 339 | def get_image_id_from_path(self, path): |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 340 | """Get the image id from image path in the VIM database. |
| 341 | Returns the image_id or raises a vimconnNotFoundException |
| 342 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 343 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 344 | |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 345 | def get_image_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 346 | """Obtain tenant images from VIM |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 347 | Filter_dict can be: |
| 348 | name: image name |
| 349 | id: image uuid |
| 350 | checksum: image checksum |
| 351 | location: image path |
| 352 | Returns the image list of dictionaries: |
| 353 | [{<the fields at Filter_dict plus some VIM specific>}, ...] |
| 354 | List can be empty |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 355 | """ |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 356 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 357 | |
| mirabal | 2935631 | 2017-07-27 12:21:22 +0200 | [diff] [blame] | 358 | def new_vminstance(self, name, description, start, image_id, flavor_id, net_list, cloud_config=None, disk_list=None, |
| tierno | 5a3273c | 2017-08-29 11:43:46 +0200 | [diff] [blame] | 359 | availability_zone_index=None, availability_zone_list=None): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 360 | """Adds a VM instance to VIM |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 361 | Params: |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 362 | 'start': (boolean) indicates if VM must start or created in pause mode. |
| 363 | 'image_id','flavor_id': image and flavor VIM id to use for the VM |
| 364 | 'net_list': list of interfaces, each one is a dictionary with: |
| 365 | 'name': (optional) name for the interface. |
| 366 | 'net_id': VIM network id where this interface must be connect to. Mandatory for type==virtual |
| 367 | 'vpci': (optional) virtual vPCI address to assign at the VM. Can be ignored depending on VIM capabilities |
| 368 | 'model': (optional and only have sense for type==virtual) interface model: virtio, e2000, ... |
| 369 | 'mac_address': (optional) mac address to assign to this interface |
| 370 | #TODO: CHECK if an optional 'vlan' parameter is needed for VIMs when type if VF and net_id is not provided, |
| 371 | the VLAN tag to be used. In case net_id is provided, the internal network vlan is used for tagging VF |
| 372 | 'type': (mandatory) can be one of: |
| 373 | 'virtual', in this case always connected to a network of type 'net_type=bridge' |
| 374 | 'PF' (passthrough): depending on VIM capabilities it can be connected to a data/ptp network ot it |
| 375 | can created unconnected |
| 376 | 'VF' (SRIOV with VLAN tag): same as PF for network connectivity. |
| 377 | 'VFnotShared'(SRIOV without VLAN tag) same as PF for network connectivity. VF where no other VFs |
| 378 | are allocated on the same physical NIC |
| 379 | 'bw': (optional) only for PF/VF/VFnotShared. Minimal Bandwidth required for the interface in GBPS |
| tierno | b3d3674 | 2017-03-03 23:51:05 +0100 | [diff] [blame] | 380 | 'port_security': (optional) If False it must avoid any traffic filtering at this interface. If missing |
| 381 | or True, it must apply the default VIM behaviour |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 382 | After execution the method will add the key: |
| 383 | 'vim_id': must be filled/added by this method with the VIM identifier generated by the VIM for this |
| 384 | interface. 'net_list' is modified |
| 385 | 'cloud_config': (optional) dictionary with: |
| 386 | 'key-pairs': (optional) list of strings with the public key to be inserted to the default user |
| 387 | 'users': (optional) list of users to be inserted, each item is a dict with: |
| 388 | 'name': (mandatory) user name, |
| 389 | 'key-pairs': (optional) list of strings with the public key to be inserted to the user |
| tierno | 40e1bce | 2017-08-09 09:12:04 +0200 | [diff] [blame] | 390 | 'user-data': (optional) can be a string with the text script to be passed directly to cloud-init, |
| 391 | or a list of strings, each one contains a script to be passed, usually with a MIMEmultipart file |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 392 | 'config-files': (optional). List of files to be transferred. Each item is a dict with: |
| 393 | 'dest': (mandatory) string with the destination absolute path |
| 394 | 'encoding': (optional, by default text). Can be one of: |
| 395 | 'b64', 'base64', 'gz', 'gz+b64', 'gz+base64', 'gzip+b64', 'gzip+base64' |
| 396 | 'content' (mandatory): string with the content of the file |
| 397 | 'permissions': (optional) string with file permissions, typically octal notation '0644' |
| 398 | 'owner': (optional) file owner, string with the format 'owner:group' |
| 399 | 'boot-data-drive': boolean to indicate if user-data must be passed using a boot drive (hard disk) |
| 400 | 'disk_list': (optional) list with additional disks to the VM. Each item is a dict with: |
| 401 | 'image_id': (optional). VIM id of an existing image. If not provided an empty disk must be mounted |
| 402 | 'size': (mandatory) string with the size of the disk in GB |
| tierno | 5a3273c | 2017-08-29 11:43:46 +0200 | [diff] [blame] | 403 | availability_zone_index: Index of availability_zone_list to use for this this VM. None if not AV required |
| 404 | availability_zone_list: list of availability zones given by user in the VNFD descriptor. Ignore if |
| 405 | availability_zone_index is None |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 406 | Returns the instance identifier or raises an exception on error |
| 407 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 408 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 409 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 410 | def get_vminstance(self,vm_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 411 | """Returns the VM instance information from VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 412 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 413 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 414 | def delete_vminstance(self, vm_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 415 | """Removes a VM instance from VIM |
| 416 | Returns the instance identifier""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 417 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 418 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 419 | def refresh_vms_status(self, vm_list): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 420 | """Get the status of the virtual machines and their interfaces/ports |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 421 | Params: the list of VM identifiers |
| 422 | Returns a dictionary with: |
| 423 | vm_id: #VIM id of this Virtual Machine |
| 424 | status: #Mandatory. Text with one of: |
| 425 | # DELETED (not found at vim) |
| 426 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 427 | # OTHER (Vim reported other status not understood) |
| 428 | # ERROR (VIM indicates an ERROR status) |
| 429 | # ACTIVE, PAUSED, SUSPENDED, INACTIVE (not running), |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 430 | # BUILD (on building process), ERROR |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 431 | # ACTIVE:NoMgmtIP (Active but any of its interface has an IP address |
| 432 | # |
| 433 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 434 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 435 | interfaces: list with interface info. Each item a dictionary with: |
| 436 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 437 | mac_address: #Text format XX:XX:XX:XX:XX:XX |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 438 | vim_net_id: #network id where this interface is connected, if provided at creation |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 439 | vim_interface_id: #interface/port VIM id |
| 440 | ip_address: #null, or text with IPv4, IPv6 address |
| tierno | 867ffe9 | 2017-03-27 12:50:34 +0200 | [diff] [blame] | 441 | compute_node: #identification of compute node where PF,VF interface is allocated |
| 442 | pci: #PCI address of the NIC that hosts the PF,VF |
| 443 | vlan: #physical VLAN used for VF |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 444 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 445 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 446 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 447 | def action_vminstance(self, vm_id, action_dict): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 448 | """Send and action over a VM instance from VIM |
| 449 | Returns the vm_id if the action was successfully sent to the VIM""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 450 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 451 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 452 | def get_vminstance_console(self, vm_id, console_type="vnc"): |
| 453 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 454 | Get a console for the virtual machine |
| 455 | Params: |
| 456 | vm_id: uuid of the VM |
| 457 | console_type, can be: |
| 458 | "novnc" (by default), "xvpvnc" for VNC types, |
| 459 | "rdp-html5" for RDP types, "spice-html5" for SPICE types |
| 460 | Returns dict with the console parameters: |
| 461 | protocol: ssh, ftp, http, https, ... |
| 462 | server: usually ip address |
| 463 | port: the http, ssh, ... port |
| 464 | suffix: extra text, e.g. the http path and query string |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 465 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 466 | raise vimconnNotImplemented( "Should have implemented this" ) |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 467 | |
| 468 | def new_classification(self, name, ctype, definition): |
| 469 | """Creates a traffic classification in the VIM |
| 470 | Params: |
| 471 | 'name': name of this classification |
| 472 | 'ctype': type of this classification |
| 473 | 'definition': definition of this classification (type-dependent free-form text) |
| 474 | Returns the VIM's classification ID on success or raises an exception on failure |
| 475 | """ |
| 476 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 477 | |
| 478 | def get_classification(self, classification_id): |
| 479 | """Obtain classification details of the VIM's classification with ID='classification_id' |
| 480 | Return a dict that contains: |
| 481 | 'id': VIM's classification ID (same as classification_id) |
| 482 | 'name': VIM's classification name |
| 483 | 'type': type of this classification |
| 484 | 'definition': definition of the classification |
| 485 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 486 | 'error_msg': (optional) text that explains the ERROR status |
| 487 | other VIM specific fields: (optional) whenever possible |
| 488 | Raises an exception upon error or when classification is not found |
| 489 | """ |
| 490 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 491 | |
| 492 | def get_classification_list(self, filter_dict={}): |
| 493 | """Obtain classifications from the VIM |
| 494 | Params: |
| 495 | 'filter_dict' (optional): contains the entries to filter the classifications on and only return those that match ALL: |
| 496 | id: string => returns classifications with this VIM's classification ID, which implies a return of one classification at most |
| 497 | name: string => returns only classifications with this name |
| 498 | type: string => returns classifications of this type |
| 499 | definition: string => returns classifications that have this definition |
| 500 | tenant_id: string => returns only classifications that belong to this tenant/project |
| 501 | Returns a list of classification dictionaries, each dictionary contains: |
| 502 | 'id': (mandatory) VIM's classification ID |
| 503 | 'name': (mandatory) VIM's classification name |
| 504 | 'type': type of this classification |
| 505 | 'definition': definition of the classification |
| 506 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 507 | List can be empty if no classification matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 508 | authorization, or some other unspecific error |
| 509 | """ |
| 510 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 511 | |
| 512 | def delete_classification(self, classification_id): |
| 513 | """Deletes a classification from the VIM |
| 514 | Returns the classification ID (classification_id) or raises an exception upon error or when classification is not found |
| 515 | """ |
| 516 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 517 | |
| 518 | def new_sfi(self, name, ingress_ports, egress_ports, sfc_encap=True): |
| 519 | """Creates a service function instance in the VIM |
| 520 | Params: |
| 521 | 'name': name of this service function instance |
| 522 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 523 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 524 | 'sfc_encap': boolean stating whether this specific instance supports IETF SFC Encapsulation |
| 525 | Returns the VIM's service function instance ID on success or raises an exception on failure |
| 526 | """ |
| 527 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 528 | |
| 529 | def get_sfi(self, sfi_id): |
| 530 | """Obtain service function instance details of the VIM's service function instance with ID='sfi_id' |
| 531 | Return a dict that contains: |
| 532 | 'id': VIM's sfi ID (same as sfi_id) |
| 533 | 'name': VIM's sfi name |
| 534 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 535 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 536 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 537 | 'error_msg': (optional) text that explains the ERROR status |
| 538 | other VIM specific fields: (optional) whenever possible |
| 539 | Raises an exception upon error or when service function instance is not found |
| 540 | """ |
| 541 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 542 | |
| 543 | def get_sfi_list(self, filter_dict={}): |
| 544 | """Obtain service function instances from the VIM |
| 545 | Params: |
| 546 | 'filter_dict' (optional): contains the entries to filter the sfis on and only return those that match ALL: |
| 547 | id: string => returns sfis with this VIM's sfi ID, which implies a return of one sfi at most |
| 548 | name: string => returns only service function instances with this name |
| 549 | tenant_id: string => returns only service function instances that belong to this tenant/project |
| 550 | Returns a list of service function instance dictionaries, each dictionary contains: |
| 551 | 'id': (mandatory) VIM's sfi ID |
| 552 | 'name': (mandatory) VIM's sfi name |
| 553 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 554 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 555 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 556 | List can be empty if no sfi matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 557 | authorization, or some other unspecific error |
| 558 | """ |
| 559 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 560 | |
| 561 | def delete_sfi(self, sfi_id): |
| 562 | """Deletes a service function instance from the VIM |
| 563 | Returns the service function instance ID (sfi_id) or raises an exception upon error or when sfi is not found |
| 564 | """ |
| 565 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 566 | |
| 567 | def new_sf(self, name, sfis, sfc_encap=True): |
| 568 | """Creates (an abstract) service function in the VIM |
| 569 | Params: |
| 570 | 'name': name of this service function |
| 571 | 'sfis': set of service function instances of this (abstract) service function |
| 572 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 573 | Returns the VIM's service function ID on success or raises an exception on failure |
| 574 | """ |
| 575 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 576 | |
| 577 | def get_sf(self, sf_id): |
| 578 | """Obtain service function details of the VIM's service function with ID='sf_id' |
| 579 | Return a dict that contains: |
| 580 | 'id': VIM's sf ID (same as sf_id) |
| 581 | 'name': VIM's sf name |
| 582 | 'sfis': VIM's sf's set of VIM's service function instance IDs |
| 583 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 584 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 585 | 'error_msg': (optional) text that explains the ERROR status |
| 586 | other VIM specific fields: (optional) whenever possible |
| 587 | Raises an exception upon error or when sf is not found |
| 588 | """ |
| 589 | |
| 590 | def get_sf_list(self, filter_dict={}): |
| 591 | """Obtain service functions from the VIM |
| 592 | Params: |
| 593 | 'filter_dict' (optional): contains the entries to filter the sfs on and only return those that match ALL: |
| 594 | id: string => returns sfs with this VIM's sf ID, which implies a return of one sf at most |
| 595 | name: string => returns only service functions with this name |
| 596 | tenant_id: string => returns only service functions that belong to this tenant/project |
| 597 | Returns a list of service function dictionaries, each dictionary contains: |
| 598 | 'id': (mandatory) VIM's sf ID |
| 599 | 'name': (mandatory) VIM's sf name |
| 600 | 'sfis': VIM's sf's set of VIM's service function instance IDs |
| 601 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 602 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 603 | List can be empty if no sf matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 604 | authorization, or some other unspecific error |
| 605 | """ |
| 606 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 607 | |
| 608 | def delete_sf(self, sf_id): |
| 609 | """Deletes (an abstract) service function from the VIM |
| 610 | Returns the service function ID (sf_id) or raises an exception upon error or when sf is not found |
| 611 | """ |
| 612 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 613 | |
| 614 | |
| 615 | def new_sfp(self, name, classifications, sfs, sfc_encap=True, spi=None): |
| 616 | """Creates a service function path |
| 617 | Params: |
| 618 | 'name': name of this service function path |
| 619 | 'classifications': set of traffic classifications that should be matched on to get into this sfp |
| 620 | 'sfs': list of every service function that constitutes this path , from first to last |
| 621 | 'sfc_encap': whether this is an SFC-Encapsulated chain (i.e using NSH), True by default |
| 622 | 'spi': (optional) the Service Function Path identifier (SPI: Service Path Identifier) for this path |
| 623 | Returns the VIM's sfp ID on success or raises an exception on failure |
| 624 | """ |
| 625 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 626 | |
| 627 | def get_sfp(self, sfp_id): |
| 628 | """Obtain service function path details of the VIM's sfp with ID='sfp_id' |
| 629 | Return a dict that contains: |
| 630 | 'id': VIM's sfp ID (same as sfp_id) |
| 631 | 'name': VIM's sfp name |
| 632 | 'classifications': VIM's sfp's list of VIM's classification IDs |
| 633 | 'sfs': VIM's sfp's list of VIM's service function IDs |
| 634 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 635 | 'error_msg': (optional) text that explains the ERROR status |
| 636 | other VIM specific fields: (optional) whenever possible |
| 637 | Raises an exception upon error or when sfp is not found |
| 638 | """ |
| 639 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 640 | |
| 641 | def get_sfp_list(self, filter_dict={}): |
| 642 | """Obtain service function paths from VIM |
| 643 | Params: |
| 644 | 'filter_dict' (optional): contains the entries to filter the sfps on, and only return those that match ALL: |
| 645 | id: string => returns sfps with this VIM's sfp ID , which implies a return of one sfp at most |
| 646 | name: string => returns only sfps with this name |
| 647 | tenant_id: string => returns only sfps that belong to this tenant/project |
| 648 | Returns a list of service function path dictionaries, each dictionary contains: |
| 649 | 'id': (mandatory) VIM's sfp ID |
| 650 | 'name': (mandatory) VIM's sfp name |
| 651 | 'classifications': VIM's sfp's list of VIM's classification IDs |
| 652 | 'sfs': VIM's sfp's list of VIM's service function IDs |
| 653 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 654 | List can be empty if no sfp matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 655 | authorization, or some other unspecific error |
| 656 | """ |
| 657 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 658 | |
| 659 | def delete_sfp(self, sfp_id): |
| 660 | """Deletes a service function path from the VIM |
| 661 | Returns the sfp ID (sfp_id) or raises an exception upon error or when sf is not found |
| 662 | """ |
| 663 | raise vimconnNotImplemented( "SFC support not implemented" ) |
| 664 | |
| 665 | #NOT USED METHODS in current version |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 666 | |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 667 | def host_vim2gui(self, host, server_dict): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 668 | """Transform host dictionary from VIM format to GUI format, |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 669 | and append to the server_dict |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 670 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 671 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 672 | |
| 673 | def get_hosts_info(self): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 674 | """Get the information of deployed hosts |
| 675 | Returns the hosts content""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 676 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 677 | |
| 678 | def get_hosts(self, vim_tenant): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 679 | """Get the hosts and deployed instances |
| 680 | Returns the hosts content""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 681 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 682 | |
| 683 | def get_processor_rankings(self): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 684 | """Get the processor rankings in the VIM database""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 685 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 686 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 687 | def new_host(self, host_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 688 | """Adds a new host to VIM""" |
| 689 | """Returns status code of the VIM response""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 690 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 691 | |
| 692 | def new_external_port(self, port_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 693 | """Adds a external port to VIM""" |
| 694 | """Returns the port identifier""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 695 | raise vimconnNotImplemented( "Should have implemented this" ) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 696 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 697 | def new_external_network(self,net_name,net_type): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 698 | """Adds a external network to VIM (shared)""" |
| 699 | """Returns the network identifier""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 700 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 701 | |
| 702 | def connect_port_network(self, port_id, network_id, admin=False): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 703 | """Connects a external port to a network""" |
| 704 | """Returns status code of the VIM response""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 705 | raise vimconnNotImplemented( "Should have implemented this" ) |
| 706 | |
| 707 | def new_vminstancefromJSON(self, vm_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 708 | """Adds a VM instance to VIM""" |
| 709 | """Returns the instance identifier""" |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 710 | raise vimconnNotImplemented( "Should have implemented this" ) |