1 # Copyright 2021 K Sai Kiran (Tata Elxsi)
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
13 # See the License for the specific language governing permissions and
14 # limitations under the License.
16 __author__
= "K Sai Kiran <saikiran.k@tataelxsi.co.in>, Selvi Jayaraman <selvi.j@tataelxsi.co.in>"
17 __date__
= "$12-June-2021 8:30:59$"
19 from osm_nbi
.base_topic
import BaseTopic
20 from .osm_vnfm
.vnf_instances
import VnfInstances2NsInstances
21 from .osm_vnfm
.vnf_instance_actions
import VnfLcmOp2NsLcmOp
24 class VnfInstances(BaseTopic
):
25 def __init__(self
, db
, fs
, msg
, auth
):
27 Constructor call for vnf instance topic
29 BaseTopic
.__init
__(self
, db
, fs
, msg
, auth
)
30 self
.vnfinstances2nsinstances
= VnfInstances2NsInstances(db
, fs
, msg
, auth
)
32 def new(self
, rollback
, session
, indata
=None, kwargs
=None, headers
=None):
34 Creates new vnf instance
35 :param rollback: list to append the created items at database in case a rollback must be done
36 :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
37 :param indata: params to be used for the vnf instance
38 :param kwargs: used to override the indata descriptor
39 :param headers: http request headers
40 :return: the _id of vnf instance created at database. Or an exception.
42 return self
.vnfinstances2nsinstances
.new(
43 rollback
, session
, indata
, kwargs
, headers
46 def list(self
, session
, filter_q
=None, api_req
=False):
48 Get a list of the vnf instances that match a filter
49 :param session: contains the used login username and working project
50 :param filter_q: filter of data to be applied
51 :param api_req: True if this call is serving an external API request. False if serving internal request.
52 :return: The list, it can be empty if no one match the filter.
54 return self
.vnfinstances2nsinstances
.list(session
, filter_q
, api_req
)
56 def show(self
, session
, _id
, filter_q
=None, api_req
=False):
58 Get complete information on an vnf instance
59 :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
60 :param _id: server internal id
61 :param api_req: True if this call is serving an external API request. False if serving internal request.
62 :return: dictionary, raise exception if not found.
64 return self
.vnfinstances2nsinstances
.show(session
, _id
, api_req
)
66 def delete(self
, session
, _id
, dry_run
=False, not_send_msg
=None):
68 Delete vnf instance by its internal _id
69 :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
70 :param _id: server internal id
71 :param dry_run: make checking but do not delete
72 :param not_send_msg: To not send message (False) or store content (list) instead
73 :return: operation id (None if there is not operation), raise exception if error or not found, conflict, ...
75 return self
.vnfinstances2nsinstances
.delete(session
, _id
, dry_run
, not_send_msg
)
78 class VnfLcmOpTopic(BaseTopic
):
79 def __init__(self
, db
, fs
, msg
, auth
):
81 Constructor call for vnf lcm op topic
83 BaseTopic
.__init
__(self
, db
, fs
, msg
, auth
)
84 self
.vnflcmop2nslcmop
= VnfLcmOp2NsLcmOp(db
, fs
, msg
, auth
)
86 def new(self
, rollback
, session
, indata
=None, kwargs
=None, headers
=None):
88 Creates new vnf lcm op
89 :param rollback: list to append the created items at database in case a rollback must be done
90 :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
91 :param indata: params to be used for the vnf instance
92 :param kwargs: used to override the indata descriptor
93 :param headers: http request headers
94 :return: the _id of vnf lcm op created at database. Or an exception.
96 return self
.vnflcmop2nslcmop
.new(rollback
, session
, indata
, kwargs
, headers
)
98 def list(self
, session
, filter_q
=None, api_req
=False):
100 Get a list of the vnf lcm op that match a filter
101 :param session: contains the used login username and working project
102 :param filter_q: filter of data to be applied
103 :param api_req: True if this call is serving an external API request. False if serving internal request.
104 :return: The list, it can be empty if no one match the filter.
106 return self
.vnflcmop2nslcmop
.list(session
, filter_q
, api_req
)
108 def show(self
, session
, _id
, filter_q
=None, api_req
=False):
110 Get complete information on an vnf lcm op
111 :param session: contains "username", "admin", "force", "public", "project_id", "set_project"
112 :param _id: server internal id
113 :param api_req: True if this call is serving an external API request. False if serving internal request.
114 :return: dictionary, raise exception if not found.
116 return self
.vnflcmop2nslcmop
.show(session
, _id
, api_req
)