Commit c58dc250 authored by Kostas Vogias's avatar Kostas Vogias Committed by Stavros Sachtouris

Make storage methods activation aware

parent 5ecc5c53
......@@ -13,6 +13,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
from soi.config import VOLUME_TYPE
from soi.utils import check_activation
def _openstackify_volumes_info(volumes):
......@@ -25,6 +26,7 @@ def _openstackify_volumes_info(volumes):
attachment['volumeId'] = attachment['volume_id']
@check_activation
def snf_get_volumes(cls, req):
"""Synnefo: list volumes"""
req.environ['service_type'] = 'volume'
......@@ -44,6 +46,7 @@ def _openstackify_volume_display_name(response):
response['displayName'] = response['display_name']
@check_activation
def snf_get_volume_info(cls, req, volume_id):
"""Synnefo: Get volume info"""
req.environ['service_type'] = 'volume'
......@@ -55,6 +58,7 @@ def snf_get_volume_info(cls, req, volume_id):
return r
@check_activation
def snf_create_volume(cls, req, name, size):
"""Synnefo: Create a volume"""
project_id = req.environ.get('HTTP_X_PROJECT_ID', None)
......@@ -74,6 +78,7 @@ def snf_create_volume(cls, req, name, size):
return snf_get_volume_info(cls, req, r['id'])
@check_activation
def snf_delete_volume(cls, req, volume_id):
"""Synnefo:Delete a volume"""
req.environ['service_type'] = 'volume'
......
......@@ -13,7 +13,7 @@
# You should have received a copy of the GNU General Public License
from soi.tests import fakes
from soi import storage
from soi import storage, config
from mock import patch
......@@ -67,6 +67,8 @@ def test_openstackify_volumes_info():
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_get_volumes(gr, gfr, _ovdns):
"""Test snf_get_volumes method"""
DISABLED_METHODS = ()
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
storage.snf_get_volumes(cls, req)
assert req.environ == dict(
......@@ -92,6 +94,8 @@ def test_openstackify_volume_display_name():
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_get_volume(gr, gfr, _ovdn):
"""Test snd_get_volume method"""
DISABLED_METHODS = ()
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
volume_id = 'volume_id'
storage.snf_get_volume_info(cls, req, volume_id)
......@@ -111,6 +115,8 @@ def test_snf_get_volume(gr, gfr, _ovdn):
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_create_volume(gr, gfr, gvi):
"""Test snf_create_volume method"""
DISABLED_METHODS = ()
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
project_id = 'a project id'
name, size = 'OCCI Volume', '100'
......@@ -131,6 +137,8 @@ def test_snf_create_volume(gr, gfr, gvi):
@patch('soi.tests.fakes.FakeReq.get_response', return_value='my response')
def test_snf_delete_volume(gr):
"""Test snf_delete_volume """
DISABLED_METHODS = ()
setattr(config, 'DISABLED_METHODS', DISABLED_METHODS)
cls, req = fakes.DummyClass(), fakes.FakeReq()
volume_id = 'a volume id'
storage.snf_delete_volume(cls, req, volume_id)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment