# See the License for the specific language governing permissions and
# limitations under the License.
-import json
+# import json
import logging
import traceback
from threading import Thread
from lcm.pub.database.models import NfInstModel, VmInstModel
from lcm.pub.exceptions import NFLCMException
-from lcm.pub.msapi.gvnfmdriver import notify_lcm_to_nfvo, prepare_notification_data
+from lcm.pub.msapi.gvnfmdriver import prepare_notification_data
+# from lcm.pub.msapi.gvnfmdriver import notify_lcm_to_nfvo
from lcm.pub.utils.jobutil import JobUtil
from lcm.pub.utils.timeutil import now_time
+from lcm.pub.utils.notificationsutil import NotificationsUtil
from lcm.pub.utils.values import ignore_case_get
from lcm.pub.vimapi import adaptor
from lcm.nf.biz.grant_vnf import grant_resource
-from lcm.nf.const import VNF_STATUS, RESOURCE_MAP, GRANT_TYPE
+from lcm.nf.const import VNF_STATUS, RESOURCE_MAP, CHANGE_TYPE, GRANT_TYPE, OPERATION_TYPE
logger = logging.getLogger(__name__)
resource_table = globals().get(resource_type + 'InstModel')
resource_insts = resource_table.objects.filter(instid=self.nf_inst_id)
for resource_inst in resource_insts:
- if not resource_inst.resouceid:
+ if not resource_inst.resourceid:
continue
self.inst_resource[RESOURCE_MAP.get(resource_type)].append(self.get_resource(resource_inst))
logger.info('Query resource end, resource=%s' % self.inst_resource)
return {
"vim_id": resource.vimid,
"tenant_id": resource.tenant,
- "id": resource.resouceid
+ "id": resource.resourceid
}
def operate_resource(self):
logger.info('Operate resource complete')
def lcm_notify(self):
- notification_content = prepare_notification_data(self.nf_inst_id, self.job_id, "MODIFIED")
+ notification_content = prepare_notification_data(self.nf_inst_id, self.job_id, CHANGE_TYPE.MODIFIED, OPERATION_TYPE.OPERATE)
logger.info('Notify request data = %s' % notification_content)
- resp = notify_lcm_to_nfvo(json.dumps(notification_content))
- logger.info('Lcm notify end, response %s' % resp)
+ # resp = notify_lcm_to_nfvo(json.dumps(notification_content))
+ # logger.info('Lcm notify end, response %s' % resp)
+ NotificationsUtil().send_notification(notification_content)
def vnf_operate_failed_handle(self, error_msg):
logger.error('VNF Operation failed, detail message: %s' % error_msg)
def do_notify_op(self, status, resid):
logger.error('VNF resource %s updated to: %s' % (resid, status))
- VmInstModel.objects.filter(instid=self.nf_inst_id, resouceid=resid).update(operationalstate=status)
+ VmInstModel.objects.filter(instid=self.nf_inst_id, resourceid=resid).update(operationalstate=status)