Exemple #1
0
    def on_link_request_prepare(self, xact_info, action, ks_path, request_msg):
        if not self._registered:
            self._log.error("Got a prepare callback when not registered!")
            xact_info.respond_xpath(rwdts.XactRspCode.NA)
            return

        self._log.debug("Received virtual-link on_prepare callback (self: %s, xact_info: %s, action: %s): %s",
                        self, xact_info, action, request_msg)

        response_info = None
        response_xpath = ks_path.to_xpath(RwResourceMgrYang.get_schema()) + "/resource-info"

        schema = RwResourceMgrYang.VirtualLinkEventData().schema()
        pathentry = schema.keyspec_to_entry(ks_path)

        if action == rwdts.QueryAction.CREATE:
            response_info = self._allocate_virtual_network(
                    pathentry.key00.event_id,
                    request_msg.request_info,
                    )

        elif action == rwdts.QueryAction.DELETE:
            self._release_virtual_network(pathentry.key00.event_id)

        elif action == rwdts.QueryAction.READ:
            response_info = self._read_virtual_network(
                    pathentry.key00.event_id
                    )
        else:
            raise ValueError("Only read/create/delete actions available. Received action: %s" %(action))

        self._log.debug("Responding with VirtualLinkInfo at xpath %s: %s.",
                        response_xpath, response_info)

        xact_info.respond_xpath(rwdts.XactRspCode.ACK, response_xpath, response_info)
Exemple #2
0
    def get_network_reserve_msg(self, name, cloud_type, xpath):
        event_id = str(uuid.uuid4())
        msg = rmgryang.VirtualLinkEventData()
        msg.event_id = event_id
        msg.request_info.name = name
        attributes = ['physical_network', 'name', 'overlay_type', 'segmentation_id']

        for attr in attributes:
            if resource_requests[cloud_type]['network'][name].has_field('provider_network'):
                if resource_requests[cloud_type]['network'][name].provider_network.has_field(attr):
                    setattr(msg.request_info.provider_network, attr,
                            getattr(resource_requests[cloud_type]['network'][name].provider_network ,attr))
                
        return msg, xpath.format(event_id)
Exemple #3
0
        def on_link_request_prepare(xact_info, action, ks_path, request_msg):
            self._log.debug(
                "Received virtual-link on_prepare callback (xact_info: %s, action: %s): %s",
                xact_info, action, request_msg)

            response_info = None
            response_xpath = ks_path.to_xpath(
                RwResourceMgrYang.get_schema()) + "/resource-info"

            schema = RwResourceMgrYang.VirtualLinkEventData().schema()
            pathentry = schema.keyspec_to_entry(ks_path)

            if action == rwdts.QueryAction.CREATE:
                response_info = yield from self._parent.allocate_virtual_network(
                    pathentry.key00.event_id, request_msg.cloud_account,
                    request_msg.request_info)
                request_msg.resource_info = response_info
                self.create_record_dts(
                    self._link_reg, None,
                    ks_path.to_xpath(RwResourceMgrYang.get_schema()),
                    request_msg)
            elif action == rwdts.QueryAction.DELETE:
                yield from self._parent.release_virtual_network(
                    pathentry.key00.event_id)
                self.delete_record_dts(
                    self._link_reg, None,
                    ks_path.to_xpath(RwResourceMgrYang.get_schema()))
            elif action == rwdts.QueryAction.READ:
                response_info = yield from self._parent.read_virtual_network_info(
                    pathentry.key00.event_id)
            else:
                raise ValueError(
                    "Only read/create/delete actions available. Received action: %s"
                    % (action))

            self._log.debug("Responding with VirtualLinkInfo at xpath %s: %s.",
                            response_xpath, response_info)

            xact_info.respond_xpath(rwdts.XactRspCode.ACK, response_xpath,
                                    response_info)