Commit 215075e2 by Szeberényi Imre

unicode->bytes fix:

  using unicode as it was used in the 2.7 version and
  adding ptyhon 2 & 3 compatible init snipet
introducing celeryconfig.py
parent ae937cd9
......@@ -8,6 +8,11 @@ from django.core.exceptions import ImproperlyConfigured
from ..models import Level, AclBase
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
def create_levels(app_config, verbosity=False, using=DEFAULT_DB_ALIAS,
**kwargs):
......@@ -61,10 +66,10 @@ def create_levels(app_config, verbosity=False, using=DEFAULT_DB_ALIAS,
]
Level.objects.using(using).bulk_create(levels)
if verbosity >= 2:
print(("Adding levels [%s]." % ", ".join(bytes(l) for l in levels)))
print(("Adding levels [%s]." % ", ".join(unicode(l) for l in levels)))
print(("Searched: [%s]." % ", ".join(
bytes(l) for l in searched_levels)))
print(("All: [%s]." % ", ".join(bytes(l) for l in all_levels)))
unicode(l) for l in searched_levels)))
print(("All: [%s]." % ", ".join(unicode(l) for l in all_levels)))
# set weights
for ctype, codename, weight in level_weights:
......
......@@ -26,6 +26,14 @@ from django.db.models import (
ManyToManyField, ForeignKey, CharField, Model, IntegerField, Q
)
from django.db import models
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -40,7 +48,7 @@ class Level(Model):
weight = IntegerField('weight', null=True)
def __str__(self):
return "<%s/%s>" % (bytes(self.content_type), self.name)
return "<%s/%s>" % (unicode(self.content_type), self.name)
class Meta:
app_label = 'acl'
......@@ -61,7 +69,7 @@ class ObjectLevel(Model):
groups = ManyToManyField(Group)
def __str__(self):
return "<%s: %s>" % (bytes(self.content_object), bytes(self.level))
return "<%s: %s>" % (unicode(self.content_object), unicode(self.level))
class Meta:
app_label = 'acl'
......@@ -143,7 +151,7 @@ class AclBase(Model):
:type level: str or unicode
"""
logger.info('%s.set_group_level(%s, %s) called',
*[bytes(p) for p in [self, group, level]])
*[unicode(p) for p in [self, group, level]])
if level is None:
pk = None
else:
......@@ -160,7 +168,7 @@ class AclBase(Model):
i.save()
def has_level(self, user, level, group_also=True):
# logger.debug('%s.has_level(%s, %s, %s) called', *[bytes(p) for p in [self, user, level, group_also]])
# logger.debug('%s.has_level(%s, %s, %s) called', *[unicode(p) for p in [self, user, level, group_also]])
if user is None or not user.is_authenticated:
return False
if getattr(user, 'is_superuser', False):
......@@ -168,7 +176,7 @@ class AclBase(Model):
return True
if isinstance(level, str):
level = self.get_level_object(level)
logger.debug("- level set by str: %s", bytes(level))
logger.debug("- level set by str: %s", unicode(level))
object_levels = self.object_level_set.filter(
level__weight__gte=level.weight).all()
......@@ -181,7 +189,7 @@ class AclBase(Model):
return False
def get_users_with_level(self, **kwargs):
# logger.debug('%s.get_users_with_level() called', bytes(self))
# logger.debug('%s.get_users_with_level() called', unicode(self))
object_levels = (self.object_level_set.filter(**kwargs).select_related(
'level').prefetch_related('users').all())
users = []
......@@ -193,7 +201,7 @@ class AclBase(Model):
return users
def get_groups_with_level(self):
# logger.debug('%s.get_groups_with_level() called', bytes(self))
# logger.debug('%s.get_groups_with_level() called', unicode(self))
object_levels = (self.object_level_set.select_related(
'level').prefetch_related('groups').all())
groups = []
......@@ -208,7 +216,7 @@ class AclBase(Model):
def get_objects_with_level(cls, level, user,
group_also=True, owner_also=False,
disregard_superuser=False):
# logger.debug('%s.get_objects_with_level(%s,%s) called', str(cls), bytes(level), bytes(user))
# logger.debug('%s.get_objects_with_level(%s,%s) called', str(cls), unicode(level), unicode(user))
if user is None or not user.is_authenticated:
return cls.objects.none()
if getattr(user, 'is_superuser', False) and not disregard_superuser:
......@@ -216,7 +224,7 @@ class AclBase(Model):
return cls.objects.all()
if isinstance(level, str):
level = cls.get_level_object(level)
# logger.debug("- level set by str: %s", bytes(level))
# logger.debug("- level set by str: %s", unicode(level))
ct = ContentType.objects.get_for_model(cls)
levelfilter = Q(users=user)
......
CELERY_RESULT_BACKEND = 'amqp://'
CELERY_TASK_RESULT_EXPIRES = 300
CELERY_TIMEZONE = 'UTC'
CELERY_ENABLE_UTC = True
CELERY_ACCEPT_CONTENT = ['pickle', 'json', 'msgpack', 'yaml']
......@@ -14,8 +14,8 @@ def update_permissions_after_migration(sender, **kwargs):
from django.conf import settings
from django.apps import apps
from django.contrib.auth.management import create_permissions
create_permissions(sender, apps.get_models(), 2 if settings.DEBUG else 0)
v = 2 if settings.DEBUG else 0
create_permissions(sender, v, apps.get_models())
post_migrate.connect(update_permissions_after_migration)
......@@ -84,7 +84,8 @@ def activitycontextimpl(act, on_abort=None, on_commit=None):
raise
except:
logger.exception("Failed activity %s" % str(act))
handler = None if on_abort is None else lambda a: on_abort(a, e)
handler = None
# handler = None if on_abort is None else lambda a: on_abort(a, e)
act.finish(succeeded=False, result=result, event_handler=handler)
raise
else:
......
......@@ -51,6 +51,14 @@ from vm.models.instance import ACCESS_METHODS
from .store_api import Store, NoStoreException, NotOkException
from .validators import connect_command_template_validator
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = getLogger(__name__)
......@@ -420,11 +428,11 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
value = attributes[atr][0].upper()
except Exception as e:
value = None
logger.info("save_org_id couldn't find attribute. %s", bytes(e))
logger.info("save_org_id couldn't find attribute. %s", unicode(e))
if instance.pk is None:
instance.save()
logger.debug("save_org_id saved user %s", bytes(instance))
logger.debug("save_org_id saved user %s", unicode(instance))
profile, created = Profile.objects.get_or_create(user=instance)
if created or profile.org_id != value:
......@@ -444,7 +452,7 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
logger.debug('cant find membergroup %s', group)
else:
logger.debug('could find membergroup %s (%s)',
group, bytes(g))
group, unicode(g))
g.user_set.add(instance)
for i in FutureMember.objects.filter(org_id__iexact=value):
......@@ -460,7 +468,7 @@ if hasattr(settings, 'SAML_ORG_ID_ATTRIBUTE'):
logger.debug('cant find ownergroup %s', group)
else:
logger.debug('could find ownergroup %s (%s)',
group, bytes(g))
group, unicode(g))
g.profile.set_level(instance, 'owner')
return False # User did not change
......
......@@ -28,6 +28,12 @@ from sizefield.utils import filesizeformat
from storage.models import Disk
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -81,7 +87,7 @@ class Store(object):
timeout=timeout, **self.request_args)
except Exception:
logger.exception("Error in store %s loading %s",
bytes(method), url)
unicode(method), url)
raise
else:
if raise_status_code and response.status_code != codes.ok:
......
......@@ -28,6 +28,13 @@ from manager.mancelery import celery
from ..models import Notification
from ..views import UnsubscribeFormView
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -46,7 +53,7 @@ def send_email_notifications():
for user, msgs in list(recipients.items()):
if (not user.profile or not user.email or not
user.profile.email_notifications):
logger.debug("%s gets no notifications", bytes(user))
logger.debug("%s gets no notifications", unicode(user))
continue
with override(user.profile.preferred_language):
context = {'user': user.profile, 'messages': msgs,
......@@ -67,7 +74,7 @@ def send_email_notifications():
logger.error("Failed to send mail to %s", user, exc_info=True)
else:
logger.info("Delivered notifications %s",
" ".join(bytes(i.pk) for i in msgs))
" ".join(unicode(i.pk) for i in msgs))
for i in msgs:
i.status = i.STATUS.delivered
i.save()
......@@ -22,6 +22,11 @@ from django.test import TestCase
from ..models import Profile
from ..views import search_user
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
class NotificationTestCase(TestCase):
......@@ -40,8 +45,8 @@ class NotificationTestCase(TestCase):
{'var': 'testme'})
assert self.u1.notification_set.count() == c1 + 1
assert self.u2.notification_set.count() == c2
assert 'user1' in bytes(msg.message)
assert 'testme' in bytes(msg.message)
assert 'user1' in unicode(msg.message)
assert 'testme' in unicode(msg.message)
assert msg in self.u1.notification_set.all()
......
......@@ -26,6 +26,11 @@ from django.http import HttpResponse
from ..views import AclUpdateView
from ..models import Profile
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
def highlight(field, q, none_wo_match=True):
"""
......@@ -59,7 +64,7 @@ class AclUserAutocomplete(autocomplete.Select2ListView):
if self.q:
condition = Q()
for field in search_fields:
condition |= Q(**{field + '__icontains': bytes(self.q)})
condition |= Q(**{field + '__icontains': unicode(self.q)})
return list(qs.filter(condition))
return []
......@@ -68,8 +73,8 @@ class AclUserAutocomplete(autocomplete.Select2ListView):
return self.filter(users, self.search_fields)
def choice_displayed_text(self, choice):
q = bytes(self.request.GET.get('q', ''))
name = highlight(bytes(choice), q, False)
q = unicode(self.request.GET.get('q', ''))
name = highlight(unicode(choice), q, False)
if isinstance(choice, User):
extra_fields = [highlight(choice.get_full_name(), q, False),
highlight(choice.email, q)]
......@@ -84,7 +89,7 @@ class AclUserAutocomplete(autocomplete.Select2ListView):
def get(self, *args, **kwargs):
return HttpResponse(json.dumps({
'results': [dict(id=bytes(r), text=self.choice_displayed_text(r))
'results': [dict(id=unicode(r), text=self.choice_displayed_text(r))
for r in self.get_list()]
}), content_type="application/json")
......
......@@ -46,6 +46,12 @@ from ..models import FutureMember, GroupProfile
from ..store_api import Store, NoStoreException
from ..tables import GroupListTable
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -217,7 +223,7 @@ class GroupList(LoginRequiredMixin, SingleTableView):
return super(GroupList, self).get(*args, **kwargs)
def get_queryset(self):
# logger.debug('GroupList.get_queryset() called. User: %s', bytes(self.request.user))
# logger.debug('GroupList.get_queryset() called. User: %s', unicode(self.request.user))
profiles = GroupProfile.get_objects_with_level(
'operator', self.request.user)
groups = Group.objects.filter(groupprofile__in=profiles)
......
......@@ -38,6 +38,14 @@ from braces.views import LoginRequiredMixin
from ..store_api import (Store, NoStoreException,
NotOkException)
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -75,7 +83,7 @@ class StoreList(LoginRequiredMixin, TemplateView):
messages.warning(self.request, _("Store has some problems now."
" Try again later."))
except Exception as e:
logger.critical("Something is wrong with store: %s", bytes(e))
logger.critical("Something is wrong with store: %s", unicode(e))
messages.warning(self.request, _("Unknown store error."))
return redirect("/")
......@@ -183,7 +191,7 @@ def store_new_directory(request):
Store(request.user).new_folder(join(path, name))
except Exception:
logger.exception("Unable to create folder %s in %s for %s",
name, path, bytes(request.user))
name, path, unicode(request.user))
messages.error(request, _("Unable to create folder."))
return redirect("%s?directory=%s" % (
reverse("dashboard.views.store-list"), urlencode(path)))
......@@ -199,7 +207,7 @@ def store_refresh_toplist(request):
quota = store.get_quota()
files = {'toplist': toplist, 'quota': quota}
except Exception:
logger.exception("Can't get toplist of %s", bytes(request.user))
logger.exception("Can't get toplist of %s", unicode(request.user))
files = {'toplist': []}
cache.set(cache_key, files, 300)
......
......@@ -56,6 +56,18 @@ from .util import (
GraphMixin
)
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -272,7 +284,7 @@ class TemplateList(LoginRequiredMixin, FilterMixin, SingleTableView):
return queryset
def get_queryset(self):
# logger.debug('TemplateList.get_queryset() called. User: %s', bytes(self.request.user))
logger.debug('TemplateList.get_queryset() called. User: %s', unicode(self.request.user))
qs = self.create_acl_queryset(InstanceTemplate)
self.create_fake_get()
......
......@@ -59,6 +59,11 @@ from ..tables import (
from .util import saml_available, DeleteViewBase, LoginView
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -153,14 +158,14 @@ class TokenLogin(View):
try:
data = signing.loads(token, salt=self.get_salt(),
max_age=self.token_max_age)
logger.debug('TokenLogin token data: %s', bytes(data))
logger.debug('TokenLogin token data: %s', unicode(data))
sudoer, user = data
logger.debug('Extracted TokenLogin data: sudoer: %s, user: %s',
bytes(sudoer), bytes(user))
unicode(sudoer), unicode(user))
except (signing.BadSignature, ValueError, TypeError) as e:
logger.warning('Tried invalid TokenLogin token. '
'Token: %s, user: %s. %s',
token, bytes(self.request.user), bytes(e))
token, unicode(self.request.user), unicode(e))
raise SuspiciousOperation()
sudoer = User.objects.get(pk=sudoer)
if not sudoer.is_superuser:
......@@ -168,9 +173,9 @@ class TokenLogin(View):
user = User.objects.get(pk=user)
user.backend = 'django.contrib.auth.backends.ModelBackend'
logger.warning('%s %d logged in as user %s %d',
bytes(sudoer), sudoer.pk, bytes(user), user.pk)
unicode(sudoer), sudoer.pk, unicode(user), user.pk)
login(request, user)
messages.info(request, _("Logged in as user %s.") % bytes(user))
messages.info(request, _("Logged in as user %s.") % unicode(user))
return redirect("/")
......@@ -253,7 +258,7 @@ class UnsubscribeFormView(SuccessMessageMixin, UpdateView):
@classmethod
def get_salt(cls):
return bytes(cls)
return unicode(cls)
@classmethod
def get_token(cls, user):
......@@ -267,7 +272,7 @@ class UnsubscribeFormView(SuccessMessageMixin, UpdateView):
raise
except (signing.BadSignature, ValueError, TypeError) as e:
logger.warning('Tried invalid token. Token: %s, user: %s. %s',
key, bytes(self.request.user), bytes(e))
key, unicode(self.request.user), unicode(e))
raise Http404
else:
return (queryset or self.get_queryset()).get(user_id=pk)
......@@ -561,7 +566,7 @@ class UserList(LoginRequiredMixin, PermissionRequiredMixin, SingleTableView):
return super(UserList, self).get(*args, **kwargs)
def get_queryset(self):
# logger.debug('UserList.get_queryset() called. User: %s', bytes(self.request.user))
# logger.debug('UserList.get_queryset() called. User: %s', unicode(self.request.user))
qs = User.objects.all().order_by("-pk")
q = self.search_form.cleaned_data.get('s')
......
......@@ -56,6 +56,13 @@ from ..models import GroupProfile, Profile
from ..forms import TransferOwnershipForm
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
saml_available = hasattr(settings, "SAML_CONFIG")
......@@ -274,7 +281,7 @@ class OperationView(RedirectToLoginMixin, DetailView):
return ctx
def check_auth(self):
#logger.debug("OperationView.check_auth(%s)", bytes(self))
logger.debug("OperationView.check_auth(%s)", unicode(self))
self.get_op().check_auth(self.request.user)
@classmethod
......@@ -374,7 +381,7 @@ class AjaxOperationMixin(object):
store = []
return JsonResponse({'success': True,
'with_reload': self.with_reload,
'messages': [bytes(m) for m in store]})
'messages': [str(m) for m in store]})
else:
return resp
......@@ -511,23 +518,23 @@ class AclUpdateView(LoginRequiredMixin, View, SingleObjectMixin):
if getattr(self.instance, "owner", None) == whom:
logger.info("Tried to set owner's acl level for %s by %s.",
bytes(self.instance), bytes(user))
unicode(self.instance), unicode(user))
msg = _("The original owner cannot be removed, however "
"you can transfer ownership.")
if not getattr(self, 'hide_messages', False):
messages.warning(self.request, msg)
elif self.check_auth(whom, old_level, new_level):
logger.info(
"Set %s's acl level for %s to %s by %s.", bytes(whom),
bytes(self.instance), new_level, bytes(user))
"Set %s's acl level for %s to %s by %s.", unicode(whom),
unicode(self.instance), new_level, unicode(user))
if not getattr(self, 'hide_messages', False):
self.send_success_message(whom, old_level, new_level)
self.instance.set_level(whom, new_level)
else:
logger.warning(
"Tried to set %s's acl_level for %s (%s->%s) by %s.",
bytes(whom), bytes(self.instance), old_level, new_level,
bytes(user))
unicode(whom), unicode(self.instance), old_level, new_level,
unicode(user))
def set_or_remove_levels(self):
for key, value in list(self.request.POST.items()):
......@@ -654,7 +661,7 @@ class TransferOwnershipView(CheckedDetailView, DetailView):
else:
messages.success(request,
_('User %s is notified about the offer.') % (
bytes(new_owner), ))
unicode(new_owner), ))
return redirect(obj.get_absolute_url())
......@@ -667,7 +674,7 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
@classmethod
def get_salt(cls):
return bytes(cls) + bytes(cls.model)
return unicode(cls) + unicode(cls.model)
def get(self, request, key, *args, **kwargs):
"""Confirm ownership transfer based on token.
......@@ -698,7 +705,7 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
self.change_owner(instance, request.user)
messages.success(request, self.success_message)
logger.info('Ownership of %s transferred from %s to %s.',
bytes(instance), bytes(old), bytes(request.user))
unicode(instance), unicode(old), unicode(request.user))
if old.profile:
old.profile.notify(
ugettext_noop('Ownership accepted'),
......@@ -716,7 +723,7 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
salt=self.get_salt()))
except (signing.BadSignature, ValueError, TypeError) as e:
logger.error('Tried invalid token. Token: %s, user: %s. %s',
key, bytes(user), bytes(e))
key, unicode(user), unicode(e))
raise SuspiciousOperation()
try:
......@@ -724,12 +731,12 @@ class TransferOwnershipConfirmView(LoginRequiredMixin, View):
except self.model.DoesNotExist as e:
logger.error('Tried token to nonexistent instance %d. '
'Token: %s, user: %s. %s',
instance, key, bytes(user), bytes(e))
instance, key, unicode(user), unicode(e))
raise Http404()
if new_owner != user.pk:
logger.error('%s (%d) tried the token for %s. Token: %s.',
bytes(user), user.pk, new_owner, key)
unicode(user), user.pk, new_owner, key)
raise PermissionDenied()
return (instance, new_owner)
......
......@@ -75,6 +75,13 @@ from request.forms import LeaseRequestForm, TemplateRequestForm
from ..models import Favourite
from manager.scheduler import has_traits
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -315,7 +322,7 @@ def get_operations(instance, user):
op.check_precond()
except PermissionDenied as e:
pass
# logger.debug('Not showing operation %s for %s: %s', k, instance, bytes(e))
# logger.debug('Not showing operation %s for %s: %s', k, instance, unicode(e))
except Exception:
ops.append(v.bind_to_object(instance, disabled=True))
else:
......
......@@ -24,6 +24,11 @@ from fabric.api import env, run, settings, sudo, prefix, cd, execute
from fabric.context_managers import shell_env
from fabric.decorators import roles, parallel
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
env.roledefs['portal'] = ['localhost']
......@@ -35,7 +40,7 @@ try:
except Exception as e:
print(e)
else:
env.roledefs['node'] = [bytes(n.host.ipv4)
env.roledefs['node'] = [unicode(n.host.ipv4)
for n in _Node.objects.filter(enabled=True)]
env.roledefs['storage'] = [_DataStore.objects.get().hostname]
......@@ -149,7 +154,7 @@ def selenium(test=""):
def pull(dir="~/circle/circle"):
"Pull from upstream branch (stash any changes)"
now = bytes(datetime.datetime.now())
now = unicode(datetime.datetime.now())
with cd(dir), shell_env(GIT_AUTHOR_NAME="fabric",
GIT_AUTHOR_EMAIL="fabric@local",
GIT_COMMITTER_NAME="fabric",
......
......@@ -23,6 +23,12 @@ from firewall.models import (Rule, Host, Vlan, Group, VlanGroup, Firewall,
SwitchPort, EthernetDevice)
from django import contrib
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
class RuleInline(contrib.admin.TabularInline):
model = Rule
......@@ -107,7 +113,7 @@ class RuleAdmin(admin.ModelAdmin):
for field in [instance.vlan, instance.vlangroup, instance.host,
instance.hostgroup, instance.firewall]:
if field:
return bytes(field) + ' ' + field._meta.object_name
return unicode(field) + ' ' + field._meta.object_name
class AliasAdmin(admin.ModelAdmin):
......
......@@ -25,6 +25,11 @@ from netaddr import (IPAddress, IPNetwork, AddrFormatError, ZEROFILL,
EUI, mac_unix, AddrConversionError)
import re
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
alfanum_re = re.compile(r'^[A-Za-z0-9_-]+$')
domain_re = re.compile(r'^([A-Za-z0-9_/-]\.?)+$')
......@@ -47,7 +52,7 @@ class MACAddressFormField(forms.Field):
return MACAddressField.to_python
except (AddrFormatError, TypeError, ValidationError) as e:
raise ValidationError(self.default_error_messages['invalid']
% bytes(e))
% unicode(e))
class MACAddressField(models.Field):
......@@ -169,7 +174,7 @@ class IPNetworkFormField(forms.Field):
return IPNetworkField(version=self.version).to_python(value)
except (AddrFormatError, TypeError) as e:
raise ValidationError(self.default_error_messages['invalid']
% bytes(e))
% unicode(e))
def __init__(self, *args, **kwargs):
self.version = kwargs['version']
......@@ -274,7 +279,7 @@ def val_ipv6_template(value):
>>> val_ipv6_template("123::%(a)d:%(b)d:%(c)d:%(d)d")
>>> val_ipv6_template("::%(a)x:%(b)x:%(c)d:%(d)d")
Don't have to use all bytes from the left (no a):
Don't have to use all unicode from the left (no a):
>>> val_ipv6_template("::%(b)x:%(c)d:%(d)d")
But have to use all ones to the right (a, but no b):
......
......@@ -29,6 +29,12 @@ from django.template import loader
from django.utils import timezone
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
settings = django.conf.settings.FIREWALL_SETTINGS
logger = logging.getLogger(__name__)
......@@ -152,9 +158,9 @@ class BuildFirewall:
template = loader.get_template('firewall/iptables.conf')
context['proto'] = 'ipv4'
ipv4 = bytes(template.render(context))
ipv4 = unicode(template.render(context))
context['proto'] = 'ipv6'
ipv6 = bytes(template.render(context))
ipv6 = unicode(template.render(context))
return (ipv4, ipv6)
......
......@@ -46,6 +46,12 @@ from .iptables import IptRule
from acl.models import AclBase
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
settings = django.conf.settings.FIREWALL_SETTINGS
......@@ -178,10 +184,10 @@ class Rule(models.Model):
"""
return '[%(type)s] %(src)s ▸ %(dst)s %(para)s %(desc)s' % {
'type': self.r_type,
'src': (bytes(self.foreign_network) if self.direction == 'in'
'src': (str(self.foreign_network) if self.direction == 'in'
else self.r_type),
'dst': (self.r_type if self.direction == 'out'
else bytes(self.foreign_network)),
else str(self.foreign_network)),
'para': ((("proto=%s " % self.proto) if self.proto else '') +
(("sport=%s " % self.sport) if self.sport else '') +
(("dport=%s " % self.dport) if self.dport else '')),
......@@ -363,7 +369,7 @@ class Vlan(AclBase, models.Model):
help_text=_('Template of the IPv4 reverse domain name that '
'should be generated for each host. The template '
'should contain four tokens: "%(a)d", "%(b)d", '
'"%(c)d", and "%(d)d", representing the four bytes '
'"%(c)d", and "%(d)d", representing the four unicode '
'of the address, respectively, in decimal notation. '
'For example, the template for the standard reverse '
'address is: "%(d)d.%(c)d.%(b)d.%(a)d.in-addr.arpa".'),
......@@ -374,7 +380,7 @@ class Vlan(AclBase, models.Model):
'Automatically generated hosts in dual-stack networks '
'will get this address. The template '
'can contain four tokens: "%(a)d", "%(b)d", '
'"%(c)d", and "%(d)d", representing the four bytes '
'"%(c)d", and "%(d)d", representing the four unicode '
'of the IPv4 address, respectively, in decimal notation. '
'Moreover you can use any standard printf format '
'specification like %(a)02x to get the first byte as two '
......@@ -424,8 +430,8 @@ class Vlan(AclBase, models.Model):
self.host_ipv6_prefixlen = prefixlen
@staticmethod
def _host_bytes(prefixlen, maxbytes):
return int(ceil((maxbytes - prefixlen / 8.0)))
def _host_unicode(prefixlen, maxunicode):
return int(ceil((maxunicode - prefixlen / 8.0)))
@staticmethod
def _append_hexa(s, v, lasthalf):
......@@ -453,26 +459,26 @@ class Vlan(AclBase, models.Model):
... IPNetwork("2001:0DB8:1:1::/64"), False)
('2001:db8:1:1:%(d)02x00::', 72)
"""
host4_bytes = cls._host_bytes(network4.prefixlen, 4)
host6_bytes = cls._host_bytes(network6.prefixlen, 16)
if host4_bytes > host6_bytes:
host4_unicode = cls._host_unicode(network4.prefixlen, 4)
host6_unicode = cls._host_unicode(network6.prefixlen, 16)
if host4_unicode > host6_unicode:
raise ValidationError(
_("IPv6 network is too small to map IPv4 addresses to it."))
letters = ascii_letters[4-host4_bytes:4]
remove = host6_bytes // 2
letters = ascii_letters[4-host4_unicode:4]
remove = host6_unicode // 2
ipstr = network6.network.format(ipv6_full)
s = ipstr.split(":")[0:-remove]
if verbose is None: # use verbose format if net6 much wider
verbose = 2 * (host4_bytes + 1) < host6_bytes
verbose = 2 * (host4_unicode + 1) < host6_unicode
if verbose:
for i in letters:
s.append("%({})d".format(i))
else:
remain = host6_bytes
remain = host6_unicode
for i in letters:
cls._append_hexa(s, i, remain % 2 == 1)
remain -= 1
if host6_bytes > host4_bytes:
if host6_unicode > host4_unicode:
s.append(":")
tpl = ":".join(s)
# compute prefix length
......@@ -886,11 +892,11 @@ class Host(models.Model):
res = Record.objects.filter(
type='A', address=self.get_external_ipv4())
if res.count() < 1:
return bytes(self.get_external_ipv4())
return unicode(self.get_external_ipv4())
else:
res = self.record_set.filter(type='A',
address=self.ipv4)
return bytes(res[0].fqdn)
return unicode(res[0].fqdn)
except:
return None
......
......@@ -63,15 +63,15 @@ def get_firewall_queues():
@celery.task
def reloadtask_worker():
from firewall.fw import BuildFirewall, dhcp, dns, ipset, vlan
from remote_tasks import (reload_dns, reload_dhcp, reload_firewall,
from firewall.tasks.remote_tasks import (reload_dns, reload_dhcp, reload_firewall,
reload_firewall_vlan, reload_blacklist)
tasks = []
for i in ('dns', 'dhcp', 'firewall', 'firewall_vlan', 'blacklist'):
lockname = "%s_lock" % i
if cache.get(lockname):
# if cache.get(lockname):
tasks.append(i)
cache.delete(lockname)
# cache.delete(lockname)
logger.info("reloadtask_worker: Reload %s", ", ".join(tasks))
......
......@@ -36,6 +36,13 @@ from .models import BlacklistItem, Host
from django.conf import settings
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = logging.getLogger(__name__)
......@@ -108,4 +115,4 @@ def add_blacklist_item(request):
if is_new and settings.BLACKLIST_HOOK_URL:
send_request(obj)
return HttpResponse(bytes(_("OK")))
return HttpResponse(unicode(_("OK")))
......@@ -6,7 +6,7 @@ msgid ""
msgstr ""
"Project-Id-Version: \n"
"Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2021-12-20 08:40+0000\n"
"POT-Creation-Date: 2022-01-05 21:47+0000\n"
"PO-Revision-Date: 2015-09-04 11:15+0116\n"
"Last-Translator: <>\n"
"Language-Team: Hungarian <cloud@ik.bme.hu>\n"
......@@ -26,38 +26,38 @@ msgstr "Angol"
msgid "Hungarian"
msgstr "Magyar"
#: common/models.py:80
#: common/models.py:81
msgid "Failure."
msgstr "Hiba."
#: common/models.py:81
#: common/models.py:82
#, python-format
msgid "Unhandled exception: %(e)s: %(error)s"
msgstr "Kezeletlen kivétel: %(e)s: %(error)s"
#: common/models.py:157
#: common/models.py:158
#: dashboard/templates/dashboard/instanceactivity_detail.html:28
#: dashboard/templates/dashboard/nodeactivity_detail.html:26
msgid "activity code"
msgstr "tevékenységkód"
#: common/models.py:160
#: common/models.py:161
msgid "human readable name"
msgstr "olvasható név"
#: common/models.py:161
#: common/models.py:162
msgid "Human readable name of activity."
msgstr "A tevékenység neve olvasható formában."
#: common/models.py:165
#: common/models.py:166
msgid "Celery task unique identifier."
msgstr "Celery feladat egyedi azonosítója."
#: common/models.py:166
#: common/models.py:167
msgid "task_uuid"
msgstr "feladat uuid"
#: common/models.py:167
#: common/models.py:168
#: dashboard/templates/dashboard/instanceactivity_detail.html:37
#: dashboard/templates/dashboard/nodeactivity_detail.html:35
#: firewall/models.py:289 request/models.py:265 vm/models/common.py:85
......@@ -65,49 +65,49 @@ msgstr "feladat uuid"
msgid "user"
msgstr "felhasználó"
#: common/models.py:168
#: common/models.py:169
msgid "The person who started this activity."
msgstr "A tevékenységet indító felhasználó."
#: common/models.py:169
#: common/models.py:170
msgid "started at"
msgstr "indítás ideje"
#: common/models.py:171
#: common/models.py:172
msgid "Time of activity initiation."
msgstr "A tevékenység megkezdésének időpontja."
#: common/models.py:172
#: common/models.py:173
msgid "finished at"
msgstr "befejezés ideje"
#: common/models.py:174
#: common/models.py:175
msgid "Time of activity finalization."
msgstr "A tevékenység befejeztének ideje."
#: common/models.py:176
#: common/models.py:177
msgid "True, if the activity has finished successfully."
msgstr "Igaz, ha a tevékenység sikeresen befejeződött."
#: common/models.py:178
#: common/models.py:179
#: dashboard/templates/dashboard/instanceactivity_detail.html:56
#: dashboard/templates/dashboard/nodeactivity_detail.html:55
msgid "result"
msgstr "eredmény"
#: common/models.py:180
#: common/models.py:181
msgid "Human readable result of activity."
msgstr "A tevékenység eredménye olvasható formában."
#: common/models.py:552
#: common/models.py:553
msgid "Permission Denied"
msgstr "Hozzáférés megtagadva"
#: common/models.py:554
#: common/models.py:555
msgid "Unknown error"
msgstr "Ismeretlen hiba"
#: common/models.py:555
#: common/models.py:556
#, python-format
msgid "Unknown error: %(ex)s"
msgstr "Ismeretlen hiba: %(ex)s"
......@@ -138,8 +138,8 @@ msgstr "szerver"
msgid "realtime"
msgstr "valós idejű"
#: dashboard/forms.py:90 dashboard/forms.py:847 dashboard/forms.py:982
#: dashboard/forms.py:988 dashboard/forms.py:1456 dashboard/tables.py:270
#: dashboard/forms.py:91 dashboard/forms.py:848 dashboard/forms.py:983
#: dashboard/forms.py:989 dashboard/forms.py:1457 dashboard/tables.py:270
#: dashboard/templates/dashboard/_vm-create-2.html:20
#: dashboard/templates/dashboard/vm-detail/home.html:9
#: dashboard/templates/dashboard/vm-list.html:63 firewall/models.py:301
......@@ -148,31 +148,31 @@ msgstr "valós idejű"
msgid "Name"
msgstr "Név"
#: dashboard/forms.py:91 vm/models/instance.py:137
#: dashboard/forms.py:92 vm/models/instance.py:137
msgid "Human readable name of template."
msgstr "A sablon olvasható neve."
#: dashboard/forms.py:101
#: dashboard/forms.py:102
msgid "Clone template permissions"
msgstr "Sablon jogosultságainak klónozása"
#: dashboard/forms.py:102
#: dashboard/forms.py:103
msgid ""
"Clone the access list of parent template. Useful for updating a template."
msgstr ""
"A szülősablon hozzáférési listájának másolása. Sablonok frissítéséhez "
"ajánlott."
#: dashboard/forms.py:212 dashboard/templates/dashboard/_vm-create-1.html:59
#: dashboard/forms.py:213 dashboard/templates/dashboard/_vm-create-1.html:59
#: dashboard/templates/dashboard/vm-detail/home.html:34
msgid "Description"
msgstr "Leírás"
#: dashboard/forms.py:223 dashboard/forms.py:308
#: dashboard/forms.py:224 dashboard/forms.py:309
msgid "Directory identifier"
msgstr "Címtári azonosító"
#: dashboard/forms.py:226
#: dashboard/forms.py:227
msgid ""
"If you select an item here, the members of this directory group will be "
"automatically added to the group at the time they log in. Please note that "
......@@ -183,7 +183,7 @@ msgstr ""
"kerülnek, ha bejelentkeznek. Vegye figyelembe, hogy más, az önhöz hasonló "
"jogosultságú felhasználók is csoportadminisztrátorrá válhatnak."
#: dashboard/forms.py:250 dashboard/templates/dashboard/store/_list-box.html:57
#: dashboard/forms.py:251 dashboard/templates/dashboard/store/_list-box.html:57
#: network/templates/network/blacklist-create.html:8
#: network/templates/network/domain-create.html:8
#: network/templates/network/firewall-create.html:6
......@@ -199,24 +199,24 @@ msgstr ""
msgid "Create"
msgstr "Létrehozás"
#: dashboard/forms.py:270
#: dashboard/forms.py:271
#, fuzzy
#| msgid "Group actions"
msgid "Group to import"
msgstr "Csoportos műveletek"
#: dashboard/forms.py:277
#: dashboard/forms.py:278
#, fuzzy
#| msgid "Support"
msgid "Import"
msgstr "Támogatás"
#: dashboard/forms.py:286 dashboard/forms.py:868
#: dashboard/forms.py:287 dashboard/forms.py:869
#: dashboard/templates/dashboard/store/_list-box.html:114
msgid "Filename"
msgstr "Fájlnév"
#: dashboard/forms.py:292
#: dashboard/forms.py:293
#: dashboard/templates/dashboard/_disk-list-element.html:14
#: dashboard/templates/dashboard/group-detail.html:15
#, fuzzy
......@@ -224,10 +224,10 @@ msgstr "Fájlnév"
msgid "Export"
msgstr "Támogatás"
#: dashboard/forms.py:319 dashboard/forms.py:1317 dashboard/forms.py:1333
#: dashboard/forms.py:1368 dashboard/forms.py:1422 dashboard/forms.py:1469
#: dashboard/forms.py:1509 dashboard/forms.py:1529 dashboard/forms.py:1592
#: dashboard/forms.py:1715 dashboard/forms.py:1765
#: dashboard/forms.py:320 dashboard/forms.py:1318 dashboard/forms.py:1334
#: dashboard/forms.py:1369 dashboard/forms.py:1423 dashboard/forms.py:1470
#: dashboard/forms.py:1510 dashboard/forms.py:1530 dashboard/forms.py:1593
#: dashboard/forms.py:1716 dashboard/forms.py:1766
#: dashboard/templates/dashboard/_manage_access.html:73
#: dashboard/templates/dashboard/connect-command-create.html:37
#: dashboard/templates/dashboard/connect-command-edit.html:37
......@@ -242,62 +242,62 @@ msgstr "Támogatás"
msgid "Save"
msgstr "Mentés"
#: dashboard/forms.py:350 dashboard/forms.py:1116
#: dashboard/forms.py:351 dashboard/forms.py:1117
#: dashboard/templates/dashboard/_vm-remove-port.html:15
#: dashboard/templates/dashboard/vm-detail.html:113 network/views.py:659
msgid "Host"
msgstr "Gép"
#: dashboard/forms.py:421 dashboard/forms.py:819 dashboard/forms.py:1079
#: dashboard/forms.py:422 dashboard/forms.py:820 dashboard/forms.py:1080
#: dashboard/templates/dashboard/node-detail.html:5
#: dashboard/templates/dashboard/vm-detail/home.html:118
#: dashboard/templates/dashboard/vm-list.html:88
msgid "Node"
msgstr "Csomópont"
#: dashboard/forms.py:500
#: dashboard/forms.py:501
msgid "Networks"
msgstr "Hálózatok"
#: dashboard/forms.py:730 dashboard/forms.py:754
#: dashboard/forms.py:731 dashboard/forms.py:755
msgid "hours"
msgstr "óra"
#: dashboard/forms.py:735 dashboard/forms.py:759
#: dashboard/forms.py:736 dashboard/forms.py:760
msgid "days"
msgstr "nap"
#: dashboard/forms.py:740 dashboard/forms.py:764
#: dashboard/forms.py:741 dashboard/forms.py:765
msgid "weeks"
msgstr "hét"
#: dashboard/forms.py:745 dashboard/forms.py:769
#: dashboard/forms.py:746 dashboard/forms.py:770
msgid "months"
msgstr "hónap"
#: dashboard/forms.py:775 dashboard/templates/dashboard/template-edit.html:64
#: dashboard/forms.py:776 dashboard/templates/dashboard/template-edit.html:64
#: network/forms.py:64
msgid "Save changes"
msgstr "Változások mentése"
#: dashboard/forms.py:785
#: dashboard/forms.py:786
msgid "Set expiration times even if they are shorter than the current value."
msgstr ""
"Akkor is állítsa át a lejárati időket, ha rövidebbek lesznek a jelenleginél."
#: dashboard/forms.py:788
#: dashboard/forms.py:789
msgid "Save selected lease."
msgstr "Kiválasztott bérlet mentése."
#: dashboard/forms.py:797
#: dashboard/forms.py:798
msgid "Length"
msgstr "Hossz"
#: dashboard/forms.py:805
#: dashboard/forms.py:806
msgid "Live migration"
msgstr "Live migration"
#: dashboard/forms.py:807
#: dashboard/forms.py:808
msgid ""
"Live migration is a way of moving virtual machines between hosts with a "
"service interruption of at most some seconds. Please note that it can take "
......@@ -307,47 +307,47 @@ msgstr ""
"legfeljebb néhány másodperces szolgáltatáskimaradással. Vegye figyelembe, "
"hogy ez terhelt gépek esetén sokáig tarthat és nagy hálózati forgalommal jár."
#: dashboard/forms.py:824
#: dashboard/forms.py:825
msgid "Forcibly interrupt all running activities."
msgstr "Futó tevékenységek erőltetett befejezése."
#: dashboard/forms.py:825
#: dashboard/forms.py:826
msgid "Set all activities to finished state, but don't interrupt any tasks."
msgstr ""
"Minden tevékenység befejezettre állítása (a feladatok megszakítása nélkül)."
#: dashboard/forms.py:828
#: dashboard/forms.py:829
msgid "New status"
msgstr "Új állapot"
#: dashboard/forms.py:829
#: dashboard/forms.py:830
msgid "Reset node"
msgstr "Csomópont visszaállítása"
#: dashboard/forms.py:843
#: dashboard/forms.py:844
msgid "use emergency state change"
msgstr "vész-állapotváltás használata"
#: dashboard/forms.py:849 dashboard/forms.py:904
#: dashboard/forms.py:850 dashboard/forms.py:905
#: dashboard/templates/dashboard/store/_list-box.html:117 request/forms.py:176
msgid "Size"
msgstr "Méret"
#: dashboard/forms.py:850
#: dashboard/forms.py:851
msgid "Size of disk to create in bytes or with units like MB or GB."
msgstr "Létrehozandó lemez mérete byte-okban vagy mértékegységgel (MB, GB)."
#: dashboard/forms.py:862 dashboard/forms.py:926
#: dashboard/forms.py:863 dashboard/forms.py:927
msgid "Invalid format, you can use GB or MB!"
msgstr "Érvénytelen formátum. „GB” és „MB” is használható."
#: dashboard/forms.py:871
#: dashboard/forms.py:872
#, fuzzy
#| msgid "normal"
msgid "Format"
msgstr "normál"
#: dashboard/forms.py:881 dashboard/forms.py:916 dashboard/forms.py:952
#: dashboard/forms.py:882 dashboard/forms.py:917 dashboard/forms.py:953
#: dashboard/templates/dashboard/storage/disk.html:7
#: dashboard/templates/dashboard/storage/disk.html:24
#: request/templates/request/_request-resize-form.html:9
......@@ -355,113 +355,113 @@ msgstr "normál"
msgid "Disk"
msgstr "Lemez"
#: dashboard/forms.py:892 dashboard/forms.py:938 dashboard/forms.py:963
#: dashboard/forms.py:893 dashboard/forms.py:939 dashboard/forms.py:964
#, python-format
msgid "<label>Disk:</label> %s"
msgstr "<label>Lemez:</label> %s"
#: dashboard/forms.py:905 request/forms.py:177
#: dashboard/forms.py:906 request/forms.py:177
msgid "Size to resize the disk in bytes or with units like MB or GB."
msgstr "A lemez kívánt mérete byte-okban vagy mértékegységgel (MB, GB)."
#: dashboard/forms.py:929
#: dashboard/forms.py:930
msgid "Disk size must be greater than the actual size."
msgstr "A lemez mérete nagyobb kell legyen a jelenleginél."
#: dashboard/forms.py:983
#: dashboard/forms.py:984
#, fuzzy
#| msgid "Disk list"
msgid "Disk image"
msgstr "Lemezek"
#: dashboard/forms.py:989
#: dashboard/forms.py:990
msgid "URL"
msgstr "URL"
#: dashboard/forms.py:999
#: dashboard/forms.py:1000
msgid "Could not find filename in URL, please specify a name explicitly."
msgstr "Az URL-ben nem található fájlnév. Kérem adja meg explicite."
#: dashboard/forms.py:1013
#: dashboard/forms.py:1014
msgid "Interface"
msgstr "Interfészek"
#: dashboard/forms.py:1025
#: dashboard/forms.py:1026
#, python-brace-format
msgid "<label>Vlan:</label> {0}"
msgstr "<label>Vlan:</label> {0}"
#: dashboard/forms.py:1040
#: dashboard/forms.py:1041
#: dashboard/templates/dashboard/_vm-remove-port.html:17
#: dashboard/templates/dashboard/node-detail/resources.html:28
#: network/views.py:658
msgid "Vlan"
msgstr "Vlan"
#: dashboard/forms.py:1043
#: dashboard/forms.py:1044
msgid "No more networks."
msgstr "Nincs több hálózat."
#: dashboard/forms.py:1064
#: dashboard/forms.py:1065
#, python-format
msgid " (missing_traits: %s)"
msgstr "(hiányzó jellemzők: %s)"
#: dashboard/forms.py:1080
#: dashboard/forms.py:1081
msgid ""
"Deploy virtual machine to this node (blank allows scheduling automatically)."
msgstr ""
"A virtuális gép elindítása ezen a csomóponton (üresen hagyva automatikus "
"ütemezés)."
#: dashboard/forms.py:1097 dashboard/forms.py:1103
#: dashboard/forms.py:1098 dashboard/forms.py:1104
#: dashboard/templates/dashboard/_vm-remove-port.html:13
msgid "Port"
msgstr "Port"
#: dashboard/forms.py:1106 dashboard/templates/dashboard/vm-detail.html:111
#: dashboard/forms.py:1107 dashboard/templates/dashboard/vm-detail.html:111
msgid "Protocol"
msgstr "Protokoll"
#: dashboard/forms.py:1128
#: dashboard/forms.py:1129
#, python-brace-format
msgid "<label>Host:</label> {0}"
msgstr "<label>Gép:</label> {0}"
#: dashboard/forms.py:1156 dashboard/templates/dashboard/profile.html:36
#: dashboard/forms.py:1157 dashboard/templates/dashboard/profile.html:36
#: dashboard/templates/dashboard/vm-detail.html:129
msgid "Username"
msgstr "Felhasználónév"
#: dashboard/forms.py:1170 dashboard/templates/dashboard/vm-detail.html:131
#: dashboard/forms.py:1171 dashboard/templates/dashboard/vm-detail.html:131
msgid "Password"
msgstr "Jelszó"
#: dashboard/forms.py:1175
#: dashboard/forms.py:1176
msgid "Sign in"
msgstr "Bejelentkezés"
#: dashboard/forms.py:1198 dashboard/templates/dashboard/profile.html:42
#: dashboard/forms.py:1199 dashboard/templates/dashboard/profile.html:42
msgid "Email address"
msgstr "E-mail cím"
#: dashboard/forms.py:1203
#: dashboard/forms.py:1204
msgid "Reset password"
msgstr "Új jelszó"
#: dashboard/forms.py:1219 dashboard/forms.py:1342
#: dashboard/forms.py:1220 dashboard/forms.py:1343
msgid "Change password"
msgstr "Jelszóváltoztatás"
#: dashboard/forms.py:1289
#: dashboard/forms.py:1290
msgid "Add trait"
msgstr "Jellemző hozzáadása"
#: dashboard/forms.py:1306
#: dashboard/forms.py:1307
msgid "Preferred language"
msgstr "Választott nyelv"
#: dashboard/forms.py:1357 dashboard/templates/dashboard/group-list.html:14
#: dashboard/forms.py:1358 dashboard/templates/dashboard/group-list.html:14
#: dashboard/templates/dashboard/index-groups.html:7
#: dashboard/templates/dashboard/profile.html:61
#: dashboard/templates/dashboard/vm-detail/network.html:44
......@@ -471,68 +471,68 @@ msgstr "Választott nyelv"
msgid "Groups"
msgstr "Csoportok"
#: dashboard/forms.py:1383
#: dashboard/forms.py:1384
msgid "Instance limit"
msgstr "Példány limit"
#: dashboard/forms.py:1386
#: dashboard/forms.py:1387
#, fuzzy
#| msgid "Instance limit"
msgid "Template instance limit"
msgstr "Példány limit"
#: dashboard/forms.py:1389
#: dashboard/forms.py:1390
msgid "Two-factor authentication secret"
msgstr ""
#: dashboard/forms.py:1390
#: dashboard/forms.py:1391
msgid ""
"Remove the secret key to disable two-factor authentication for this user."
msgstr ""
#: dashboard/forms.py:1432 dashboard/templates/dashboard/lease-edit.html:86
#: dashboard/forms.py:1433 dashboard/templates/dashboard/lease-edit.html:86
msgid "Name of group or user"
msgstr "Csoport vagy felhasználó neve"
#: dashboard/forms.py:1441 dashboard/forms.py:1451
#: dashboard/forms.py:1442 dashboard/forms.py:1452
msgid "Name of user"
msgstr "Felhasználó neve"
#: dashboard/forms.py:1442 dashboard/forms.py:1452
#: dashboard/forms.py:1443 dashboard/forms.py:1453
msgid "E-mail address or identifier of user"
msgstr "A felhasználó e-mail címe vagy azonosítója"
#: dashboard/forms.py:1458
#: dashboard/forms.py:1459
msgid "Key"
msgstr "Kulcs"
#: dashboard/forms.py:1459
#: dashboard/forms.py:1460
msgid "For example: ssh-rsa AAAAB3NzaC1yc2ED..."
msgstr "Például: ssh-rsa AAAAB3NzaC1yc2ED…"
#: dashboard/forms.py:1538
#: dashboard/forms.py:1539
msgid "permissions"
msgstr "jogosultságok"
#: dashboard/forms.py:1639
#: dashboard/forms.py:1640
msgid "owned"
msgstr "saját"
#: dashboard/forms.py:1640
#: dashboard/forms.py:1641
msgid "shared"
msgstr "osztott"
#: dashboard/forms.py:1641
#: dashboard/forms.py:1642
#, fuzzy
#| msgid "shared IP"
msgid "shared with me"
msgstr "osztott IP"
#: dashboard/forms.py:1642
#: dashboard/forms.py:1643
msgid "all"
msgstr "összes"
#: dashboard/forms.py:1651 dashboard/forms.py:1677 dashboard/forms.py:1698
#: dashboard/forms.py:1652 dashboard/forms.py:1678 dashboard/forms.py:1699
#: dashboard/templates/dashboard/index-groups.html:23
#: dashboard/templates/dashboard/index-nodes.html:40
#: dashboard/templates/dashboard/index-templates.html:40
......@@ -543,19 +543,19 @@ msgstr "összes"
msgid "Search..."
msgstr "Keresés..."
#: dashboard/forms.py:1748
#: dashboard/forms.py:1749
#, fuzzy
#| msgid "Start time of the message in YYYY.DD.MM. hh.mm.ss format."
msgid "Start time of the message in YYYY-MM-DD hh:mm:ss format."
msgstr "Az üzenet kezdési időpontja YYYY.DD.MM. hh.mm.ss formátumban."
#: dashboard/forms.py:1750
#: dashboard/forms.py:1751
#, fuzzy
#| msgid "End time of the message in YYYY.DD.MM. hh.mm.ss format."
msgid "End time of the message in YYYY-MM-DD hh:mm:ss format."
msgstr "Az üzenet befejezési időpontja YYYY.DD.MM. hh.mm.ss formátumban."
#: dashboard/forms.py:1752
#: dashboard/forms.py:1753
msgid ""
"The color of the message box defined by the respective <a href=\"http://"
"getbootstrap.com/components/#alerts\">Bootstrap class</a>."
......@@ -563,23 +563,23 @@ msgstr ""
"Az üzenet doboz színe a megfelelő <a href=\"http://getbootstrap.com/"
"components/#alerts\">Bootstrap osztály</a> szerint meghatározva."
#: dashboard/forms.py:1758
#: dashboard/forms.py:1759
msgid "Start time"
msgstr "Kezdési időpont"
#: dashboard/forms.py:1759
#: dashboard/forms.py:1760
msgid "End time"
msgstr "Befejezési időpont"
#: dashboard/forms.py:1777
#: dashboard/forms.py:1778
msgid "Two-factor authentication passcode"
msgstr ""
#: dashboard/forms.py:1778
#: dashboard/forms.py:1779
msgid "Get the code from your authenticator."
msgstr ""
#: dashboard/forms.py:1789
#: dashboard/forms.py:1790
#, fuzzy
#| msgid "File removal confirmation"
msgid "Invalid confirmation code."
......@@ -752,7 +752,7 @@ msgid "Unique identifier of the group at the organization."
msgstr "A csoport egyedi szervezeti azonosítója."
#. Translators: [T] as Template
#: dashboard/tables.py:53 dashboard/tables.py:310
#: dashboard/tables.py:53 dashboard/tables.py:313
#: dashboard/templates/dashboard/vm-detail/home.html:131
msgid "Template"
msgstr "Sablon"
......@@ -804,7 +804,7 @@ msgid "Admin"
msgstr "Adminisztráció"
#: dashboard/tables.py:141 dashboard/tables.py:220 dashboard/tables.py:251
#: dashboard/tables.py:285 dashboard/tables.py:314 network/tables.py:272
#: dashboard/tables.py:285 dashboard/tables.py:317 network/tables.py:272
msgid "Actions"
msgstr "Műveletek"
......@@ -855,15 +855,15 @@ msgstr "Nincs elérhető bérlési mód."
msgid "Fingerprint"
msgstr "Ujjlenyomat"
#: dashboard/tables.py:296
#: dashboard/tables.py:299
msgid "You haven't added any public keys yet."
msgstr "Még nem adott meg publikus kulcsot."
#: dashboard/tables.py:306 templates/info/help/overview.html:354
#: dashboard/tables.py:309 templates/info/help/overview.html:354
msgid "Access method"
msgstr "Elérés módja"
#: dashboard/tables.py:327
#: dashboard/tables.py:330
msgid ""
"You don't have any custom connection commands yet. You can specify commands "
"to be displayed on VM detail pages instead of the defaults."
......@@ -871,24 +871,24 @@ msgstr ""
"Még nincs egyedi csatlakozási parancsa. Az itt megadott parancsok fognak "
"megjelenni a VM-részletező oldalon az alapértelmezettek helyett."
#: dashboard/tables.py:336 dashboard/templates/dashboard/vm-list.html:59
#: dashboard/tables.py:339 dashboard/templates/dashboard/vm-list.html:59
#: request/tables.py:31 request/tables.py:62 request/tables.py:78
msgid "ID"
msgstr "ID"
#: dashboard/tables.py:341 dashboard/templates/dashboard/storage/disk.html:18
#: dashboard/tables.py:344 dashboard/templates/dashboard/storage/disk.html:18
msgid "Appliance"
msgstr "Felhasználás"
#: dashboard/tables.py:345
#: dashboard/tables.py:348
msgid "ready"
msgstr "kész"
#: dashboard/tables.py:356
#: dashboard/tables.py:359
msgid "No disk found."
msgstr "Nem található lemez."
#: dashboard/tables.py:373
#: dashboard/tables.py:376
msgid "No messages."
msgstr "Nincsenek üzenetek."
......@@ -3502,112 +3502,112 @@ msgstr "A művelet sikeresen végrehajtásra került."
msgid "Operation is started."
msgstr "A művelet megkezdődött."
#: dashboard/views/util.py:426
#: dashboard/views/util.py:429
#, python-format
msgid "Acl user/group %(w)s successfully modified."
msgstr "A(z) %(w)s ACL felhasználó/csoport módosításra került."
#: dashboard/views/util.py:428
#: dashboard/views/util.py:431
#, python-format
msgid "Acl user/group %(w)s successfully added."
msgstr "A(z) %(w)s ACL felhasználó/csoport hozzáadásra került."
#: dashboard/views/util.py:430
#: dashboard/views/util.py:433
#, python-format
msgid "Acl user/group %(w)s successfully removed."
msgstr "A(z) %(w)s ACL felhasználó/csoport törlésre került."
#: dashboard/views/util.py:515
#: dashboard/views/util.py:518
msgid ""
"The original owner cannot be removed, however you can transfer ownership."
msgstr "Az eredeti tulajdonos nem törölhető, azonban a tulajdon átruházható."
#: dashboard/views/util.py:551
#: dashboard/views/util.py:554
#, python-format
msgid "User \"%s\" has already access to this object."
msgstr "„%s” felhasználó már hozzáfér az objektumhoz."
#: dashboard/views/util.py:560
#: dashboard/views/util.py:563
#, python-format
msgid "Group \"%s\" has already access to this object."
msgstr "„%s” csoport már hozzáfér az objektumhoz."
#: dashboard/views/util.py:565
#: dashboard/views/util.py:568
#, python-format
msgid "User or group \"%s\" not found."
msgstr "Nem található „%s” felhasználó vagy csoport."
#: dashboard/views/util.py:581
#: dashboard/views/util.py:584
msgid "1 hour"
msgstr "1 óra"
#: dashboard/views/util.py:582
#: dashboard/views/util.py:585
msgid "6 hours"
msgstr "6 óra"
#: dashboard/views/util.py:583
#: dashboard/views/util.py:586
msgid "1 day"
msgstr "1 nap"
#: dashboard/views/util.py:584
#: dashboard/views/util.py:587
msgid "1 week"
msgstr "1 hét"
#: dashboard/views/util.py:585
#: dashboard/views/util.py:588
msgid "1 month"
msgstr "1 hónap"
#: dashboard/views/util.py:586
#: dashboard/views/util.py:589
msgid "6 months"
msgstr "6 hónap"
#: dashboard/views/util.py:595
#: dashboard/views/util.py:598
msgid "Bad graph time format, available periods are: h, d, w, and y."
msgstr "Hibás grafikon időformátum. Lehetséges egységek: h, d, w és y."
#: dashboard/views/util.py:620
#: dashboard/views/util.py:623
msgid "Transfer ownership"
msgstr "Tulajdon átruházása"
#: dashboard/views/util.py:633
#: dashboard/views/util.py:636
msgid "Can not find specified user."
msgstr "Nem található a megadott felhasználó."
#: dashboard/views/util.py:649
#: dashboard/views/util.py:652
msgid "Ownership offer"
msgstr "Átruházási ajánlat"
#: dashboard/views/util.py:653
#: dashboard/views/util.py:656
msgid "Can not notify selected user."
msgstr "A kiválaszott felhasználó értesítése sikertelen."
#: dashboard/views/util.py:656
#: dashboard/views/util.py:659
#, python-format
msgid "User %s is notified about the offer."
msgstr "%s felhasználó értesítésre került az ajánlatról."
#: dashboard/views/util.py:666
#: dashboard/views/util.py:669
msgid "Ownership successfully transferred to you."
msgstr "A tulajdon átruházásra került."
#: dashboard/views/util.py:679
#: dashboard/views/util.py:682
msgid "This token is for an other user."
msgstr "A token más felhasználó nevére szól."
#: dashboard/views/util.py:682
#: dashboard/views/util.py:685
msgid "This token is invalid or has expired."
msgstr "A token érvénytelen vagy lejárt."
#: dashboard/views/util.py:704
#: dashboard/views/util.py:707
msgid "Ownership accepted"
msgstr "Átruházás elfogadva"
#: dashboard/views/util.py:705
#: dashboard/views/util.py:708
#, python-format
msgid "Your ownership offer of %(instance)s has been accepted by %(owner)s."
msgstr "%(instance)s gépre vonatkozó átruházási ajánlatát elfogadta %(owner)s."
#: dashboard/views/util.py:754
#: dashboard/views/util.py:757
msgid "Only the owners can delete the selected object."
msgstr "Csak a tulajdonos törölheti a kiválasztott objektumot."
......
......@@ -39,7 +39,6 @@ def crontab_parser(crontab):
day_of_week=fields[4],
)
celery = Celery('manager',
broker=getenv("AMQP_URI"),
include=['vm.tasks.local_tasks',
......@@ -51,9 +50,10 @@ celery = Celery('manager',
'dashboard.tasks.local_periodic_tasks',
])
celery.config_from_object('celeryconfig')
celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=30000,
# CELERY_RESULT_BACKEND='amqp',
CELERY_QUEUES=(
Queue(HOSTNAME + '.man', Exchange('manager', type='direct'),
routing_key="manager"),
......
......@@ -24,15 +24,17 @@ from os import getenv
HOSTNAME = "localhost"
QUEUE_NAME = HOSTNAME + '.monitor'
celery = Celery('monitor',
broker=getenv("AMQP_URI"),
include=['vm.tasks.local_periodic_tasks',
'monitor.tasks.local_periodic_tasks',
])
celery.config_from_object('celeryconfig')
celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=30000,
# CELERY_RESULT_BACKEND='amqp',
CELERY_QUEUES=(
Queue(QUEUE_NAME, Exchange('monitor', type='direct'),
routing_key="monitor"),
......
......@@ -24,6 +24,7 @@ from os import getenv
HOSTNAME = "localhost"
QUEUE_NAME = HOSTNAME + '.man.slow'
celery = Celery('manager.slow',
broker=getenv("AMQP_URI"),
include=['vm.tasks.local_tasks',
......@@ -31,10 +32,10 @@ celery = Celery('manager.slow',
'storage.tasks.local_tasks',
'storage.tasks.periodic_tasks',
])
celery.config_from_object('celeryconfig')
celery.conf.update(
CELERY_RESULT_BACKEND='amqp',
CELERY_TASK_RESULT_EXPIRES=30000,
# CELERY_RESULT_BACKEND='amqp',
CELERY_QUEUES=(
Queue(QUEUE_NAME, Exchange('manager.slow', type='direct'),
routing_key="manager.slow"),
......
......@@ -67,6 +67,12 @@ ACCESS_METHODS = [(key, name) for key, (name, port, transport)
in list(ACCESS_PROTOCOLS.items())]
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
def find_unused_port(port_range, used_ports=[]):
"""Find an unused port in the specified range.
......@@ -699,7 +705,7 @@ class Instance(AclBase, VirtualMachineDescModel, StatusModel, OperatedMixin,
" Failed ones are: %(faileds_ex)s."),
failed=len(failed), success=len(success),
faileds=", ".join(a for a, e in failed),
faileds_ex=", ".join("%s (%s)" % (a, bytes(e))
faileds_ex=", ".join("%s (%s)" % (a, unicode(e))
for a, e in failed))
else:
act.result = create_readable(ugettext_noop(
......
......@@ -57,6 +57,13 @@ from .tasks.local_tasks import (
abortable_async_instance_operation, abortable_async_node_operation,
)
try:
# Python 2: "unicode" is built-in
unicode
except NameError:
unicode = str
logger = getLogger(__name__)
......@@ -111,16 +118,16 @@ class InstanceOperation(Operation):
if self.accept_states:
if self.instance.status not in self.accept_states:
logger.debug("precond failed for %s: %s not in %s",
bytes(self.__class__),
bytes(self.instance.status),
bytes(self.accept_states))
unicode(self.__class__),
unicode(self.instance.status),
unicode(self.accept_states))
raise self.instance.WrongStateError(self.instance)
if self.deny_states:
if self.instance.status in self.deny_states:
logger.debug("precond failed for %s: %s in %s",
bytes(self.__class__),
bytes(self.instance.status),
bytes(self.accept_states))
unicode(self.__class__),
unicode(self.instance.status),
unicode(self.accept_states))
raise self.instance.WrongStateError(self.instance)
def check_auth(self, user):
......@@ -1310,7 +1317,7 @@ class UpdateNodeOperation(NodeOperation):
if not isinstance(data, dict):
raise HumanReadableException.create(ugettext_noop(
"Unhandled exception: %(msg)s"), msg=bytes(data))
"Unhandled exception: %(msg)s"), msg=unicode(data))
return data
......@@ -1321,7 +1328,7 @@ class UpdateNodeOperation(NodeOperation):
data = self.minion_cmd('pkg.upgrade', [])
if not data.get('result'):
raise HumanReadableException.create(ugettext_noop(
"Unhandled exception: %(msg)s"), msg=bytes(data))
"Unhandled exception: %(msg)s"), msg=unicode(data))
# data = {'vim': {'new': '1.2.7', 'old': '1.3.7'}}
data = [v for v in list(data.values()) if isinstance(v, dict)]
......@@ -1786,11 +1793,11 @@ class DetachMixin(object):
try:
super(DetachMixin, self)._operation(**kwargs)
except Exception as e:
if hasattr(e, "libvirtError") and "not found" in bytes(e):
if hasattr(e, "libvirtError") and "not found" in unicode(e):
activity.result = create_readable(
ugettext_noop("Resource was not found."),
ugettext_noop("Resource was not found. %(exception)s"),
exception=bytes(e))
exception=unicode(e))
else:
raise
......
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 sign in to comment