projects
/
osm
/
SO.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
update from RIFT as of 696b75d2fe9fb046261b08c616f1bcf6c0b54a9b second try
[osm/SO.git]
/
rwlaunchpad
/
plugins
/
rwnsm
/
rift
/
tasklets
/
rwnsmtasklet
/
publisher.py
diff --git
a/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/publisher.py
b/rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/publisher.py
index
6c4b123
..
6def40e
100644
(file)
--- a/
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/publisher.py
+++ b/
rwlaunchpad/plugins/rwnsm/rift/tasklets/rwnsmtasklet/publisher.py
@@
-1,4
+1,4
@@
-#
+#
# Copyright 2016 RIFT.IO Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# Copyright 2016 RIFT.IO Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
@@
-21,7
+21,7
@@
import json
from gi.repository import (
RwDts as rwdts,
RwTypes,
from gi.repository import (
RwDts as rwdts,
RwTypes,
- RwVnfdYang,
+ Rw
ProjectVnfdYang as Rw
VnfdYang,
RwYang
)
import rift.tasklets
RwYang
)
import rift.tasklets
@@
-33,10
+33,11
@@
class NsrOpDataDtsHandler(object):
""" The network service op data DTS handler """
XPATH = "D,/nsr:ns-instance-opdata/nsr:nsr"
""" The network service op data DTS handler """
XPATH = "D,/nsr:ns-instance-opdata/nsr:nsr"
- def __init__(self, dts, log, loop):
+ def __init__(self, dts, log, loop
, project
):
self._dts = dts
self._log = log
self._loop = loop
self._dts = dts
self._log = log
self._loop = loop
+ self._project = project
self._regh = None
@property
self._regh = None
@property
@@
-47,52
+48,63
@@
class NsrOpDataDtsHandler(object):
@asyncio.coroutine
def register(self):
""" Register for Nsr op data publisher registration"""
@asyncio.coroutine
def register(self):
""" Register for Nsr op data publisher registration"""
- self._log.debug("Registering Nsr op data path %s as publisher",
- NsrOpDataDtsHandler.XPATH)
+ if self._regh:
+ return
+
+ xpath = self._project.add_project(NsrOpDataDtsHandler.XPATH)
+ self._log.debug("Registering Nsr op data path {} as publisher".
+ format(xpath))
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
- self._regh = group.register(xpath=
NsrOpDataDtsHandler.XPATH
,
+ self._regh = group.register(xpath=
xpath
,
handler=hdl,
flags=rwdts.Flag.PUBLISHER | rwdts.Flag.NO_PREP_READ)
@asyncio.coroutine
handler=hdl,
flags=rwdts.Flag.PUBLISHER | rwdts.Flag.NO_PREP_READ)
@asyncio.coroutine
- def create(self, xact, path, msg):
+ def create(self, xact,
x
path, msg):
"""
Create an NS record in DTS with the path and message
"""
"""
Create an NS record in DTS with the path and message
"""
+ path = self._project.add_project(xpath)
self._log.debug("Creating NSR xact = %s, %s:%s", xact, path, msg)
self._log.debug("Creating NSR xact = %s, %s:%s", xact, path, msg)
- self.regh.create_element(path, msg)
+ self.regh.create_element(path, msg
, xact=xact
)
self._log.debug("Created NSR xact = %s, %s:%s", xact, path, msg)
@asyncio.coroutine
self._log.debug("Created NSR xact = %s, %s:%s", xact, path, msg)
@asyncio.coroutine
- def update(self, xact, path, msg, flags=rwdts.XactFlag.REPLACE):
+ def update(self, xact,
x
path, msg, flags=rwdts.XactFlag.REPLACE):
"""
Update an NS record in DTS with the path and message
"""
"""
Update an NS record in DTS with the path and message
"""
+ path = self._project.add_project(xpath)
self._log.debug("Updating NSR xact = %s, %s:%s regh = %s", xact, path, msg, self.regh)
self._log.debug("Updating NSR xact = %s, %s:%s regh = %s", xact, path, msg, self.regh)
- self.regh.update_element(path, msg, flags)
+ self.regh.update_element(path, msg, flags
, xact=xact
)
self._log.debug("Updated NSR xact = %s, %s:%s", xact, path, msg)
@asyncio.coroutine
self._log.debug("Updated NSR xact = %s, %s:%s", xact, path, msg)
@asyncio.coroutine
- def delete(self, xact, path):
+ def delete(self, xact,
x
path):
"""
Update an NS record in DTS with the path and message
"""
"""
Update an NS record in DTS with the path and message
"""
+ path = self._project.add_project(xpath)
self._log.debug("Deleting NSR xact:%s, path:%s", xact, path)
self._log.debug("Deleting NSR xact:%s, path:%s", xact, path)
- self.regh.delete_element(path)
+ self.regh.delete_element(path
, xact=xact
)
self._log.debug("Deleted NSR xact:%s, path:%s", xact, path)
self._log.debug("Deleted NSR xact:%s, path:%s", xact, path)
-
+ def deregister(self):
+ if self._regh:
+ self._regh.deregister()
+ self._regh = None
class VnfrPublisherDtsHandler(object):
class VnfrPublisherDtsHandler(object):
- """ Registers 'D,/vnfr:vnfr-catalog/vnfr:vnfr' DTS"""
+ """ Registers 'D,/
rw-project:project/
vnfr:vnfr-catalog/vnfr:vnfr' DTS"""
XPATH = "D,/vnfr:vnfr-catalog/vnfr:vnfr"
XPATH = "D,/vnfr:vnfr-catalog/vnfr:vnfr"
- def __init__(self, dts, log, loop):
+ def __init__(self, dts, log, loop
, project
):
self._dts = dts
self._log = log
self._loop = loop
self._dts = dts
self._log = log
self._loop = loop
+ self._project = project
self._regh = None
self._regh = None
@@
-104,6
+116,8
@@
class VnfrPublisherDtsHandler(object):
@asyncio.coroutine
def register(self):
""" Register for Vvnfr create/update/delete/read requests from dts """
@asyncio.coroutine
def register(self):
""" Register for Vvnfr create/update/delete/read requests from dts """
+ if self._regh:
+ return
@asyncio.coroutine
def on_prepare(xact_info, action, ks_path, msg):
@asyncio.coroutine
def on_prepare(xact_info, action, ks_path, msg):
@@
-116,17
+130,24
@@
class VnfrPublisherDtsHandler(object):
"%s action on VirtualNetworkFunctionRecord not supported",
action)
"%s action on VirtualNetworkFunctionRecord not supported",
action)
- self._log.debug("Registering for VNFR using xpath: %s",
- VnfrPublisherDtsHandler.XPATH,)
+ xpath = self._project.add_project(VnfrPublisherDtsHandler.XPATH)
+ self._log.debug("Registering for VNFR using xpath: {}".
+ format(xpath))
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
- self._regh = group.register(xpath=
VnfrPublisherDtsHandler.XPATH
,
+ self._regh = group.register(xpath=
xpath
,
handler=hdl,
flags=(rwdts.Flag.PUBLISHER |
handler=hdl,
flags=(rwdts.Flag.PUBLISHER |
+ rwdts.Flag.SHARED |
rwdts.Flag.NO_PREP_READ |
rwdts.Flag.CACHE),)
rwdts.Flag.NO_PREP_READ |
rwdts.Flag.CACHE),)
+ def deregister(self):
+ if self._regh:
+ self._regh.deregister()
+ self._regh = None
+
@asyncio.coroutine
def create(self, xact, path, msg):
"""
@asyncio.coroutine
def create(self, xact, path, msg):
"""
@@
-134,7
+155,7
@@
class VnfrPublisherDtsHandler(object):
"""
self._log.debug("Creating VNFR xact = %s, %s:%s",
xact, path, msg)
"""
self._log.debug("Creating VNFR xact = %s, %s:%s",
xact, path, msg)
- self.regh.create_element(path, msg)
+ self.regh.create_element(path, msg
, xact=xact
)
self._log.debug("Created VNFR xact = %s, %s:%s",
xact, path, msg)
self._log.debug("Created VNFR xact = %s, %s:%s",
xact, path, msg)
@@
-145,7
+166,7
@@
class VnfrPublisherDtsHandler(object):
"""
self._log.debug("Updating VNFR xact = %s, %s:%s",
xact, path, msg)
"""
self._log.debug("Updating VNFR xact = %s, %s:%s",
xact, path, msg)
- self.regh.update_element(path, msg)
+ self.regh.update_element(path, msg
, xact=xact
)
self._log.debug("Updated VNFR xact = %s, %s:%s",
xact, path, msg)
self._log.debug("Updated VNFR xact = %s, %s:%s",
xact, path, msg)
@@
-155,18
+176,19
@@
class VnfrPublisherDtsHandler(object):
Delete a VNFR record in DTS with path and message
"""
self._log.debug("Deleting VNFR xact = %s, %s", xact, path)
Delete a VNFR record in DTS with path and message
"""
self._log.debug("Deleting VNFR xact = %s, %s", xact, path)
- self.regh.delete_element(path)
+ self.regh.delete_element(path
, xact=xact
)
self._log.debug("Deleted VNFR xact = %s, %s", xact, path)
class VlrPublisherDtsHandler(object):
self._log.debug("Deleted VNFR xact = %s, %s", xact, path)
class VlrPublisherDtsHandler(object):
- """ registers 'D,/vlr:vlr-catalog/vlr:vlr """
+ """ registers 'D,/
rw-project:project/
vlr:vlr-catalog/vlr:vlr """
XPATH = "D,/vlr:vlr-catalog/vlr:vlr"
XPATH = "D,/vlr:vlr-catalog/vlr:vlr"
- def __init__(self, dts, log, loop):
+ def __init__(self, dts, log, loop
, project
):
self._dts = dts
self._log = log
self._loop = loop
self._dts = dts
self._log = log
self._loop = loop
+ self._project = project
self._regh = None
self._regh = None
@@
-179,6
+201,9
@@
class VlrPublisherDtsHandler(object):
def register(self):
""" Register for vlr create/update/delete/read requests from dts """
def register(self):
""" Register for vlr create/update/delete/read requests from dts """
+ if self._regh:
+ return
+
@asyncio.coroutine
def on_prepare(xact_info, action, ks_path, msg):
""" prepare callback from dts """
@asyncio.coroutine
def on_prepare(xact_info, action, ks_path, msg):
""" prepare callback from dts """
@@
-190,17
+215,23
@@
class VlrPublisherDtsHandler(object):
"%s action on VirtualLinkRecord not supported",
action)
"%s action on VirtualLinkRecord not supported",
action)
- self._log.debug("Registering for VLR using xpath: %s",
- VlrPublisherDtsHandler.XPATH,)
+ xpath = self._project.add_project(VlrPublisherDtsHandler.XPATH)
+ self._log.debug("Registering for VLR using xpath: {}".
+ format(xpath))
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
hdl = rift.tasklets.DTS.RegistrationHandler()
with self._dts.group_create() as group:
- self._regh = group.register(xpath=
VlrPublisherDtsHandler.XPATH
,
+ self._regh = group.register(xpath=
xpath
,
handler=hdl,
flags=(rwdts.Flag.PUBLISHER |
rwdts.Flag.NO_PREP_READ |
rwdts.Flag.CACHE),)
handler=hdl,
flags=(rwdts.Flag.PUBLISHER |
rwdts.Flag.NO_PREP_READ |
rwdts.Flag.CACHE),)
+ def deregister(self):
+ if self._regh:
+ self._regh.deregister()
+ self._regh = None
+
@asyncio.coroutine
def create(self, xact, path, msg):
"""
@asyncio.coroutine
def create(self, xact, path, msg):
"""
@@
-208,7
+239,7
@@
class VlrPublisherDtsHandler(object):
"""
self._log.debug("Creating VLR xact = %s, %s:%s",
xact, path, msg)
"""
self._log.debug("Creating VLR xact = %s, %s:%s",
xact, path, msg)
- self.regh.create_element(path, msg)
+ self.regh.create_element(path, msg
, xact=xact
)
self._log.debug("Created VLR xact = %s, %s:%s",
xact, path, msg)
self._log.debug("Created VLR xact = %s, %s:%s",
xact, path, msg)
@@
-219,7
+250,7
@@
class VlrPublisherDtsHandler(object):
"""
self._log.debug("Updating VLR xact = %s, %s:%s",
xact, path, msg)
"""
self._log.debug("Updating VLR xact = %s, %s:%s",
xact, path, msg)
- self.regh.update_element(path, msg)
+ self.regh.update_element(path, msg
, xact=xact
)
self._log.debug("Updated VLR xact = %s, %s:%s",
xact, path, msg)
self._log.debug("Updated VLR xact = %s, %s:%s",
xact, path, msg)
@@
-229,19
+260,20
@@
class VlrPublisherDtsHandler(object):
Delete a VLR record in DTS with path and message
"""
self._log.debug("Deleting VLR xact = %s, %s", xact, path)
Delete a VLR record in DTS with path and message
"""
self._log.debug("Deleting VLR xact = %s, %s", xact, path)
- self.regh.delete_element(path)
+ self.regh.delete_element(path
, xact=xact
)
self._log.debug("Deleted VLR xact = %s, %s", xact, path)
class VnfdPublisher(object):
self._log.debug("Deleted VLR xact = %s, %s", xact, path)
class VnfdPublisher(object):
- AUTH = ('
admin', 'admin
')
+ AUTH = ('
@rift', 'rift
')
HEADERS = {"content-type": "application/vnd.yang.data+json"}
HEADERS = {"content-type": "application/vnd.yang.data+json"}
- def __init__(self, use_ssl, ssl_cert, ssl_key, loop):
+ def __init__(self, use_ssl, ssl_cert, ssl_key, loop
, project
):
self.use_ssl = use_ssl
self.ssl_cert = ssl_cert
self.ssl_key = ssl_key
self.use_ssl = use_ssl
self.ssl_cert = ssl_cert
self.ssl_key = ssl_key
+ self._project = project
self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
self.loop = loop
self.executor = concurrent.futures.ThreadPoolExecutor(max_workers=1)
self.loop = loop
@@
-255,15
+287,15
@@
class VnfdPublisher(object):
scheme = "https" if self.use_ssl else "http"
scheme = "https" if self.use_ssl else "http"
- url = "{}://127.0.0.1:8008/api/config/vnfd-catalog/vnfd/{}"
+ url = "{}://127.0.0.1:8008/api/config/
project/{}/
vnfd-catalog/vnfd/{}"
- model = RwYang.Model.create_lib
ncx
()
- model.load_module("rw-vnfd")
- model.load_module("vnfd")
+ model = RwYang.Model.create_lib
yang
()
+ model.load_module("rw-
project-
vnfd")
+ model.load_module("
project-
vnfd")
data = vnfd.to_json(model)
data = vnfd.to_json(model)
- key = "vnfd:vnfd-catalog"
+ key = "
project-
vnfd:vnfd-catalog"
newdict = json.loads(data)
if key in newdict:
data = json.dumps(newdict[key])
newdict = json.loads(data)
if key in newdict:
data = json.dumps(newdict[key])
@@
-277,7
+309,7
@@
class VnfdPublisher(object):
options["cert"] = (self.ssl_cert, self.ssl_key)
response = requests.put(
options["cert"] = (self.ssl_cert, self.ssl_key)
response = requests.put(
- url.format(scheme, vnfd.id),
+ url.format(scheme,
self._project.name,
vnfd.id),
**options
)
**options
)
@@
-286,4
+318,3
@@
class VnfdPublisher(object):
update,
vnfd
)
update,
vnfd
)
-