Beispiel #1
0
    def _set_version(self, msg, vers):
        """Helper method to set the version in a message.

        :param msg: The message having a version added to it.
        :param vers: The version number to add to the message.
        """
        v = vers if vers else self.default_version
        if (self.version_cap
                and not rpc_common.version_is_compatible(self.version_cap, v)):
            raise rpc_common.RpcVersionCapError(version=self.version_cap)
        msg['version'] = v
Beispiel #2
0
    def block_device_mapping_get_all_by_instance(self, context, instance,
                                                 legacy=True):
        instance_p = jsonutils.to_primitive(instance)
        if self.can_send_version('1.51'):
            version = '1.51'
            msg = self.make_msg('block_device_mapping_get_all_by_instance',
                                instance=instance_p, legacy=legacy)
        elif legacy:
            # If the remote side is >= 1.51, it defaults to legacy=True.
            # If it's older, it only understands the legacy format.
            version = '1.13'
            msg = self.make_msg('block_device_mapping_get_all_by_instance',
                                instance=instance_p)
        else:
            # If we require new style data, but can't ask for it, then we must
            # fail here.
            raise rpc_common.RpcVersionCapError(version_cap=self.version_cap)

        return self.call(context, msg, version=version)
Beispiel #3
0
    def block_device_mapping_get_all_by_instance(self, context, instance,
                                                 legacy=True):
        instance_p = jsonutils.to_primitive(instance)
        if self.client.can_send_version('1.51'):
            version = '1.51'
            kwargs = {'legacy': legacy}
        elif legacy:
            # If the remote side is >= 1.51, it defaults to legacy=True.
            # If it's older, it only understands the legacy format.
            version = '1.13'
            kwargs = {}
        else:
            # If we require new style data, but can't ask for it, then we must
            # fail here.
            raise rpc_common.RpcVersionCapError(version_cap=self.version_cap)

        cctxt = self.client.prepare(version=version)
        return cctxt.call(context, 'block_device_mapping_get_all_by_instance',
                          instance=instance_p, **kwargs)