class SDNAccountConfigSubscriber(object):
XPATH = "C,/rw-sdn:sdn/rw-sdn:account"
- def __init__(self, dts, log, rwlog_hdl, sdn_callbacks, acctstore):
+ def __init__(self, dts, log, project, rwlog_hdl, sdn_callbacks, acctstore):
self._dts = dts
self._log = log
+ self._project = project
self._rwlog_hdl = rwlog_hdl
self._reg = None
xact_info.respond_xpath(rwdts.XactRspCode.ACK)
+ xpath = self._project.add_project(SDNAccountConfigSubscriber.XPATH)
self._log.debug("Registering for SDN Account config using xpath: %s",
- SDNAccountConfigSubscriber.XPATH,
+ xpath,
)
acg_handler = rift.tasklets.AppConfGroup.Handler(
with self._dts.appconf_group_create(acg_handler) as acg:
self._reg = acg.register(
- xpath=SDNAccountConfigSubscriber.XPATH,
+ xpath=xpath,
flags=rwdts.Flag.SUBSCRIBER | rwdts.Flag.DELTA_READY | rwdts.Flag.CACHE,
on_prepare=on_prepare,
)
class SDNAccountDtsOperdataHandler(object):
- def __init__(self, dts, log, loop):
+ def __init__(self, dts, log, loop, project):
self._dts = dts
self._log = log
self._loop = loop
+ self._project = project
self.sdn_accounts = {}
self._oper = None
def _register_show_status(self):
def get_xpath(sdn_name=None):
- return "D,/rw-sdn:sdn/account{}/connection-status".format(
- "[name='%s']" % sdn_name if sdn_name is not None else ''
- )
+ return self._project.add_project("D,/rw-sdn:sdn/account{}/connection-status".
+ format(
+ "[name='%s']" % sdn_name
+ if sdn_name is not None else ''))
@asyncio.coroutine
def on_prepare(xact_info, action, ks_path, msg):
except Exception as e:
self._log.exception("Project {} create for {} failed: {}".
format(name, self._get_tasklet_name(), e))
+ raise e
try:
yield from self._get_project(name).register()
except Exception as e:
self._log.exception("Project {} register for tasklet {} failed: {}".
format(name, self._get_tasklet_name(), e))
+ raise e
@asyncio.coroutine
def on_delete_prepare(self, name):
<permissions>read execute</permissions>
<path>/rw-project:project/nsr:ns-instance-config</path>
<path>/rw-project:project/nsr:ns-instance-opdata</path>
+ <path>/rw-project:project/nsr:key-pair</path>
</authorize>
</role-definition>
<permissions>create read update delete execute</permissions>
<path>/rw-project:project/nsr:ns-instance-config</path>
<path>/rw-project:project/nsr:ns-instance-opdata</path>
+ <path>/rw-project:project/nsr:key-pair</path>
<path>/nsr:exec-scale-out</path>
<path>/nsr:exec-scale-in</path>
<path>/nsr:exec-ns-service-primitive</path>
leaf key-pair-ref {
description "A reference to the key pair entry in the global key pair table";
type leafref {
- path "/nsr:key-pair/nsr:name";
+ path "../../../../key-pair/name";
}
}
}
leaf key-pair-ref {
description "A reference to the key pair entry in the global key pair table";
type leafref {
- path "/nsr:key-pair/nsr:name";
+ path "../../../../../key-pair/nsr:name";
}
}
}
}
}
- list key-pair {
- key "name";
- description "Used to configure the list of public keys to be injected as part
- of ns instantiation";
- leaf name {
- description "Name of this key pair";
- type string;
- }
-
- leaf key {
- description "Key associated with this key pair";
- type string;
- }
- }
-
augment "/rw-project:project" {
list key-pair {
key "name";
VALA_PACKAGES
rw_types-1.0 rw_yang-1.0 rw_keyspec-1.0 rw_yang_pb-1.0 rw_schema_proto-1.0
rw_log_yang-1.0 rw_base_yang-1.0 rwcal_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0
- rw_log-1.0 rw_project_yang-1.0
+ rw_log-1.0 rw_project_yang-1.0 rw_user_yang-1.0
VAPI_DIRS ${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang
${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang
${RIFT_SUBMODULE_BINARY_ROOT}/rwvcs/plugins/yang
class CopyStatusPublisher(mano_dts.DtsHandler, url_downloader.DownloaderProtocol):
- def __init__(self, log, dts, loop, tasklet_info):
- super().__init__(log, dts, loop)
- self.tasks = {}
- self.tasklet_info = tasklet_info
+ def __init__(self, log, dts, loop, project):
+ super().__init__(log, dts, loop, project)
+ self.tasks = {}
+ self.tasklet_info = project.tasklet.tasklet_info
def xpath(self, transaction_id=None):
- return ("D,/rw-pkg-mgmt:copy-jobs/rw-pkg-mgmt:job" +
+ return self.project.add_project("D,/rw-pkg-mgmt:copy-jobs/rw-pkg-mgmt:job" +
("[transaction-id='{}']".format(transaction_id) if transaction_id else ""))
pass
-
+
@asyncio.coroutine
def register(self):
self.reg = yield from self.dts.register(xpath=self.xpath(),
class SchemaRpcHandler(mano_dts.AbstractRpcHandler):
"""RPC handler to generate the schema for the packages.
"""
- def __init__(self, log, dts, loop, project, proxy):
+ def __init__(self, log, dts, loop, proxy):
"""
Args:
proxy: Any impl of .proxy.AbstractPackageManagerProxy
"""
- super().__init__(log, dts, loop, project)
+ super().__init__(log, dts, loop)
self.proxy = proxy
@property
from . import rpc
from .proxy import filesystem
from . import publisher as pkg_publisher
-from . import subscriber
+from . import subscriber
class PackageManagerProject(ManoProject):
args = [self.log, self.dts, self.loop, self]
self.job_handler = pkg_publisher.DownloadStatusPublisher(*args)
- self.copy_publisher = pkg_publisher.CopyStatusPublisher(*args + [self.tasklet.tasklet_info])
+ self.copy_publisher = pkg_publisher.CopyStatusPublisher(*args)
- # create catalog subscribers
+ # create catalog subscribers
self.vnfd_catalog_sub = subscriber.VnfdStatusSubscriber(*args)
self.nsd_catalog_sub = subscriber.NsdStatusSubscriber(*args)
-
+
args.append(proxy)
self.copy_rpc = rpc.PackageCopyOperationsRpcHandler(*(args + [self.copy_publisher]))
@asyncio.coroutine
def register (self):
- yield from self.vnfd_catalog_sub.register()
- yield from self.nsd_catalog_sub.register()
- yield from self.copy_rpc.register()
- yield from self.copy_publisher.register()
- yield from self.job_handler.register()
+ try:
+ yield from self.vnfd_catalog_sub.register()
+ yield from self.nsd_catalog_sub.register()
+ yield from self.copy_rpc.register()
+ yield from self.copy_publisher.register()
+ yield from self.job_handler.register()
+ except Exception as e:
+ self.log.exception("Exception registering project {}: {}".
+ format(self.name, e))
def deregister (self):
yield from self.job_handler.deregister()
yield from self.delete_rpc.register()
self.log.debug("creating project handler")
- self.project_handler = ProjectHandler(self, PackageManagerProject)
self.project_handler.register()
@asyncio.coroutine
rw_log_yang-1.0 rw_base_yang-1.0 rwcal_yang-1.0 rwsdnal_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0
ietf_network_yang-1.0 ietf_network_topology_yang-1.0
ietf_l2_topology_yang-1.0 rw_topology_yang-1.0
- rw_log-1.0 rw_project_yang-1.0
+ rw_log-1.0 rw_project_yang-1.0 rw_user_yang-1.0
VAPI_DIRS
${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang
${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang
VALA_PACKAGES
rw_types-1.0 rw_yang-1.0 rw_keyspec-1.0 rw_yang_pb-1.0 rw_schema_proto-1.0
rw_log_yang-1.0 rw_base_yang-1.0 rwmon_yang-1.0 rw_manifest_yang-1.0 protobuf_c-1.0 ietf_netconf_yang-1.0
- rw_log-1.0 rwcal_yang-1.0 rw_project_yang-1.0
+ rw_log-1.0 rwcal_yang-1.0 rw_project_yang-1.0 rw_user_yang-1.0
VAPI_DIRS ${RIFT_SUBMODULE_BINARY_ROOT}/rwmon/plugins/yang
${RIFT_SUBMODULE_BINARY_ROOT}/rwcal/plugins/yang
${RIFT_SUBMODULE_BINARY_ROOT}/models/plugins/yang
self.users = {}
self.pub = RoleConfigPublisher(project)
+ self.proj_roles = [role['mano-role'] for role in MANO_PROJECT_ROLES]
def get_xpath(self):
return "C,/{}[name='{}']/project-config/user".format(NS_PROJECT, self.project_name)
self._log.debug("User {}: on_prepare add request".
format(user.key))
+ for role in msg.mano_role:
+ if role.role not in self.proj_roles:
+ errmsg = "Invalid MANO role {} for user {}". \
+ format(role.role, user.key)
+ self._log.error(errmsg)
+ xact_info.send_error_xpath(RwTypes.RwStatus.FAILURE,
+ self.get_xpath(),
+ errmsg)
+ xact_info.respond_xpath(rwdts.XactRspCode.NACK)
+ return
+
elif action == rwdts.QueryAction.DELETE:
# Check if the user got deleted
fref = ProtobufC.FieldReference.alloc()