| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1 | # -*- coding: utf-8 -*- |
| 2 | |
| 3 | ## |
| tierno | 9202102 | 2018-09-12 16:29:23 +0200 | [diff] [blame] | 4 | # Copyright 2015 Telefonica Investigacion y Desarrollo, S.A.U. |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 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 | """ |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 28 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 29 | from email.mime.multipart import MIMEMultipart |
| 30 | from email.mime.text import MIMEText |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 31 | from http import HTTPStatus |
| sousaedu | 049cbb1 | 2022-01-05 11:39:35 +0000 | [diff] [blame] | 32 | from io import StringIO |
| 33 | import logging |
| 34 | import socket |
| 35 | import sys |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 36 | import warnings |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 37 | |
| sousaedu | 049cbb1 | 2022-01-05 11:39:35 +0000 | [diff] [blame] | 38 | import paramiko |
| 39 | import yaml |
| 40 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 41 | __author__ = "Alfonso Tierno, Igor D.C." |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 42 | __date__ = "$14-aug-2017 23:59:59$" |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 43 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 44 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 45 | def deprecated(message): |
| 46 | def deprecated_decorator(func): |
| 47 | def deprecated_func(*args, **kwargs): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 48 | warnings.warn( |
| 49 | "{} is a deprecated function. {}".format(func.__name__, message), |
| 50 | category=DeprecationWarning, |
| 51 | stacklevel=2, |
| 52 | ) |
| 53 | warnings.simplefilter("default", DeprecationWarning) |
| 54 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 55 | return func(*args, **kwargs) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 56 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 57 | return deprecated_func |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 58 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 59 | return deprecated_decorator |
| 60 | |
| 61 | |
| 62 | # Error variables |
| 63 | HTTP_Bad_Request = HTTPStatus.BAD_REQUEST.value |
| 64 | HTTP_Unauthorized = HTTPStatus.UNAUTHORIZED.value |
| 65 | HTTP_Not_Found = HTTPStatus.NOT_FOUND.value |
| 66 | HTTP_Method_Not_Allowed = HTTPStatus.METHOD_NOT_ALLOWED.value |
| 67 | HTTP_Request_Timeout = HTTPStatus.REQUEST_TIMEOUT.value |
| 68 | HTTP_Conflict = HTTPStatus.CONFLICT.value |
| 69 | HTTP_Not_Implemented = HTTPStatus.NOT_IMPLEMENTED.value |
| 70 | HTTP_Service_Unavailable = HTTPStatus.SERVICE_UNAVAILABLE.value |
| 71 | HTTP_Internal_Server_Error = HTTPStatus.INTERNAL_SERVER_ERROR.value |
| 72 | |
| 73 | |
| 74 | class VimConnException(Exception): |
| 75 | """Common and base class Exception for all VimConnector exceptions""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 76 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 77 | def __init__(self, message, http_code=HTTP_Bad_Request): |
| 78 | Exception.__init__(self, message) |
| 79 | self.http_code = http_code |
| 80 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 81 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 82 | class VimConnConnectionException(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 83 | """Connectivity error with the VIM""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 84 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 85 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 86 | VimConnException.__init__(self, message, http_code) |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 87 | |
| 88 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 89 | class VimConnUnexpectedResponse(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 90 | """Get an wrong response from VIM""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 91 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 92 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 93 | VimConnException.__init__(self, message, http_code) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 94 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 95 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 96 | class VimConnAuthException(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 97 | """Invalid credentials or authorization to perform this action over the VIM""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 98 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 99 | def __init__(self, message, http_code=HTTP_Unauthorized): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 100 | VimConnException.__init__(self, message, http_code) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 101 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 102 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 103 | class VimConnNotFoundException(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 104 | """The item is not found at VIM""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 105 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 106 | def __init__(self, message, http_code=HTTP_Not_Found): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 107 | VimConnException.__init__(self, message, http_code) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 108 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 109 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 110 | class VimConnConflictException(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 111 | """There is a conflict, e.g. more item found than one""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 112 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 113 | def __init__(self, message, http_code=HTTP_Conflict): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 114 | VimConnException.__init__(self, message, http_code) |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 115 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 116 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 117 | class VimConnNotSupportedException(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 118 | """The request is not supported by connector""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 119 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 120 | def __init__(self, message, http_code=HTTP_Service_Unavailable): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 121 | VimConnException.__init__(self, message, http_code) |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 122 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 123 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 124 | class VimConnNotImplemented(VimConnException): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 125 | """The method is not implemented by the connected""" |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 126 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 127 | def __init__(self, message, http_code=HTTP_Not_Implemented): |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 128 | VimConnException.__init__(self, message, http_code) |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 129 | |
| mirabal | 2935631 | 2017-07-27 12:21:22 +0200 | [diff] [blame] | 130 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 131 | class VimConnector: |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 132 | """Abstract base class for all the VIM connector plugins |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 133 | These plugins must implement a VimConnector class derived from this |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 134 | and all these privated methods |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 135 | """ |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 136 | |
| 137 | def __init__( |
| 138 | self, |
| 139 | uuid, |
| 140 | name, |
| 141 | tenant_id, |
| 142 | tenant_name, |
| 143 | url, |
| 144 | url_admin=None, |
| 145 | user=None, |
| 146 | passwd=None, |
| 147 | log_level=None, |
| 148 | config={}, |
| 149 | persistent_info={}, |
| 150 | ): |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 151 | """ |
| 152 | Constructor of VIM. Raise an exception is some needed parameter is missing, but it must not do any connectivity |
| 153 | checking against the VIM |
| 154 | :param uuid: internal id of this VIM |
| 155 | :param name: name assigned to this VIM, can be used for logging |
| 156 | :param tenant_id: 'tenant_id': (only one of them is mandatory) VIM tenant to be used |
| 157 | :param tenant_name: 'tenant_name': (only one of them is mandatory) VIM tenant to be used |
| 158 | :param url: url used for normal operations |
| 159 | :param url_admin: (optional), url used for administrative tasks |
| 160 | :param user: user to access |
| 161 | :param passwd: password |
| 162 | :param log_level: provided if it should use a different log_level than the general one |
| 163 | :param config: dictionary with extra VIM information. This contains a consolidate version of VIM config |
| 164 | at VIM_ACCOUNT (attach) |
| 165 | :param persitent_info: dict where the class can store information that will be available among class |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 166 | destroy/creation cycles. This info is unique per VIM/credential. At first call it will contain an |
| 167 | empty dict. Useful to store login/tokens information for speed up communication |
| 168 | |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 169 | """ |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 170 | self.id = uuid |
| 171 | self.name = name |
| 172 | self.url = url |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 173 | self.url_admin = url_admin |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 174 | self.tenant_id = tenant_id |
| 175 | self.tenant_name = tenant_name |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 176 | self.user = user |
| 177 | self.passwd = passwd |
| 178 | self.config = config or {} |
| mirabal | 2935631 | 2017-07-27 12:21:22 +0200 | [diff] [blame] | 179 | self.availability_zone = None |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 180 | self.logger = logging.getLogger("ro.vim") |
| 181 | |
| tierno | fe78990 | 2016-09-29 14:20:44 +0000 | [diff] [blame] | 182 | if log_level: |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 183 | self.logger.setLevel(getattr(logging, log_level)) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 184 | |
| 185 | if not self.url_admin: # try to use normal url |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 186 | self.url_admin = self.url |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 187 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 188 | def __getitem__(self, index): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 189 | if index == "tenant_id": |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 190 | return self.tenant_id |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 191 | |
| 192 | if index == "tenant_name": |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 193 | return self.tenant_name |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 194 | elif index == "id": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 195 | return self.id |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 196 | elif index == "name": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 197 | return self.name |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 198 | elif index == "user": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 199 | return self.user |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 200 | elif index == "passwd": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 201 | return self.passwd |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 202 | elif index == "url": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 203 | return self.url |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 204 | elif index == "url_admin": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 205 | return self.url_admin |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 206 | elif index == "config": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 207 | return self.config |
| 208 | else: |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 209 | raise KeyError("Invalid key '{}'".format(index)) |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 210 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 211 | def __setitem__(self, index, value): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 212 | if index == "tenant_id": |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 213 | self.tenant_id = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 214 | |
| 215 | if index == "tenant_name": |
| tierno | 392f285 | 2016-05-13 12:28:55 +0200 | [diff] [blame] | 216 | self.tenant_name = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 217 | elif index == "id": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 218 | self.id = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 219 | elif index == "name": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 220 | self.name = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 221 | elif index == "user": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 222 | self.user = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 223 | elif index == "passwd": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 224 | self.passwd = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 225 | elif index == "url": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 226 | self.url = value |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 227 | elif index == "url_admin": |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 228 | self.url_admin = value |
| 229 | else: |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 230 | raise KeyError("Invalid key '{}'".format(index)) |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 231 | |
| 232 | @staticmethod |
| 233 | def _create_mimemultipart(content_list): |
| 234 | """Creates a MIMEmultipart text combining the content_list |
| 235 | :param content_list: list of text scripts to be combined |
| 236 | :return: str of the created MIMEmultipart. If the list is empty returns None, if the list contains only one |
| 237 | element MIMEmultipart is not created and this content is returned |
| 238 | """ |
| 239 | if not content_list: |
| 240 | return None |
| 241 | elif len(content_list) == 1: |
| 242 | return content_list[0] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 243 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 244 | combined_message = MIMEMultipart() |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 245 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 246 | for content in content_list: |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 247 | if content.startswith("#include"): |
| 248 | mime_format = "text/x-include-url" |
| 249 | elif content.startswith("#include-once"): |
| 250 | mime_format = "text/x-include-once-url" |
| 251 | elif content.startswith("#!"): |
| 252 | mime_format = "text/x-shellscript" |
| 253 | elif content.startswith("#cloud-config"): |
| 254 | mime_format = "text/cloud-config" |
| 255 | elif content.startswith("#cloud-config-archive"): |
| 256 | mime_format = "text/cloud-config-archive" |
| 257 | elif content.startswith("#upstart-job"): |
| 258 | mime_format = "text/upstart-job" |
| 259 | elif content.startswith("#part-handler"): |
| 260 | mime_format = "text/part-handler" |
| 261 | elif content.startswith("#cloud-boothook"): |
| 262 | mime_format = "text/cloud-boothook" |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 263 | else: # by default |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 264 | mime_format = "text/x-shellscript" |
| 265 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 266 | sub_message = MIMEText(content, mime_format, sys.getdefaultencoding()) |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 267 | combined_message.attach(sub_message) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 268 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 269 | return combined_message.as_string() |
| 270 | |
| 271 | def _create_user_data(self, cloud_config): |
| 272 | """ |
| 273 | Creates a script user database on cloud_config info |
| 274 | :param cloud_config: dictionary with |
| 275 | 'key-pairs': (optional) list of strings with the public key to be inserted to the default user |
| 276 | 'users': (optional) list of users to be inserted, each item is a dict with: |
| 277 | 'name': (mandatory) user name, |
| 278 | 'key-pairs': (optional) list of strings with the public key to be inserted to the user |
| 279 | 'user-data': (optional) can be a string with the text script to be passed directly to cloud-init, |
| 280 | or a list of strings, each one contains a script to be passed, usually with a MIMEmultipart file |
| 281 | 'config-files': (optional). List of files to be transferred. Each item is a dict with: |
| 282 | 'dest': (mandatory) string with the destination absolute path |
| 283 | 'encoding': (optional, by default text). Can be one of: |
| 284 | 'b64', 'base64', 'gz', 'gz+b64', 'gz+base64', 'gzip+b64', 'gzip+base64' |
| 285 | 'content' (mandatory): string with the content of the file |
| 286 | 'permissions': (optional) string with file permissions, typically octal notation '0644' |
| 287 | 'owner': (optional) file owner, string with the format 'owner:group' |
| 288 | 'boot-data-drive': boolean to indicate if user-data must be passed using a boot drive (hard disk) |
| 289 | :return: config_drive, userdata. The first is a boolean or None, the second a string or None |
| 290 | """ |
| 291 | config_drive = None |
| 292 | userdata = None |
| 293 | userdata_list = [] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 294 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 295 | if isinstance(cloud_config, dict): |
| 296 | if cloud_config.get("user-data"): |
| 297 | if isinstance(cloud_config["user-data"], str): |
| 298 | userdata_list.append(cloud_config["user-data"]) |
| 299 | else: |
| 300 | for u in cloud_config["user-data"]: |
| 301 | userdata_list.append(u) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 302 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 303 | if cloud_config.get("boot-data-drive") is not None: |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 304 | config_drive = cloud_config["boot-data-drive"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 305 | |
| 306 | if ( |
| 307 | cloud_config.get("config-files") |
| 308 | or cloud_config.get("users") |
| 309 | or cloud_config.get("key-pairs") |
| 310 | ): |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 311 | userdata_dict = {} |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 312 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 313 | # default user |
| 314 | if cloud_config.get("key-pairs"): |
| 315 | userdata_dict["ssh-authorized-keys"] = cloud_config["key-pairs"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 316 | userdata_dict["users"] = [ |
| 317 | { |
| 318 | "default": None, |
| 319 | "ssh-authorized-keys": cloud_config["key-pairs"], |
| 320 | } |
| 321 | ] |
| 322 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 323 | if cloud_config.get("users"): |
| 324 | if "users" not in userdata_dict: |
| 325 | userdata_dict["users"] = ["default"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 326 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 327 | for user in cloud_config["users"]: |
| 328 | user_info = { |
| 329 | "name": user["name"], |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 330 | "sudo": "ALL = (ALL)NOPASSWD:ALL", |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 331 | } |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 332 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 333 | if "user-info" in user: |
| 334 | user_info["gecos"] = user["user-info"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 335 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 336 | if user.get("key-pairs"): |
| 337 | user_info["ssh-authorized-keys"] = user["key-pairs"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 338 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 339 | userdata_dict["users"].append(user_info) |
| 340 | |
| 341 | if cloud_config.get("config-files"): |
| 342 | userdata_dict["write_files"] = [] |
| 343 | for file in cloud_config["config-files"]: |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 344 | file_info = {"path": file["dest"], "content": file["content"]} |
| 345 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 346 | if file.get("encoding"): |
| 347 | file_info["encoding"] = file["encoding"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 348 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 349 | if file.get("permissions"): |
| 350 | file_info["permissions"] = file["permissions"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 351 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 352 | if file.get("owner"): |
| 353 | file_info["owner"] = file["owner"] |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 354 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 355 | userdata_dict["write_files"].append(file_info) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 356 | |
| 357 | userdata_list.append( |
| 358 | "#cloud-config\n" |
| 359 | + yaml.safe_dump(userdata_dict, indent=4, default_flow_style=False) |
| 360 | ) |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 361 | userdata = self._create_mimemultipart(userdata_list) |
| 362 | self.logger.debug("userdata: %s", userdata) |
| 363 | elif isinstance(cloud_config, str): |
| 364 | userdata = cloud_config |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 365 | |
| tierno | 0a1437e | 2017-10-02 00:17:43 +0200 | [diff] [blame] | 366 | return config_drive, userdata |
| 367 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 368 | def check_vim_connectivity(self): |
| 369 | """Checks VIM can be reached and user credentials are ok. |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 370 | Returns None if success or raises VimConnConnectionException, VimConnAuthException, ... |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 371 | """ |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 372 | # by default no checking until each connector implements it |
| 373 | return None |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 374 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 375 | def get_tenant_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 376 | """Obtain tenants of VIM |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 377 | filter_dict dictionary that can contain the following keys: |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 378 | name: filter by tenant name |
| 379 | id: filter by tenant uuid/id |
| 380 | <other VIM specific> |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 381 | 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] | 382 | [{'name':'<name>, 'id':'<id>, ...}, ...] |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 383 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 384 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 385 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 386 | def new_network( |
| 387 | self, |
| 388 | net_name, |
| 389 | net_type, |
| 390 | ip_profile=None, |
| 391 | shared=False, |
| 392 | provider_network_profile=None, |
| 393 | ): |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 394 | """Adds a tenant network to VIM |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 395 | Params: |
| 396 | 'net_name': name of the network |
| 397 | 'net_type': one of: |
| 398 | 'bridge': overlay isolated network |
| 399 | 'data': underlay E-LAN network for Passthrough and SRIOV interfaces |
| 400 | 'ptp': underlay E-LINE network for Passthrough and SRIOV interfaces. |
| tierno | 41a6981 | 2018-02-16 14:34:33 +0100 | [diff] [blame] | 401 | 'ip_profile': is a dict containing the IP parameters of the network |
| 402 | 'ip_version': can be "IPv4" or "IPv6" (Currently only IPv4 is implemented) |
| 403 | 'subnet_address': ip_prefix_schema, that is X.X.X.X/Y |
| 404 | 'gateway_address': (Optional) ip_schema, that is X.X.X.X |
| 405 | 'dns_address': (Optional) comma separated list of ip_schema, e.g. X.X.X.X[,X,X,X,X] |
| 406 | 'dhcp_enabled': True or False |
| 407 | 'dhcp_start_address': ip_schema, first IP to grant |
| 408 | 'dhcp_count': number of IPs to grant. |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 409 | 'shared': if this network can be seen/use by other tenants/organization |
| kbsub | a85c54d | 2019-10-17 16:30:32 +0000 | [diff] [blame] | 410 | 'provider_network_profile': (optional) contains {segmentation-id: vlan, provider-network: vim_netowrk} |
| garciadeblas | ebd6672 | 2019-01-31 16:01:31 +0000 | [diff] [blame] | 411 | Returns a tuple with the network identifier and created_items, or raises an exception on error |
| 412 | created_items can be None or a dictionary where this method can include key-values that will be passed to |
| 413 | the method delete_network. Can be used to store created segments, created l2gw connections, etc. |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 414 | Format is VimConnector dependent, but do not use nested dictionaries and a value of None should be the same |
| garciadeblas | ebd6672 | 2019-01-31 16:01:31 +0000 | [diff] [blame] | 415 | as not present. |
| tierno | fb1987b | 2016-11-15 17:35:06 +0000 | [diff] [blame] | 416 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 417 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 418 | |
| 419 | def get_network_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 420 | """Obtain tenant networks of VIM |
| 421 | Params: |
| 422 | 'filter_dict' (optional) contains entries to return only networks that matches ALL entries: |
| 423 | name: string => returns only networks with this name |
| 424 | id: string => returns networks with this VIM id, this imply returns one network at most |
| 425 | shared: boolean >= returns only networks that are (or are not) shared |
| 426 | tenant_id: sting => returns only networks that belong to this tenant/project |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 427 | ,#(not used yet) admin_state_up: boolean => returns only networks that are (or are not) in admin state |
| 428 | active |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 429 | #(not used yet) status: 'ACTIVE','ERROR',... => filter networks that are on this status |
| 430 | Returns the network list of dictionaries. each dictionary contains: |
| 431 | 'id': (mandatory) VIM network id |
| 432 | 'name': (mandatory) VIM network name |
| 433 | '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] | 434 | 'network_type': (optional) can be 'vxlan', 'vlan' or 'flat' |
| 435 | '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] | 436 | 'error_msg': (optional) text that explains the ERROR status |
| 437 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 438 | List can be empty if no network map the filter_dict. Raise an exception only upon VIM connectivity, |
| 439 | authorization, or some other unspecific error |
| 440 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 441 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 442 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 443 | def get_network(self, net_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 444 | """Obtain network details from the 'net_id' VIM network |
| 445 | Return a dict that contains: |
| 446 | 'id': (mandatory) VIM network id, that is, net_id |
| 447 | 'name': (mandatory) VIM network name |
| 448 | 'status': (mandatory) can be 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 449 | 'error_msg': (optional) text that explains the ERROR status |
| 450 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 451 | Raises an exception upon error or when network is not found |
| 452 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 453 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 454 | |
| garciadeblas | ebd6672 | 2019-01-31 16:01:31 +0000 | [diff] [blame] | 455 | def delete_network(self, net_id, created_items=None): |
| 456 | """ |
| 457 | Removes a tenant network from VIM and its associated elements |
| 458 | :param net_id: VIM identifier of the network, provided by method new_network |
| 459 | :param created_items: dictionary with extra items to be deleted. provided by method new_network |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 460 | Returns the network identifier or raises an exception upon error or when network is not found |
| 461 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 462 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 463 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 464 | def refresh_nets_status(self, net_list): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 465 | """Get the status of the networks |
| 466 | Params: |
| 467 | 'net_list': a list with the VIM network id to be get the status |
| 468 | Returns a dictionary with: |
| 469 | 'net_id': #VIM id of this network |
| 470 | status: #Mandatory. Text with one of: |
| 471 | # DELETED (not found at vim) |
| 472 | # VIM_ERROR (Cannot connect to VIM, authentication problems, VIM response error, ...) |
| 473 | # OTHER (Vim reported other status not understood) |
| 474 | # ERROR (VIM indicates an ERROR status) |
| 475 | # ACTIVE, INACTIVE, DOWN (admin down), |
| 476 | # BUILD (on building process) |
| 477 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 478 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 479 | 'net_id2': ... |
| 480 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 481 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 482 | |
| 483 | def get_flavor(self, flavor_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 484 | """Obtain flavor details from the VIM |
| 485 | Returns the flavor dict details {'id':<>, 'name':<>, other vim specific } |
| 486 | Raises an exception upon error or if not found |
| 487 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 488 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 489 | |
| 490 | def get_flavor_id_from_data(self, flavor_dict): |
| 491 | """Obtain flavor id that match the flavor description |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 492 | Params: |
| 493 | 'flavor_dict': dictionary that contains: |
| 494 | 'disk': main hard disk in GB |
| 495 | 'ram': meomry in MB |
| 496 | 'vcpus': number of virtual cpus |
| 497 | #TODO: complete parameters for EPA |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 498 | Returns the flavor_id or raises a VimConnNotFoundException |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 499 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 500 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 501 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 502 | def new_flavor(self, flavor_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 503 | """Adds a tenant flavor to VIM |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 504 | flavor_data contains a dictionary with information, keys: |
| 505 | name: flavor name |
| 506 | ram: memory (cloud type) in MBytes |
| 507 | vpcus: cpus (cloud type) |
| 508 | extended: EPA parameters |
| 509 | - numas: #items requested in same NUMA |
| 510 | memory: number of 1G huge pages memory |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 511 | paired-threads|cores|threads: number of paired hyperthreads, complete cores OR individual |
| 512 | threads |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 513 | interfaces: # passthrough(PT) or SRIOV interfaces attached to this numa |
| 514 | - name: interface name |
| 515 | dedicated: yes|no|yes:sriov; for PT, SRIOV or only one SRIOV for the physical NIC |
| 516 | bandwidth: X Gbps; requested guarantee bandwidth |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 517 | vpci: requested virtual PCI address |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 518 | disk: disk size |
| 519 | is_public: |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 520 | #TODO to concrete |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 521 | Returns the flavor identifier |
| 522 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 523 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 524 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 525 | def delete_flavor(self, flavor_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 526 | """Deletes a tenant flavor from VIM identify by its id |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 527 | Returns the used id or raise an exception |
| 528 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 529 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 530 | |
| Alexis Romero | b70f4ed | 2022-03-11 18:00:49 +0100 | [diff] [blame] | 531 | def get_affinity_group(self, affinity_group_id): |
| 532 | """Obtain affinity or anti affinity group details from the VIM |
| 533 | Returns the flavor dict details {'id':<>, 'name':<>, other vim specific } |
| 534 | Raises an exception upon error or if not found |
| 535 | """ |
| 536 | raise VimConnNotImplemented("Should have implemented this") |
| 537 | |
| 538 | def new_affinity_group(self, affinity_group_data): |
| 539 | """Adds an affinity or anti affinity group to VIM |
| 540 | affinity_group_data contains a dictionary with information, keys: |
| 541 | name: name in VIM for the affinity or anti-affinity group |
| 542 | type: affinity or anti-affinity |
| 543 | scope: Only nfvi-node allowed |
| 544 | Returns the affinity or anti affinity group identifier |
| 545 | """ |
| 546 | raise VimConnNotImplemented("Should have implemented this") |
| 547 | |
| 548 | def delete_affinity_group(self, affinity_group_id): |
| 549 | """Deletes an affinity or anti affinity group from the VIM identified by its id |
| 550 | Returns the used id or raise an exception |
| 551 | """ |
| 552 | raise VimConnNotImplemented("Should have implemented this") |
| 553 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 554 | def new_image(self, image_dict): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 555 | """Adds a tenant image to VIM |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 556 | Returns the image id or raises an exception if failed |
| 557 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 558 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 559 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 560 | def delete_image(self, image_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 561 | """Deletes a tenant image from VIM |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 562 | Returns the image_id if image is deleted or raises an exception on error |
| 563 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 564 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 565 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 566 | def get_image_id_from_path(self, path): |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 567 | """Get the image id from image path in the VIM database. |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 568 | Returns the image_id or raises a VimConnNotFoundException |
| tierno | cf157a8 | 2017-01-30 14:07:06 +0100 | [diff] [blame] | 569 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 570 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 571 | |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 572 | def get_image_list(self, filter_dict={}): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 573 | """Obtain tenant images from VIM |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 574 | Filter_dict can be: |
| 575 | name: image name |
| 576 | id: image uuid |
| 577 | checksum: image checksum |
| 578 | location: image path |
| 579 | Returns the image list of dictionaries: |
| 580 | [{<the fields at Filter_dict plus some VIM specific>}, ...] |
| 581 | List can be empty |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 582 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 583 | raise VimConnNotImplemented("Should have implemented this") |
| garciadeblas | b69fa9f | 2016-09-28 12:04:10 +0200 | [diff] [blame] | 584 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 585 | def new_vminstance( |
| 586 | self, |
| 587 | name, |
| 588 | description, |
| 589 | start, |
| 590 | image_id, |
| 591 | flavor_id, |
| Alexis Romero | b70f4ed | 2022-03-11 18:00:49 +0100 | [diff] [blame] | 592 | affinity_group_list, |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 593 | net_list, |
| 594 | cloud_config=None, |
| 595 | disk_list=None, |
| 596 | availability_zone_index=None, |
| 597 | availability_zone_list=None, |
| 598 | ): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 599 | """Adds a VM instance to VIM |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 600 | Params: |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 601 | 'start': (boolean) indicates if VM must start or created in pause mode. |
| 602 | 'image_id','flavor_id': image and flavor VIM id to use for the VM |
| Alexis Romero | b70f4ed | 2022-03-11 18:00:49 +0100 | [diff] [blame] | 603 | affinity_group_list: list of affinity groups, each one is a dictionary. |
| 604 | Ignore if empty. |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 605 | 'net_list': list of interfaces, each one is a dictionary with: |
| 606 | 'name': (optional) name for the interface. |
| 607 | 'net_id': VIM network id where this interface must be connect to. Mandatory for type==virtual |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 608 | 'vpci': (optional) virtual vPCI address to assign at the VM. Can be ignored depending on VIM |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 609 | capabilities |
| garciadeblas | c4f4d73 | 2018-10-25 18:17:24 +0200 | [diff] [blame] | 610 | 'model': (optional and only have sense for type==virtual) interface model: virtio, e1000, ... |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 611 | 'mac_address': (optional) mac address to assign to this interface |
| tierno | 41a6981 | 2018-02-16 14:34:33 +0100 | [diff] [blame] | 612 | 'ip_address': (optional) IP address to assign to this interface |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 613 | #TODO: CHECK if an optional 'vlan' parameter is needed for VIMs when type if VF and net_id is not |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 614 | provided, the VLAN tag to be used. In case net_id is provided, the internal network vlan is used |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 615 | for tagging VF |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 616 | 'type': (mandatory) can be one of: |
| 617 | 'virtual', in this case always connected to a network of type 'net_type=bridge' |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 618 | 'PCI-PASSTHROUGH' or 'PF' (passthrough): depending on VIM capabilities it can be connected to a |
| 619 | data/ptp network ot it |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 620 | can created unconnected |
| tierno | 66eba6e | 2017-11-10 17:09:18 +0100 | [diff] [blame] | 621 | 'SR-IOV' or 'VF' (SRIOV with VLAN tag): same as PF for network connectivity. |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 622 | 'VFnotShared'(SRIOV without VLAN tag) same as PF for network connectivity. VF where no other VFs |
| 623 | are allocated on the same physical NIC |
| 624 | '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] | 625 | 'port_security': (optional) If False it must avoid any traffic filtering at this interface. If missing |
| 626 | or True, it must apply the default VIM behaviour |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 627 | After execution the method will add the key: |
| 628 | 'vim_id': must be filled/added by this method with the VIM identifier generated by the VIM for this |
| 629 | interface. 'net_list' is modified |
| 630 | 'cloud_config': (optional) dictionary with: |
| 631 | 'key-pairs': (optional) list of strings with the public key to be inserted to the default user |
| 632 | 'users': (optional) list of users to be inserted, each item is a dict with: |
| 633 | 'name': (mandatory) user name, |
| 634 | '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] | 635 | 'user-data': (optional) can be a string with the text script to be passed directly to cloud-init, |
| 636 | 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] | 637 | 'config-files': (optional). List of files to be transferred. Each item is a dict with: |
| 638 | 'dest': (mandatory) string with the destination absolute path |
| 639 | 'encoding': (optional, by default text). Can be one of: |
| 640 | 'b64', 'base64', 'gz', 'gz+b64', 'gz+base64', 'gzip+b64', 'gzip+base64' |
| 641 | 'content' (mandatory): string with the content of the file |
| 642 | 'permissions': (optional) string with file permissions, typically octal notation '0644' |
| 643 | 'owner': (optional) file owner, string with the format 'owner:group' |
| 644 | 'boot-data-drive': boolean to indicate if user-data must be passed using a boot drive (hard disk) |
| 645 | 'disk_list': (optional) list with additional disks to the VM. Each item is a dict with: |
| 646 | 'image_id': (optional). VIM id of an existing image. If not provided an empty disk must be mounted |
| 647 | 'size': (mandatory) string with the size of the disk in GB |
| tierno | 5a3273c | 2017-08-29 11:43:46 +0200 | [diff] [blame] | 648 | availability_zone_index: Index of availability_zone_list to use for this this VM. None if not AV required |
| 649 | availability_zone_list: list of availability zones given by user in the VNFD descriptor. Ignore if |
| 650 | availability_zone_index is None |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 651 | Returns a tuple with the instance identifier and created_items or raises an exception on error |
| 652 | created_items can be None or a dictionary where this method can include key-values that will be passed to |
| 653 | the method delete_vminstance and action_vminstance. Can be used to store created ports, volumes, etc. |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 654 | Format is VimConnector dependent, but do not use nested dictionaries and a value of None should be the same |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 655 | as not present. |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 656 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 657 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 658 | |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 659 | def get_vminstance(self, vm_id): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 660 | """Returns the VM instance information from VIM""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 661 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 662 | |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 663 | def delete_vminstance(self, vm_id, created_items=None): |
| 664 | """ |
| garciadeblas | ebd6672 | 2019-01-31 16:01:31 +0000 | [diff] [blame] | 665 | Removes a VM instance from VIM and its associated elements |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 666 | :param vm_id: VIM identifier of the VM, provided by method new_vminstance |
| 667 | :param created_items: dictionary with extra items to be deleted. provided by method new_vminstance and/or method |
| 668 | action_vminstance |
| 669 | :return: None or the same vm_id. Raises an exception on fail |
| 670 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 671 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 672 | |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 673 | def refresh_vms_status(self, vm_list): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 674 | """Get the status of the virtual machines and their interfaces/ports |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 675 | Params: the list of VM identifiers |
| 676 | Returns a dictionary with: |
| 677 | vm_id: #VIM id of this Virtual Machine |
| 678 | status: #Mandatory. Text with one of: |
| 679 | # DELETED (not found at vim) |
| 680 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 681 | # OTHER (Vim reported other status not understood) |
| 682 | # ERROR (VIM indicates an ERROR status) |
| 683 | # ACTIVE, PAUSED, SUSPENDED, INACTIVE (not running), |
| 684 | # BUILD (on building process), ERROR |
| 685 | # ACTIVE:NoMgmtIP (Active but any of its interface has an IP address |
| 686 | # |
| 687 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 688 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 689 | interfaces: list with interface info. Each item a dictionary with: |
| 690 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 691 | mac_address: #Text format XX:XX:XX:XX:XX:XX |
| 692 | vim_net_id: #network id where this interface is connected, if provided at creation |
| 693 | vim_interface_id: #interface/port VIM id |
| 694 | ip_address: #null, or text with IPv4, IPv6 address |
| 695 | compute_node: #identification of compute node where PF,VF interface is allocated |
| 696 | pci: #PCI address of the NIC that hosts the PF,VF |
| 697 | vlan: #physical VLAN used for VF |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 698 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 699 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 700 | |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 701 | def action_vminstance(self, vm_id, action_dict, created_items={}): |
| 702 | """ |
| 703 | Send and action over a VM instance. Returns created_items if the action was successfully sent to the VIM. |
| 704 | created_items is a dictionary with items that |
| 705 | :param vm_id: VIM identifier of the VM, provided by method new_vminstance |
| 706 | :param action_dict: dictionary with the action to perform |
| 707 | :param created_items: provided by method new_vminstance is a dictionary with key-values that will be passed to |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 708 | the method delete_vminstance. Can be used to store created ports, volumes, etc. Format is VimConnector |
| tierno | 98e909c | 2017-10-14 13:27:03 +0200 | [diff] [blame] | 709 | dependent, but do not use nested dictionaries and a value of None should be the same as not present. This |
| 710 | method can modify this value |
| 711 | :return: None, or a console dict |
| 712 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 713 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 714 | |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 715 | def get_vminstance_console(self, vm_id, console_type="vnc"): |
| 716 | """ |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 717 | Get a console for the virtual machine |
| 718 | Params: |
| 719 | vm_id: uuid of the VM |
| 720 | console_type, can be: |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 721 | "novnc" (by default), "xvpvnc" for VNC types, |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 722 | "rdp-html5" for RDP types, "spice-html5" for SPICE types |
| 723 | Returns dict with the console parameters: |
| 724 | protocol: ssh, ftp, http, https, ... |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 725 | server: usually ip address |
| 726 | port: the http, ssh, ... port |
| 727 | suffix: extra text, e.g. the http path and query string |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 728 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 729 | raise VimConnNotImplemented("Should have implemented this") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 730 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 731 | def inject_user_key( |
| 732 | self, ip_addr=None, user=None, key=None, ro_key=None, password=None |
| 733 | ): |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 734 | """ |
| 735 | Inject a ssh public key in a VM |
| 736 | Params: |
| 737 | ip_addr: ip address of the VM |
| 738 | user: username (default-user) to enter in the VM |
| 739 | key: public key to be injected in the VM |
| 740 | ro_key: private key of the RO, used to enter in the VM if the password is not provided |
| 741 | password: password of the user to enter in the VM |
| 742 | The function doesn't return a value: |
| 743 | """ |
| 744 | if not ip_addr or not user: |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 745 | raise VimConnNotSupportedException( |
| 746 | "All parameters should be different from 'None'" |
| 747 | ) |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 748 | elif not ro_key and not password: |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 749 | raise VimConnNotSupportedException( |
| 750 | "All parameters should be different from 'None'" |
| 751 | ) |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 752 | else: |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 753 | commands = { |
| 754 | "mkdir -p ~/.ssh/", |
| 755 | 'echo "{}" >> ~/.ssh/authorized_keys'.format(key), |
| 756 | "chmod 644 ~/.ssh/authorized_keys", |
| 757 | "chmod 700 ~/.ssh/", |
| 758 | } |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 759 | client = paramiko.SSHClient() |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 760 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 761 | try: |
| 762 | if ro_key: |
| tierno | 7d782ef | 2019-10-04 12:56:31 +0000 | [diff] [blame] | 763 | pkey = paramiko.RSAKey.from_private_key(StringIO(ro_key)) |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 764 | else: |
| 765 | pkey = None |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 766 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 767 | client.set_missing_host_key_policy(paramiko.AutoAddPolicy()) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 768 | client.connect( |
| 769 | ip_addr, username=user, password=password, pkey=pkey, timeout=10 |
| 770 | ) |
| 771 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 772 | for command in commands: |
| 773 | (i, o, e) = client.exec_command(command, timeout=10) |
| 774 | returncode = o.channel.recv_exit_status() |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 775 | outerror = e.read() |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 776 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 777 | if returncode != 0: |
| 778 | text = "run_command='{}' Error='{}'".format(command, outerror) |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 779 | raise VimConnUnexpectedResponse( |
| 780 | "Cannot inject ssh key in VM: '{}'".format(text) |
| 781 | ) |
| 782 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 783 | return |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 784 | except ( |
| 785 | socket.error, |
| 786 | paramiko.AuthenticationException, |
| 787 | paramiko.SSHException, |
| 788 | ) as message: |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 789 | raise VimConnUnexpectedResponse( |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 790 | "Cannot inject ssh key in VM: '{}' - {}".format( |
| 791 | ip_addr, str(message) |
| 792 | ) |
| 793 | ) |
| 794 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 795 | return |
| 796 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 797 | # Optional methods |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 798 | def new_tenant(self, tenant_name, tenant_description): |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 799 | """Adds a new tenant to VIM with this name and description, this is done using admin_url if provided |
| 800 | "tenant_name": string max lenght 64 |
| 801 | "tenant_description": string max length 256 |
| 802 | returns the tenant identifier or raise exception |
| 803 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 804 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 805 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 806 | def delete_tenant(self, tenant_id): |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 807 | """Delete a tenant from VIM |
| 808 | tenant_id: returned VIM tenant_id on "new_tenant" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 809 | Returns None on success. Raises and exception of failure. If tenant is not found raises VimConnNotFoundException |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 810 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 811 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 812 | |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 813 | def new_classification(self, name, ctype, definition): |
| 814 | """Creates a traffic classification in the VIM |
| 815 | Params: |
| 816 | 'name': name of this classification |
| 817 | 'ctype': type of this classification |
| 818 | 'definition': definition of this classification (type-dependent free-form text) |
| 819 | Returns the VIM's classification ID on success or raises an exception on failure |
| 820 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 821 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 822 | |
| 823 | def get_classification(self, classification_id): |
| 824 | """Obtain classification details of the VIM's classification with ID='classification_id' |
| 825 | Return a dict that contains: |
| 826 | 'id': VIM's classification ID (same as classification_id) |
| 827 | 'name': VIM's classification name |
| 828 | 'type': type of this classification |
| 829 | 'definition': definition of the classification |
| 830 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 831 | 'error_msg': (optional) text that explains the ERROR status |
| 832 | other VIM specific fields: (optional) whenever possible |
| 833 | Raises an exception upon error or when classification is not found |
| 834 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 835 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 836 | |
| 837 | def get_classification_list(self, filter_dict={}): |
| 838 | """Obtain classifications from the VIM |
| 839 | Params: |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 840 | 'filter_dict' (optional): contains the entries to filter the classifications on and only return those that |
| 841 | match ALL: |
| 842 | id: string => returns classifications with this VIM's classification ID, which implies a return of one |
| 843 | classification at most |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 844 | name: string => returns only classifications with this name |
| 845 | type: string => returns classifications of this type |
| 846 | definition: string => returns classifications that have this definition |
| 847 | tenant_id: string => returns only classifications that belong to this tenant/project |
| 848 | Returns a list of classification dictionaries, each dictionary contains: |
| 849 | 'id': (mandatory) VIM's classification ID |
| 850 | 'name': (mandatory) VIM's classification name |
| 851 | 'type': type of this classification |
| 852 | 'definition': definition of the classification |
| 853 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 854 | List can be empty if no classification matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 855 | authorization, or some other unspecific error |
| 856 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 857 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 858 | |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 859 | def refresh_classifications_status(self, classification_list): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 860 | """Get the status of the classifications |
| 861 | Params: the list of classification identifiers |
| 862 | Returns a dictionary with: |
| 863 | vm_id: #VIM id of this classifier |
| 864 | status: #Mandatory. Text with one of: |
| 865 | # DELETED (not found at vim) |
| 866 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 867 | # OTHER (Vim reported other status not understood) |
| 868 | # ERROR (VIM indicates an ERROR status) |
| 869 | # ACTIVE, |
| 870 | # CREATING (on building process) |
| 871 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 872 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 873 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 874 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 875 | |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 876 | def delete_classification(self, classification_id): |
| 877 | """Deletes a classification from the VIM |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 878 | Returns the classification ID (classification_id) or raises an exception upon error or when classification is |
| 879 | not found |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 880 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 881 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 882 | |
| 883 | def new_sfi(self, name, ingress_ports, egress_ports, sfc_encap=True): |
| 884 | """Creates a service function instance in the VIM |
| 885 | Params: |
| 886 | 'name': name of this service function instance |
| 887 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 888 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 889 | 'sfc_encap': boolean stating whether this specific instance supports IETF SFC Encapsulation |
| 890 | Returns the VIM's service function instance ID on success or raises an exception on failure |
| 891 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 892 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 893 | |
| 894 | def get_sfi(self, sfi_id): |
| 895 | """Obtain service function instance details of the VIM's service function instance with ID='sfi_id' |
| 896 | Return a dict that contains: |
| 897 | 'id': VIM's sfi ID (same as sfi_id) |
| 898 | 'name': VIM's sfi name |
| 899 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 900 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 901 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 902 | 'error_msg': (optional) text that explains the ERROR status |
| 903 | other VIM specific fields: (optional) whenever possible |
| 904 | Raises an exception upon error or when service function instance is not found |
| 905 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 906 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 907 | |
| 908 | def get_sfi_list(self, filter_dict={}): |
| 909 | """Obtain service function instances from the VIM |
| 910 | Params: |
| 911 | 'filter_dict' (optional): contains the entries to filter the sfis on and only return those that match ALL: |
| 912 | id: string => returns sfis with this VIM's sfi ID, which implies a return of one sfi at most |
| 913 | name: string => returns only service function instances with this name |
| 914 | tenant_id: string => returns only service function instances that belong to this tenant/project |
| 915 | Returns a list of service function instance dictionaries, each dictionary contains: |
| 916 | 'id': (mandatory) VIM's sfi ID |
| 917 | 'name': (mandatory) VIM's sfi name |
| 918 | 'ingress_ports': set of ingress ports (VIM's port IDs) |
| 919 | 'egress_ports': set of egress ports (VIM's port IDs) |
| 920 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 921 | List can be empty if no sfi matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 922 | authorization, or some other unspecific error |
| 923 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 924 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 925 | |
| 926 | def delete_sfi(self, sfi_id): |
| 927 | """Deletes a service function instance from the VIM |
| 928 | Returns the service function instance ID (sfi_id) or raises an exception upon error or when sfi is not found |
| 929 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 930 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 931 | |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 932 | def refresh_sfis_status(self, sfi_list): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 933 | """Get the status of the service function instances |
| 934 | Params: the list of sfi identifiers |
| 935 | Returns a dictionary with: |
| 936 | vm_id: #VIM id of this service function instance |
| 937 | status: #Mandatory. Text with one of: |
| 938 | # DELETED (not found at vim) |
| 939 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 940 | # OTHER (Vim reported other status not understood) |
| 941 | # ERROR (VIM indicates an ERROR status) |
| 942 | # ACTIVE, |
| 943 | # CREATING (on building process) |
| 944 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 945 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 946 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 947 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 948 | |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 949 | def new_sf(self, name, sfis, sfc_encap=True): |
| 950 | """Creates (an abstract) service function in the VIM |
| 951 | Params: |
| 952 | 'name': name of this service function |
| 953 | 'sfis': set of service function instances of this (abstract) service function |
| 954 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 955 | Returns the VIM's service function ID on success or raises an exception on failure |
| 956 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 957 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 958 | |
| 959 | def get_sf(self, sf_id): |
| 960 | """Obtain service function details of the VIM's service function with ID='sf_id' |
| 961 | Return a dict that contains: |
| 962 | 'id': VIM's sf ID (same as sf_id) |
| 963 | 'name': VIM's sf name |
| 964 | 'sfis': VIM's sf's set of VIM's service function instance IDs |
| 965 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 966 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 967 | 'error_msg': (optional) text that explains the ERROR status |
| 968 | other VIM specific fields: (optional) whenever possible |
| 969 | Raises an exception upon error or when sf is not found |
| 970 | """ |
| 971 | |
| 972 | def get_sf_list(self, filter_dict={}): |
| 973 | """Obtain service functions from the VIM |
| 974 | Params: |
| 975 | 'filter_dict' (optional): contains the entries to filter the sfs on and only return those that match ALL: |
| 976 | id: string => returns sfs with this VIM's sf ID, which implies a return of one sf at most |
| 977 | name: string => returns only service functions with this name |
| 978 | tenant_id: string => returns only service functions that belong to this tenant/project |
| 979 | Returns a list of service function dictionaries, each dictionary contains: |
| 980 | 'id': (mandatory) VIM's sf ID |
| 981 | 'name': (mandatory) VIM's sf name |
| 982 | 'sfis': VIM's sf's set of VIM's service function instance IDs |
| 983 | 'sfc_encap': boolean stating whether this service function supports IETF SFC Encapsulation |
| 984 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 985 | List can be empty if no sf matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 986 | authorization, or some other unspecific error |
| 987 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 988 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 989 | |
| 990 | def delete_sf(self, sf_id): |
| 991 | """Deletes (an abstract) service function from the VIM |
| 992 | Returns the service function ID (sf_id) or raises an exception upon error or when sf is not found |
| 993 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 994 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 995 | |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 996 | def refresh_sfs_status(self, sf_list): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 997 | """Get the status of the service functions |
| 998 | Params: the list of sf identifiers |
| 999 | Returns a dictionary with: |
| 1000 | vm_id: #VIM id of this service function |
| 1001 | status: #Mandatory. Text with one of: |
| 1002 | # DELETED (not found at vim) |
| 1003 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 1004 | # OTHER (Vim reported other status not understood) |
| 1005 | # ERROR (VIM indicates an ERROR status) |
| 1006 | # ACTIVE, |
| 1007 | # CREATING (on building process) |
| 1008 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 1009 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump) |
| 1010 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1011 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1012 | |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1013 | def new_sfp(self, name, classifications, sfs, sfc_encap=True, spi=None): |
| 1014 | """Creates a service function path |
| 1015 | Params: |
| 1016 | 'name': name of this service function path |
| 1017 | 'classifications': set of traffic classifications that should be matched on to get into this sfp |
| 1018 | 'sfs': list of every service function that constitutes this path , from first to last |
| 1019 | 'sfc_encap': whether this is an SFC-Encapsulated chain (i.e using NSH), True by default |
| 1020 | 'spi': (optional) the Service Function Path identifier (SPI: Service Path Identifier) for this path |
| 1021 | Returns the VIM's sfp ID on success or raises an exception on failure |
| 1022 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1023 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1024 | |
| 1025 | def get_sfp(self, sfp_id): |
| 1026 | """Obtain service function path details of the VIM's sfp with ID='sfp_id' |
| 1027 | Return a dict that contains: |
| 1028 | 'id': VIM's sfp ID (same as sfp_id) |
| 1029 | 'name': VIM's sfp name |
| 1030 | 'classifications': VIM's sfp's list of VIM's classification IDs |
| 1031 | 'sfs': VIM's sfp's list of VIM's service function IDs |
| 1032 | 'status': 'ACTIVE', 'INACTIVE', 'DOWN', 'BUILD', 'ERROR', 'VIM_ERROR', 'OTHER' |
| 1033 | 'error_msg': (optional) text that explains the ERROR status |
| 1034 | other VIM specific fields: (optional) whenever possible |
| 1035 | Raises an exception upon error or when sfp is not found |
| 1036 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1037 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1038 | |
| 1039 | def get_sfp_list(self, filter_dict={}): |
| 1040 | """Obtain service function paths from VIM |
| 1041 | Params: |
| 1042 | 'filter_dict' (optional): contains the entries to filter the sfps on, and only return those that match ALL: |
| 1043 | id: string => returns sfps with this VIM's sfp ID , which implies a return of one sfp at most |
| 1044 | name: string => returns only sfps with this name |
| 1045 | tenant_id: string => returns only sfps that belong to this tenant/project |
| 1046 | Returns a list of service function path dictionaries, each dictionary contains: |
| 1047 | 'id': (mandatory) VIM's sfp ID |
| 1048 | 'name': (mandatory) VIM's sfp name |
| 1049 | 'classifications': VIM's sfp's list of VIM's classification IDs |
| 1050 | 'sfs': VIM's sfp's list of VIM's service function IDs |
| 1051 | other VIM specific fields: (optional) whenever possible using the same naming of filter_dict param |
| 1052 | List can be empty if no sfp matches the filter_dict. Raise an exception only upon VIM connectivity, |
| 1053 | authorization, or some other unspecific error |
| 1054 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1055 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1056 | |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1057 | def refresh_sfps_status(self, sfp_list): |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 1058 | """Get the status of the service function path |
| 1059 | Params: the list of sfp identifiers |
| 1060 | Returns a dictionary with: |
| 1061 | vm_id: #VIM id of this service function path |
| 1062 | status: #Mandatory. Text with one of: |
| 1063 | # DELETED (not found at vim) |
| 1064 | # VIM_ERROR (Cannot connect to VIM, VIM response error, ...) |
| 1065 | # OTHER (Vim reported other status not understood) |
| 1066 | # ERROR (VIM indicates an ERROR status) |
| 1067 | # ACTIVE, |
| 1068 | # CREATING (on building process) |
| 1069 | error_msg: #Text with VIM error message, if any. Or the VIM connection ERROR |
| 1070 | vim_info: #Text with plain information obtained from vim (yaml.safe_dump)F |
| 1071 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1072 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1073 | |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1074 | def delete_sfp(self, sfp_id): |
| 1075 | """Deletes a service function path from the VIM |
| 1076 | Returns the sfp ID (sfp_id) or raises an exception upon error or when sf is not found |
| 1077 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1078 | raise VimConnNotImplemented("SFC support not implemented") |
| Igor Duarte Cardoso | 862a60a | 2017-08-09 16:07:46 +0000 | [diff] [blame] | 1079 | |
| sousaedu | 80135b9 | 2021-02-17 15:05:18 +0100 | [diff] [blame] | 1080 | # NOT USED METHODS in current version. Deprecated |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1081 | @deprecated |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1082 | def host_vim2gui(self, host, server_dict): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1083 | """Transform host dictionary from VIM format to GUI format, |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1084 | and append to the server_dict |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1085 | """ |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1086 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1087 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1088 | @deprecated |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1089 | def get_hosts_info(self): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1090 | """Get the information of deployed hosts |
| 1091 | Returns the hosts content""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1092 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1093 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1094 | @deprecated |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1095 | def get_hosts(self, vim_tenant): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1096 | """Get the hosts and deployed instances |
| 1097 | Returns the hosts content""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1098 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1099 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1100 | @deprecated |
| tierno | 7edb675 | 2016-03-21 17:37:52 +0100 | [diff] [blame] | 1101 | def get_processor_rankings(self): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1102 | """Get the processor rankings in the VIM database""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1103 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1104 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1105 | @deprecated |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1106 | def new_host(self, host_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1107 | """Adds a new host to VIM""" |
| 1108 | """Returns status code of the VIM response""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1109 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1110 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1111 | @deprecated |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1112 | def new_external_port(self, port_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1113 | """Adds a external port to VIM""" |
| 1114 | """Returns the port identifier""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1115 | raise VimConnNotImplemented("Should have implemented this") |
| borsatti | 8a2dda3 | 2019-12-18 15:08:57 +0000 | [diff] [blame] | 1116 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1117 | @deprecated |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1118 | def new_external_network(self, net_name, net_type): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1119 | """Adds a external network to VIM (shared)""" |
| 1120 | """Returns the network identifier""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1121 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1122 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1123 | @deprecated |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1124 | def connect_port_network(self, port_id, network_id, admin=False): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1125 | """Connects a external port to a network""" |
| 1126 | """Returns status code of the VIM response""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1127 | raise VimConnNotImplemented("Should have implemented this") |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1128 | |
| tierno | 9228f51 | 2019-07-04 16:23:00 +0000 | [diff] [blame] | 1129 | @deprecated |
| tierno | ae4a8d1 | 2016-07-08 12:30:39 +0200 | [diff] [blame] | 1130 | def new_vminstancefromJSON(self, vm_data): |
| tierno | a7d34d0 | 2017-02-23 14:42:07 +0100 | [diff] [blame] | 1131 | """Adds a VM instance to VIM""" |
| 1132 | """Returns the instance identifier""" |
| tierno | 7277486 | 2020-05-04 11:44:15 +0000 | [diff] [blame] | 1133 | raise VimConnNotImplemented("Should have implemented this") |