def index(request): for f in (TerminateInstance, RebootInstance): _, handled = f.maybe_handle(request) if handled: return handled instances = [] try: instances = api.admin_server_list(request) except Exception as e: LOG.exception('Unspecified error in instance index') messages.error(request, _('Unable to get instance list: %s') % e.message) # We don't have any way of showing errors for these, so don't bother # trying to reuse the forms from above terminate_form = TerminateInstance() reboot_form = RebootInstance() return render_to_response( 'django_openstack/syspanel/instances/index.html', { 'instances': instances, 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request))
def refresh(request): for f in (TerminateInstance, RebootInstance): form, handled = f.maybe_handle(request) if handled: return handled instances = [] try: instances = api.admin_server_list(request) except Exception as e: messages.error(request, _('Unable to get instance list: %s') % e.message) # We don't have any way of showing errors for these, so don't bother # trying to reuse the forms from above terminate_form = TerminateInstance() reboot_form = RebootInstance() return render_to_response( 'django_openstack/syspanel/instances/_list.html', { 'instances': instances, 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request))
def index(request): for f in (TerminateInstance, RebootInstance): _, handled = f.maybe_handle(request) if handled: return handled #added contented starts #(date_start, date_end, datetime_start, datetime_end) = \ # _get_start_and_end_date(request) #(unit_flag, unit_cost) = get_unitCost(request, date_start) #instances = [] #added end try: instances = api.admin_server_list(request) # for instance in instances : #added # LOG.info('-----Instance---%s--++%s-\n' %(instance.attrs.__dict__ , unit_cost.__dict__)) #added except Exception as e: LOG.exception('Unspecified error in instance index') messages.error(request, 'Unable to get instance list: %s' % e.message) # We don't have any way of showing errors for these, so don't bother # trying to reuse the forms from above terminate_form = TerminateInstance() reboot_form = RebootInstance() return render_to_response( 'django_openstack/syspanel/instances/index.html', { 'instances': instances, 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request))
def _add_record_for_active_instance(self): now = datetime.now() instances = [] try: instances = api.admin_server_list(self.request) except Exception as e: LOG.error('Unspecified error in instance index', exc_info=True) messages.error(request, 'Unable to get instance list: %s' % e.message) for instance in instances: if instance.status == 'ACTIVE': self._add_record(instance.attrs.tenant_id, PriceList.ACTIVE_INSTANCE, 'instance %s is running at %s' % (instance.id,now))
def _add_record_for_active_instance(self): now = datetime.now() instances = [] try: instances = api.admin_server_list(self.request) except Exception as e: LOG.error('Unspecified error in instance index', exc_info=True) messages.error(request, 'Unable to get instance list: %s' % e.message) for instance in instances: if instance.status == 'ACTIVE': self._add_record( instance.attrs.tenant_id, self.price_list.active_instance_price( instance.attrs.vcpus, instance.attrs.memory_mb), 'instance %s is running at %s' % (instance.id, now))
def refresh(request): for f in (TerminateInstance, RebootInstance): _, handled = f.maybe_handle(request) if handled: return handled instances = [] try: instances = api.admin_server_list(request) except Exception as e: messages.error(request, 'Unable to get instance list: %s' % e.message) # We don't have any way of showing errors for these, so don't bother # trying to reuse the forms from above terminate_form = TerminateInstance() reboot_form = RebootInstance() return render_to_response('_syspanel_instance_list.html', { 'instances': instances, 'terminate_form': terminate_form, 'reboot_form': reboot_form, }, context_instance=template.RequestContext(request))