"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "openstack_dashboard/dashboards/project/instances/utils.py" between
horizon-20.1.1.tar.gz and horizon-20.1.2.tar.gz

About: OpenStack Horizon (Optional Service: Dashboard) provides a web-based self-service portal to interact with underlying OpenStack services, such as launching an instance, assigning IP addresses and configuring access controls.
The "Xena" series (latest release).

utils.py  (horizon-20.1.1):utils.py  (horizon-20.1.2)
skipping to change at line 13 skipping to change at line 13
# a copy of the License at # a copy of the License at
# #
# 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, WITHOUT # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations # License for the specific language governing permissions and limitations
# under the License. # under the License.
from collections import namedtuple
import logging import logging
from operator import itemgetter from operator import itemgetter
from django.conf import settings from django.conf import settings
from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ugettext_lazy as _
from horizon import exceptions from horizon import exceptions
from openstack_dashboard import api from openstack_dashboard import api
skipping to change at line 227 skipping to change at line 228
:param request: django http request object :param request: django http request object
:return: list of (id, name) tuples :return: list of (id, name) tuples
""" """
server_groups = server_group_list(request) server_groups = server_group_list(request)
if server_groups: if server_groups:
server_groups_list = [(sg.id, sg.name) for sg in server_groups] server_groups_list = [(sg.id, sg.name) for sg in server_groups]
server_groups_list.sort(key=lambda obj: obj[1]) server_groups_list.sort(key=lambda obj: obj[1])
return [("", _("Select Server Group")), ] + server_groups_list return [("", _("Select Server Group")), ] + server_groups_list
return [("", _("No server groups available")), ] return [("", _("No server groups available")), ]
def resolve_flavor(request, instance, flavors=None, **kwargs):
"""Resolves name of instance flavor independent of API microversion
:param request: django http request object
:param instance: api._nova.Server instance to resolve flavor
:param flavors: dict of flavors already retrieved
:param kwargs: flavor parameters to return if hit some flavor discrepancy
:return: flavor name or default placeholder
"""
def flavor_from_dict(flavor_dict):
"""Creates flavor-like objects from dictionary
:param flavor_dict: dictionary contains vcpu, ram, name, etc. values
:return: novaclient.v2.flavors.Flavor like object
"""
return namedtuple('Flavor', flavor_dict.keys())(*flavor_dict.values())
if flavors is None:
flavors = {}
flavor_id = instance.flavor.get('id')
if flavor_id: # Nova API <=2.46
if flavor_id in flavors:
return flavors[flavor_id]
try:
return api.nova.flavor_get(request, flavor_id)
except Exception:
msg = _('Unable to retrieve flavor information '
'for instance "%s".') % instance.id
exceptions.handle(request, msg, ignore=True)
fallback_flavor = {
'vcpus': 0, 'ram': 0, 'disk': 0, 'ephemeral': 0, 'swap': 0,
'name': _('Not available'),
'original_name': _('Not available'),
'extra_specs': {},
}
fallback_flavor.update(kwargs)
return flavor_from_dict(fallback_flavor)
else:
instance.flavor['name'] = instance.flavor['original_name']
return flavor_from_dict(instance.flavor)
 End of changes. 2 change blocks. 
0 lines changed or deleted 1 lines changed or added

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