"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sahara/utils/openstack/cinder.py" between
sahara-14.0.0.tar.gz and sahara-15.0.0.tar.gz

About: OpenStack Sahara provides an ability to provision, start, shutdown, scale Hadoop cluster on OpenStack.
The "Xena" series (latest release).

cinder.py  (sahara-14.0.0):cinder.py  (sahara-15.0.0)
skipping to change at line 18 skipping to change at line 18
# #
# http://www.apache.org/licenses/LICENSE-2.0 # http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software # Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, # distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
# implied. # implied.
# See the License for the specific language governing permissions and # See the License for the specific language governing permissions and
# limitations under the License. # limitations under the License.
from cinderclient.v2 import client as cinder_client_v2
from cinderclient.v3 import client as cinder_client_v3 from cinderclient.v3 import client as cinder_client_v3
from keystoneauth1 import exceptions as keystone_exceptions from keystoneauth1 import exceptions as keystone_exceptions
from oslo_config import cfg from oslo_config import cfg
from oslo_log import log as logging from oslo_log import log as logging
from sahara import context from sahara import context
from sahara.service import sessions from sahara.service import sessions
from sahara.utils.openstack import base from sahara.utils.openstack import base
from sahara.utils.openstack import keystone from sahara.utils.openstack import keystone
skipping to change at line 54 skipping to change at line 53
] ]
cinder_group = cfg.OptGroup(name='cinder', cinder_group = cfg.OptGroup(name='cinder',
title='Cinder client options') title='Cinder client options')
CONF = cfg.CONF CONF = cfg.CONF
CONF.register_group(cinder_group) CONF.register_group(cinder_group)
CONF.register_opts(opts, group=cinder_group) CONF.register_opts(opts, group=cinder_group)
def validate_config(): def validate_config():
if CONF.cinder.api_version == 2: if CONF.cinder.api_version != 3:
LOG.warning('The Cinder v2 API is deprecated. You should set '
'cinder.api_version=3 in your sahara.conf file.')
elif CONF.cinder.api_version != 3:
LOG.warning('Unsupported Cinder API version: {bad}. Please set a ' LOG.warning('Unsupported Cinder API version: {bad}. Please set a '
'correct value for cinder.api_version in your ' 'correct value for cinder.api_version in your '
'sahara.conf file (currently supported versions are: ' 'sahara.conf file (currently supported versions are: '
'{supported}). Falling back to Cinder API version 3.' '{supported}). Falling back to Cinder API version 3.'
.format(bad=CONF.cinder.api_version, .format(bad=CONF.cinder.api_version,
supported=[2, 3])) supported=[3]))
CONF.set_override('api_version', 3, group='cinder') CONF.set_override('api_version', 3, group='cinder')
def client(): def client():
session = sessions.cache().get_session(sessions.SESSION_TYPE_CINDER) session = sessions.cache().get_session(sessions.SESSION_TYPE_CINDER)
auth = keystone.auth() auth = keystone.auth()
if CONF.cinder.api_version == 2: cinder = cinder_client_v3.Client(
cinder = cinder_client_v2.Client( session=session, auth=auth,
session=session, auth=auth, endpoint_type=CONF.cinder.endpoint_type,
endpoint_type=CONF.cinder.endpoint_type, region_name=CONF.os_region_name)
region_name=CONF.os_region_name)
else:
cinder = cinder_client_v3.Client(
session=session, auth=auth,
endpoint_type=CONF.cinder.endpoint_type,
region_name=CONF.os_region_name)
return cinder return cinder
def check_cinder_exists(): def check_cinder_exists():
if CONF.cinder.api_version == 2: service_type = 'volumev3'
service_type = 'volumev2'
else:
service_type = 'volumev3'
try: try:
base.url_for(context.current().service_catalog, service_type, base.url_for(context.current().service_catalog, service_type,
endpoint_type=CONF.cinder.endpoint_type) endpoint_type=CONF.cinder.endpoint_type)
return True return True
except keystone_exceptions.EndpointNotFound: except keystone_exceptions.EndpointNotFound:
return False return False
def get_volume(volume_id): def get_volume(volume_id):
return base.execute_with_retries(client().volumes.get, volume_id) return base.execute_with_retries(client().volumes.get, volume_id)
 End of changes. 5 change blocks. 
20 lines changed or deleted 7 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)