Exemplo n.º 1
0
    def create_service_volume(self, tenant, service, dep_vol):
        """
        raise ErrInvalidVolume
        raise ErrDepVolumeNotFound
        """
        tenant_service_volumes = volume_service.get_service_volumes(
            tenant, service)
        local_path = [l_path.volume_path for l_path in tenant_service_volumes]
        code, msg = volume_service.check_volume_path(service,
                                                     dep_vol["path"],
                                                     local_path=local_path)
        if code != 200:
            logger.debug("Service id: {0}; ingore mnt; msg: {1}".format(
                service.service_id, msg))
            raise ErrInvalidVolume(msg)

        dep_volume = volume_repo.get_service_volume_by_name(
            dep_vol["service_id"], dep_vol["volume_name"])
        if not dep_volume:
            raise ErrDepVolumeNotFound(dep_vol["service_id"],
                                       dep_vol["volume_name"])

        source_path = dep_vol['path'].strip()
        return mnt_repo.add_service_mnt_relation(tenant.tenant_id,
                                                 service.service_id,
                                                 dep_volume.service_id,
                                                 dep_volume.volume_name,
                                                 source_path)
Exemplo n.º 2
0
    def create_service_volume(self, tenant, service, dep_vol):
        """
        raise ErrInvalidVolume
        raise ErrDepVolumeNotFound
        """
        tenant_service_volumes = volume_service.get_service_volumes(
            tenant, service)
        local_path = [
            l_path["volume_path"] for l_path in tenant_service_volumes
        ]
        volume_service.check_volume_path(service,
                                         dep_vol["path"],
                                         local_path=local_path)

        dep_volume = volume_repo.get_service_volume_by_name(
            dep_vol["service_id"], dep_vol["volume_name"])
        if not dep_volume:
            raise ErrDepVolumeNotFound(dep_vol["service_id"],
                                       dep_vol["volume_name"])

        source_path = dep_vol['path'].strip()
        return mnt_repo.add_service_mnt_relation(tenant.tenant_id,
                                                 service.service_id,
                                                 dep_volume.service_id,
                                                 dep_volume.volume_name,
                                                 source_path)