From b3cdbbcae2ac6bca8496a164ef767e3b32666141 Mon Sep 17 00:00:00 2001 From: "M.Ravi" Date: Wed, 11 Jul 2018 18:50:56 +0200 Subject: [PATCH 01/38] Move placeholder to blog_ungleich This was the cause why the structure/content switch was not available on the blog page --- ungleich/templates/cms/ungleichch/base_ungleich.html | 1 - ungleich/templates/cms/ungleichch/blog_ungleich.html | 4 ++-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/ungleich/templates/cms/ungleichch/base_ungleich.html b/ungleich/templates/cms/ungleichch/base_ungleich.html index e19e7421..b82402a4 100644 --- a/ungleich/templates/cms/ungleichch/base_ungleich.html +++ b/ungleich/templates/cms/ungleichch/base_ungleich.html @@ -55,7 +55,6 @@
{% block base_content %} - {% placeholder "default" %} {% endblock %}
diff --git a/ungleich/templates/cms/ungleichch/blog_ungleich.html b/ungleich/templates/cms/ungleichch/blog_ungleich.html index d5475867..ebd4b102 100644 --- a/ungleich/templates/cms/ungleichch/blog_ungleich.html +++ b/ungleich/templates/cms/ungleichch/blog_ungleich.html @@ -1,5 +1,5 @@ {% extends "base_ungleich.html" %} +{% load cms_tags %} {% block base_content %} -{% block content %} -{% endblock %} +{% placeholder "default" %} {% endblock %} From a5929b3e863a8156a17be8ae4e5b88b728366174 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Jul 2018 18:41:28 +0200 Subject: [PATCH 02/38] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index e2bb96cd..f0d5e09d 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.0.1: 2018-07-14 + * bugfix: [blog] Enable content/structure mode in blog page 2.0: 2018-07-07 * #3747: [dcl,hosting] Add multiple cards support (PR #530) * #3934: [dcl,hosting] Create HostingOrder outside celery task and add and associate OrderDetail with HostingOrder (PR #624) From c97e2c55f3892c0f3002ff9d0a324d905356b08e Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Jul 2018 19:03:04 +0200 Subject: [PATCH 03/38] Add missing content block in the blog_ungleich.html template file --- ungleich/templates/cms/ungleichch/blog_ungleich.html | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ungleich/templates/cms/ungleichch/blog_ungleich.html b/ungleich/templates/cms/ungleichch/blog_ungleich.html index ebd4b102..e7ed3f25 100644 --- a/ungleich/templates/cms/ungleichch/blog_ungleich.html +++ b/ungleich/templates/cms/ungleichch/blog_ungleich.html @@ -2,4 +2,6 @@ {% load cms_tags %} {% block base_content %} {% placeholder "default" %} +{% block content %} +{% endblock %} {% endblock %} From 098a9065f14a30785e3e170d523fd704c04dbe14 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Jul 2018 19:05:14 +0200 Subject: [PATCH 04/38] Update Changelog for 2.0.2 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index f0d5e09d..2436f1a3 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.0.2: 2018-07-14 + * bugfix: [blog] Add missing content block in the blog_ungleich.html template file 2.0.1: 2018-07-14 * bugfix: [blog] Enable content/structure mode in blog page 2.0: 2018-07-07 From 15e435d220dbbcea537fa215bb6ea57cb2bf78fd Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 14 Jul 2018 20:05:18 +0200 Subject: [PATCH 05/38] Remove unused ^comic/$ url --- dynamicweb/urls.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index c8961971..bee1398d 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -57,9 +57,6 @@ urlpatterns += i18n_patterns( url(r'^blog/$', RedirectView.as_view(url=reverse_lazy('ungleich:post-list')), name='blog_list_view'), - url(r'^comic/$', - ungleich_views.PostListViewUngleich.as_view(category='comic'), - name='comic_post_list_view'), url(r'^cms/', include('cms.urls')), url(r'^blog/', include('djangocms_blog.urls', namespace='djangocms_blog')), url(r'^$', RedirectView.as_view(url='/cms') if REDIRECT_TO_CMS From 13e33cbb7ad0c687dd580a2baad35c30826efeeb Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 16 Jul 2018 20:44:09 +0200 Subject: [PATCH 06/38] Remove unused import --- dynamicweb/urls.py | 1 - 1 file changed, 1 deletion(-) diff --git a/dynamicweb/urls.py b/dynamicweb/urls.py index bee1398d..7e2d58a1 100644 --- a/dynamicweb/urls.py +++ b/dynamicweb/urls.py @@ -11,7 +11,6 @@ from hosting.views import ( RailsHostingView, DjangoHostingView, NodeJSHostingView ) from membership import urls as membership_urls -from ungleich import views as ungleich_views from ungleich_page.views import LandingView from django.views.generic import RedirectView from django.core.urlresolvers import reverse_lazy From d6a404d49d25d86e4af0bbdc2c3cd4c508dd4b2c Mon Sep 17 00:00:00 2001 From: PCoder Date: Mon, 16 Jul 2018 22:38:29 +0200 Subject: [PATCH 07/38] Add missing placeholder --- ungleich/templates/cms/ungleichch/base_ungleich.html | 1 + 1 file changed, 1 insertion(+) diff --git a/ungleich/templates/cms/ungleichch/base_ungleich.html b/ungleich/templates/cms/ungleichch/base_ungleich.html index b82402a4..ba314b25 100644 --- a/ungleich/templates/cms/ungleichch/base_ungleich.html +++ b/ungleich/templates/cms/ungleichch/base_ungleich.html @@ -55,6 +55,7 @@
{% block base_content %} + {% placeholder "base_ungleich_content" %} {% endblock %}
From 4a19bd1971bf0491e2d73bf857edb7d1b85dcf42 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Jul 2018 21:48:39 +0200 Subject: [PATCH 08/38] Set X_FRAME_OPTIONS from env --- dynamicweb/settings/base.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 75dfaa73..d526881f 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -702,6 +702,12 @@ if ENABLE_LOGGING: TEST_MANAGE_SSH_KEY_PUBKEY = env('TEST_MANAGE_SSH_KEY_PUBKEY') TEST_MANAGE_SSH_KEY_HOST = env('TEST_MANAGE_SSH_KEY_HOST') +X_FRAME_OPTIONS_ALLOW_FROM_URI = env('X_FRAME_OPTIONS_ALLOW_FROM_URI') +X_FRAME_OPTIONS = ('SAMEORIGIN' if X_FRAME_OPTIONS_ALLOW_FROM_URI is None else + 'ALLOW-FROM {}'.format( + X_FRAME_OPTIONS_ALLOW_FROM_URI.strip() + )) + DEBUG = bool_env('DEBUG') if DEBUG: From 1291b49ec34524086a84bac29a890d78d113659c Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Jul 2018 21:49:11 +0200 Subject: [PATCH 09/38] Reformat base.py --- dynamicweb/settings/base.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index d526881f..7d333a2f 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -2,16 +2,15 @@ Copyright 2015 ungleich. """ +import json +import logging # -*- coding: utf-8 -*- # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os -import json - -from django.utils.translation import ugettext_lazy as _ # dotenv import dotenv -import logging +from django.utils.translation import ugettext_lazy as _ logger = logging.getLogger(__name__) @@ -56,6 +55,7 @@ PROJECT_DIR = os.path.abspath( dotenv.read_dotenv("{0}/.env".format(PROJECT_DIR)) from multisite import SiteID + SITE_ID = SiteID(default=1) APP_ROOT_ENDPOINT = "/" @@ -580,7 +580,6 @@ MULTISITE_FALLBACK_KWARGS = { FILER_ENABLE_PERMISSIONS = True - ############################################# # configurations for opennebula-integration # ############################################# From 62d23b8a5ce7c871879fbe5bd0691a500d658bee Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Jul 2018 22:02:21 +0200 Subject: [PATCH 10/38] Update Changelog --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 2436f1a3..381fe562 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +Next: + * 5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` 2.0.2: 2018-07-14 * bugfix: [blog] Add missing content block in the blog_ungleich.html template file 2.0.1: 2018-07-14 From be2831818d4647cfddc6c2fdd2d8da877f709399 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Jul 2018 22:08:47 +0200 Subject: [PATCH 11/38] Update Changelog for 2.0.3 --- Changelog | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 381fe562..bc127879 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,6 @@ -Next: - * 5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` +2.0.3: + * Remove unused /comic url (PR #644) + * 5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` (PR #645) 2.0.2: 2018-07-14 * bugfix: [blog] Add missing content block in the blog_ungleich.html template file 2.0.1: 2018-07-14 From 15db1c88d7827c84a99eff52d9bdda48cfa7c88f Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 18 Jul 2018 22:14:35 +0200 Subject: [PATCH 12/38] Add release date for 2.0.3 --- Changelog | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Changelog b/Changelog index bc127879..6c48e4b5 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,4 @@ -2.0.3: +2.0.3: 2018-07-18 * Remove unused /comic url (PR #644) * 5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` (PR #645) 2.0.2: 2018-07-14 From 07c7a64c5a3da4d5a66d496187f9905f8eb6c00c Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 4 Aug 2018 08:46:00 +0200 Subject: [PATCH 13/38] Leave 'ipv6only' as a part of the VM name if it starts with it --- opennebula_api/serializers.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/opennebula_api/serializers.py b/opennebula_api/serializers.py index 79f37ecd..f63f2eb0 100644 --- a/opennebula_api/serializers.py +++ b/opennebula_api/serializers.py @@ -162,7 +162,10 @@ class VirtualMachineSerializer(serializers.Serializer): return '-' def get_name(self, obj): - return obj.name.lstrip('public-') + if obj.name.startswith('public-'): + return obj.name.lstrip('public-') + else: + return obj.name class VMTemplateSerializer(serializers.Serializer): From 6546814d622d32db90e11de266e0e7d9d734a832 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sat, 4 Aug 2018 09:52:15 +0200 Subject: [PATCH 14/38] Change VM terminate action from terminate to terminate hard --- opennebula_api/models.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opennebula_api/models.py b/opennebula_api/models.py index 29632009..3682c5da 100644 --- a/opennebula_api/models.py +++ b/opennebula_api/models.py @@ -315,7 +315,7 @@ class OpenNebulaManager(): return vm_id def delete_vm(self, vm_id): - TERMINATE_ACTION = 'terminate' + TERMINATE_ACTION = 'terminate-hard' vm_terminated = False try: self.oneadmin_client.call( From 93d489334f449ff7336bdd92514beb207e3dfcf5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 21:44:51 +0200 Subject: [PATCH 15/38] Load cms_templates later These templates are/were used in digitalglarus and hence are obsolete now. Later can be removed after testing. --- dynamicweb/settings/base.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 7d333a2f..7d62ceb5 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -179,9 +179,7 @@ ROOT_URLCONF = 'dynamicweb.urls' TEMPLATES = [ { 'BACKEND': 'django.template.backends.django.DjangoTemplates', - 'DIRS': [os.path.join(PROJECT_DIR, 'cms_templates/'), - os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'), - os.path.join(PROJECT_DIR, 'membership'), + 'DIRS': [os.path.join(PROJECT_DIR, 'membership'), os.path.join(PROJECT_DIR, 'hosting/templates/'), os.path.join(PROJECT_DIR, 'nosystemd/templates/'), os.path.join(PROJECT_DIR, @@ -192,6 +190,8 @@ TEMPLATES = [ os.path.join(PROJECT_DIR, 'ungleich_page/templates/ungleich_page'), os.path.join(PROJECT_DIR, 'templates/analytics'), + os.path.join(PROJECT_DIR, 'cms_templates/'), + os.path.join(PROJECT_DIR, 'cms_templates/djangocms_blog/'), ], 'APP_DIRS': True, 'OPTIONS': { From 0ddbdb045f669f1dae6f60898481e8941bf27eb2 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 21:48:25 +0200 Subject: [PATCH 16/38] Remove unused CMS templates --- dynamicweb/settings/base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index 7d62ceb5..f5cff4fe 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -215,18 +215,18 @@ TEMPLATES = [ WSGI_APPLICATION = 'dynamicweb.wsgi.application' CMS_TEMPLATES = ( - ('base_glarus.html', gettext('default')), - ('one_column.html', gettext('2 Column')), - ('two_columns.html', gettext('3 Column')), - ('about.html', gettext('DG.About')), - ('contact.html', gettext('DG.Contact')), - ('home_digitalglarus.html', gettext('DG.Home')), - ('letscowork.html', gettext('DG.CoWork')), - # ('detail.html', gettext('DG.Detail')), - ('one_column.html', gettext('DG.OneColumn')), + # ('base_glarus.html', gettext('default')), + # ('one_column.html', gettext('2 Column')), + # ('two_columns.html', gettext('3 Column')), + # ('about.html', gettext('DG.About')), + # ('contact.html', gettext('DG.Contact')), + # ('home_digitalglarus.html', gettext('DG.Home')), + # ('letscowork.html', gettext('DG.CoWork')), + # # ('detail.html', gettext('DG.Detail')), + # ('one_column.html', gettext('DG.OneColumn')), # ungleich ('blog_ungleich.html', gettext('Blog')), - ('page.html', gettext('Page')), + # ('page.html', gettext('Page')), # dcl ('datacenterlight/cms/base.html', gettext('Data Center Light')), ('ungleich_page/glasfaser_cms_page.html', gettext('Glasfaser')), From 0a3f51361f04ce2e0dd14a90a264b4d0d1f5c096 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 21:58:50 +0200 Subject: [PATCH 17/38] Add RSS feed icon and link --- ungleich/templates/cms/ungleichch/_header_base.html | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ungleich/templates/cms/ungleichch/_header_base.html b/ungleich/templates/cms/ungleichch/_header_base.html index d32f72e6..3dcb689f 100644 --- a/ungleich/templates/cms/ungleichch/_header_base.html +++ b/ungleich/templates/cms/ungleichch/_header_base.html @@ -31,6 +31,9 @@

{% page_attribute 'page_title' %}


{% page_attribute 'meta_description' %} +
+ +
From 48936ace5196ed78af78f8b2c7e708616b16d544 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 21:59:44 +0200 Subject: [PATCH 18/38] Revert back commenting out unwanted templates Todo in another pull request --- dynamicweb/settings/base.py | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/dynamicweb/settings/base.py b/dynamicweb/settings/base.py index f5cff4fe..7d62ceb5 100644 --- a/dynamicweb/settings/base.py +++ b/dynamicweb/settings/base.py @@ -215,18 +215,18 @@ TEMPLATES = [ WSGI_APPLICATION = 'dynamicweb.wsgi.application' CMS_TEMPLATES = ( - # ('base_glarus.html', gettext('default')), - # ('one_column.html', gettext('2 Column')), - # ('two_columns.html', gettext('3 Column')), - # ('about.html', gettext('DG.About')), - # ('contact.html', gettext('DG.Contact')), - # ('home_digitalglarus.html', gettext('DG.Home')), - # ('letscowork.html', gettext('DG.CoWork')), - # # ('detail.html', gettext('DG.Detail')), - # ('one_column.html', gettext('DG.OneColumn')), + ('base_glarus.html', gettext('default')), + ('one_column.html', gettext('2 Column')), + ('two_columns.html', gettext('3 Column')), + ('about.html', gettext('DG.About')), + ('contact.html', gettext('DG.Contact')), + ('home_digitalglarus.html', gettext('DG.Home')), + ('letscowork.html', gettext('DG.CoWork')), + # ('detail.html', gettext('DG.Detail')), + ('one_column.html', gettext('DG.OneColumn')), # ungleich ('blog_ungleich.html', gettext('Blog')), - # ('page.html', gettext('Page')), + ('page.html', gettext('Page')), # dcl ('datacenterlight/cms/base.html', gettext('Data Center Light')), ('ungleich_page/glasfaser_cms_page.html', gettext('Glasfaser')), From 53667451889ecd6e55e37821ef3296aec285ae30 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 22:39:43 +0200 Subject: [PATCH 19/38] Update Changelog --- Changelog | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index 6c48e4b5..95dace16 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,9 @@ +Next: + * #5308: [ipv6only] Fix - when creating a VM, the name begins with v6only + * #5293: Use `terminate-hard` action instead of `terminate` in the opennebula call to terminate a vm 2.0.3: 2018-07-18 * Remove unused /comic url (PR #644) - * 5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` (PR #645) + * #5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` (PR #645) 2.0.2: 2018-07-14 * bugfix: [blog] Add missing content block in the blog_ungleich.html template file 2.0.1: 2018-07-14 From e27317aeab5fdf8ed16562a95a9fae77f85e932a Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 23:24:02 +0200 Subject: [PATCH 20/38] Move rss icon from the header to the footer --- ungleich/templates/cms/ungleichch/_footer.html | 8 ++++++++ ungleich/templates/cms/ungleichch/_header_base.html | 3 --- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ungleich/templates/cms/ungleichch/_footer.html b/ungleich/templates/cms/ungleichch/_footer.html index 81194f69..94832ed4 100644 --- a/ungleich/templates/cms/ungleichch/_footer.html +++ b/ungleich/templates/cms/ungleichch/_footer.html @@ -30,6 +30,14 @@ +
  • + + + + + + +
  • {% page_attribute 'page_title' %}


    {% page_attribute 'meta_description' %} -
    - -
    From 895961868bbdcbd45f38cab57c86314f2e01c1c3 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 7 Aug 2018 23:39:43 +0200 Subject: [PATCH 21/38] Update Changelog for 2.0.4 --- Changelog | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Changelog b/Changelog index 95dace16..661d7978 100644 --- a/Changelog +++ b/Changelog @@ -1,6 +1,7 @@ -Next: - * #5308: [ipv6only] Fix - when creating a VM, the name begins with v6only - * #5293: Use `terminate-hard` action instead of `terminate` in the opennebula call to terminate a vm +2.0.4: 2018-08-07 + * Add RSS feed link to the footer of the blog template (PR #651) + * #5308: [ipv6only] Fix - when creating a VM, the name begins with v6only (PR #649) + * #5293: Use `terminate-hard` action instead of `terminate` in the opennebula call to terminate a vm (PR #650) 2.0.3: 2018-07-18 * Remove unused /comic url (PR #644) * #5126: Allow dynamicweb sites to be iframed on other by setting `X_FRAME_OPTIONS_ALLOW_FROM_URI` (PR #645) From 29c4cc44547992ec5216bec4d80477027d5d846d Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Aug 2018 00:10:03 +0200 Subject: [PATCH 22/38] Correct IPv6 VM name in serializer --- opennebula_api/serializers.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/opennebula_api/serializers.py b/opennebula_api/serializers.py index f63f2eb0..c7418aa5 100644 --- a/opennebula_api/serializers.py +++ b/opennebula_api/serializers.py @@ -36,7 +36,10 @@ class VirtualMachineTemplateSerializer(serializers.Serializer): return int(obj.template.memory) / 1024 def get_name(self, obj): - return obj.name.lstrip('public-') + if obj.name.startswith('public-'): + return obj.name.lstrip('public-') + else: + return obj.name class VirtualMachineSerializer(serializers.Serializer): @@ -133,7 +136,10 @@ class VirtualMachineSerializer(serializers.Serializer): def get_configuration(self, obj): template_id = obj.template.template_id template = OpenNebulaManager().get_template(template_id) - return template.name.lstrip('public-') + if template.name.startswith('public-'): + return template.name.lstrip('public-') + else: + return template.name def get_ipv4(self, obj): """ From 051408e1340b071a44ae66ef463b5b81c48ccb0f Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 8 Aug 2018 00:26:00 +0200 Subject: [PATCH 23/38] Update Changelog for 2.0.5 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index 661d7978..bc6a51dc 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.0.5: 2018-08-08 + * Fix IPv6 VM name in the billing invoice 2.0.4: 2018-08-07 * Add RSS feed link to the footer of the blog template (PR #651) * #5308: [ipv6only] Fix - when creating a VM, the name begins with v6only (PR #649) From 770b5e080bc6605e6365353177db2bb6aeda12c5 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 13:24:54 +0200 Subject: [PATCH 24/38] Make UserCardDetail brand field 35 chars long --- hosting/migrations/0047_auto_20180821_1124.py | 20 +++++++++++++++++++ hosting/models.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 hosting/migrations/0047_auto_20180821_1124.py diff --git a/hosting/migrations/0047_auto_20180821_1124.py b/hosting/migrations/0047_auto_20180821_1124.py new file mode 100644 index 00000000..b74a8870 --- /dev/null +++ b/hosting/migrations/0047_auto_20180821_1124.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-08-21 11:24 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0046_usercarddetail'), + ] + + operations = [ + migrations.AlterField( + model_name='usercarddetail', + name='brand', + field=models.CharField(max_length=35), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index 3ae3b0a5..338d6052 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -212,7 +212,7 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): permissions = ('view_usercarddetail',) stripe_customer = models.ForeignKey(StripeCustomer) last4 = models.CharField(max_length=4) - brand = models.CharField(max_length=10) + brand = models.CharField(max_length=35) card_id = models.CharField(max_length=100, blank=True, default='') fingerprint = models.CharField(max_length=100) exp_month = models.IntegerField(null=False) From 768b8ca8209886fc7459b1f65bf7078c63bd41fd Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 14:06:58 +0200 Subject: [PATCH 25/38] Change HostingOrder cc_brand field size to 35 chars --- hosting/migrations/0048_auto_20180821_1206.py | 20 +++++++++++++++++++ hosting/models.py | 2 +- 2 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 hosting/migrations/0048_auto_20180821_1206.py diff --git a/hosting/migrations/0048_auto_20180821_1206.py b/hosting/migrations/0048_auto_20180821_1206.py new file mode 100644 index 00000000..6939f63c --- /dev/null +++ b/hosting/migrations/0048_auto_20180821_1206.py @@ -0,0 +1,20 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-08-21 12:06 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0047_auto_20180821_1124'), + ] + + operations = [ + migrations.AlterField( + model_name='hostingorder', + name='cc_brand', + field=models.CharField(max_length=35), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index 338d6052..a15cdaa4 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -69,7 +69,7 @@ class HostingOrder(AssignPermissionsMixin, models.Model): created_at = models.DateTimeField(auto_now_add=True) approved = models.BooleanField(default=False) last4 = models.CharField(max_length=4) - cc_brand = models.CharField(max_length=10) + cc_brand = models.CharField(max_length=35) stripe_charge_id = models.CharField(max_length=100, null=True) price = models.FloatField() subscription_id = models.CharField(max_length=100, null=True) From 8bf6440110f9a545a53a62438ad3d5a45fb44f3a Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 14:41:16 +0200 Subject: [PATCH 26/38] Delete old migrations --- hosting/migrations/0047_auto_20180821_1124.py | 20 ------------------- hosting/migrations/0048_auto_20180821_1206.py | 20 ------------------- 2 files changed, 40 deletions(-) delete mode 100644 hosting/migrations/0047_auto_20180821_1124.py delete mode 100644 hosting/migrations/0048_auto_20180821_1206.py diff --git a/hosting/migrations/0047_auto_20180821_1124.py b/hosting/migrations/0047_auto_20180821_1124.py deleted file mode 100644 index b74a8870..00000000 --- a/hosting/migrations/0047_auto_20180821_1124.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-08-21 11:24 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('hosting', '0046_usercarddetail'), - ] - - operations = [ - migrations.AlterField( - model_name='usercarddetail', - name='brand', - field=models.CharField(max_length=35), - ), - ] diff --git a/hosting/migrations/0048_auto_20180821_1206.py b/hosting/migrations/0048_auto_20180821_1206.py deleted file mode 100644 index 6939f63c..00000000 --- a/hosting/migrations/0048_auto_20180821_1206.py +++ /dev/null @@ -1,20 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-08-21 12:06 -from __future__ import unicode_literals - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ('hosting', '0047_auto_20180821_1124'), - ] - - operations = [ - migrations.AlterField( - model_name='hostingorder', - name='cc_brand', - field=models.CharField(max_length=35), - ), - ] From b69abf3eddc001ad50b9b4c32897f32789a01ad0 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 14:42:01 +0200 Subject: [PATCH 27/38] Make CC brand 128 characters long --- hosting/migrations/0047_auto_20180821_1240.py | 25 +++++++++++++++++++ hosting/models.py | 4 +-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 hosting/migrations/0047_auto_20180821_1240.py diff --git a/hosting/migrations/0047_auto_20180821_1240.py b/hosting/migrations/0047_auto_20180821_1240.py new file mode 100644 index 00000000..7976c58d --- /dev/null +++ b/hosting/migrations/0047_auto_20180821_1240.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.9.4 on 2018-08-21 12:40 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('hosting', '0046_usercarddetail'), + ] + + operations = [ + migrations.AlterField( + model_name='hostingorder', + name='cc_brand', + field=models.CharField(max_length=128), + ), + migrations.AlterField( + model_name='usercarddetail', + name='brand', + field=models.CharField(max_length=128), + ), + ] diff --git a/hosting/models.py b/hosting/models.py index a15cdaa4..e9fcdc7e 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -69,7 +69,7 @@ class HostingOrder(AssignPermissionsMixin, models.Model): created_at = models.DateTimeField(auto_now_add=True) approved = models.BooleanField(default=False) last4 = models.CharField(max_length=4) - cc_brand = models.CharField(max_length=35) + cc_brand = models.CharField(max_length=128) stripe_charge_id = models.CharField(max_length=100, null=True) price = models.FloatField() subscription_id = models.CharField(max_length=100, null=True) @@ -212,7 +212,7 @@ class UserCardDetail(AssignPermissionsMixin, models.Model): permissions = ('view_usercarddetail',) stripe_customer = models.ForeignKey(StripeCustomer) last4 = models.CharField(max_length=4) - brand = models.CharField(max_length=35) + brand = models.CharField(max_length=128) card_id = models.CharField(max_length=100, blank=True, default='') fingerprint = models.CharField(max_length=100) exp_month = models.IntegerField(null=False) From cda6c60e026411c31c2b7380f7f2809d46677df7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 15:09:02 +0200 Subject: [PATCH 28/38] Update Changelog for 2.1 --- Changelog | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Changelog b/Changelog index bc6a51dc..bd3873c4 100644 --- a/Changelog +++ b/Changelog @@ -1,3 +1,5 @@ +2.1: 2018-08-21 + * Bugfix: Increase CC brand name fields from 10 to 128 characters 2.0.5: 2018-08-08 * Fix IPv6 VM name in the billing invoice 2.0.4: 2018-08-07 From 91021d761273db7230ae995faa595fd8b3043b5a Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 23:24:40 +0200 Subject: [PATCH 29/38] Add ping_ok utility method --- datacenterlight/utils.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py index 1c54148e..7734703b 100644 --- a/datacenterlight/utils.py +++ b/datacenterlight/utils.py @@ -1,3 +1,5 @@ +import logging +import subprocess from django.contrib.sites.models import Site from datacenterlight.tasks import create_vm_task @@ -8,6 +10,8 @@ from utils.models import BillingAddress from .cms_models import CMSIntegration from .models import VMPricing, VMTemplate +logger = logging.getLogger(__name__) + def get_cms_integration(name): current_site = Site.objects.get_current() @@ -91,3 +95,21 @@ def create_vm(billing_address_data, stripe_customer_id, specs, 'token', 'customer']: if session_var in request.session: del request.session[session_var] + + +def ping_ok(host_ipv6): + """ + A utility method to check if a host responds to ping requests. Note: the + function relies on `ping6` utility of debian to check. + + :param host_ipv6 str type parameter that represets the ipv6 of the host to + checked + :return True if the host responds to ping else returns False + """ + try: + output = subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, + shell=True) + except Exception as ex: + logger.debug(host_ipv6 + " not reachable via ping. Error = " + str(ex)) + return False + return True From a55587dbf3024dacd673de34aeb0320e01660dc7 Mon Sep 17 00:00:00 2001 From: PCoder Date: Tue, 21 Aug 2018 23:49:47 +0200 Subject: [PATCH 30/38] Wait for VM to be pingable before doing a manage_public_key --- datacenterlight/tasks.py | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 281d5f45..76216c16 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -8,6 +8,7 @@ from django.core.mail import EmailMessage from django.core.urlresolvers import reverse from django.utils import translation from django.utils.translation import ugettext_lazy as _ +from time import sleep from dynamicweb.celery import app from hosting.models import HostingOrder @@ -18,6 +19,7 @@ from utils.hosting_utils import get_all_public_keys, get_or_create_vm_detail from utils.mailer import BaseEmail from utils.stripe_utils import StripeUtils from .models import VMPricing +from .utils import ping_ok logger = get_task_logger(__name__) @@ -206,9 +208,32 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id): # Let's delay the task by 75 seconds to be sure # that we run the cdist configure after the host # is up - manager.manage_public_key( - keys, hosts=[vm_ipv6], countdown=75 - ) + did_manage_public_key = False + for i in range(0, 15): + if ping_ok(vm_ipv6): + logger.debug( + "{} is pingable. Doing a " + "manage_public_key".format(vm_ipv6) + ) + manager.manage_public_key( + keys, hosts=[vm_ipv6] + ) + did_manage_public_key = True + break + else: + logger.debug( + "Can't ping {}. Wait 5 secs".format( + vm_ipv6 + ) + ) + sleep(5) + if not did_manage_public_key: + logger.error( + "Waited for over 75 seconds for {} to be " + "pingable. But the VM was not reachable. So," + "gave up manage_public_key. Do this " + "manually".format(vm_ipv6) + ) except Exception as e: logger.error(str(e)) try: From 3b07687d3eb6e61e9182450f8b16ae9f4b4baaf8 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 00:12:14 +0200 Subject: [PATCH 31/38] Refactor ping_ok from datacenterlight.utils to utils.hosting_utils --- datacenterlight/utils.py | 19 ------------------- utils/hosting_utils.py | 19 +++++++++++++++++++ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/datacenterlight/utils.py b/datacenterlight/utils.py index 7734703b..8da408a0 100644 --- a/datacenterlight/utils.py +++ b/datacenterlight/utils.py @@ -1,5 +1,4 @@ import logging -import subprocess from django.contrib.sites.models import Site from datacenterlight.tasks import create_vm_task @@ -95,21 +94,3 @@ def create_vm(billing_address_data, stripe_customer_id, specs, 'token', 'customer']: if session_var in request.session: del request.session[session_var] - - -def ping_ok(host_ipv6): - """ - A utility method to check if a host responds to ping requests. Note: the - function relies on `ping6` utility of debian to check. - - :param host_ipv6 str type parameter that represets the ipv6 of the host to - checked - :return True if the host responds to ping else returns False - """ - try: - output = subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, - shell=True) - except Exception as ex: - logger.debug(host_ipv6 + " not reachable via ping. Error = " + str(ex)) - return False - return True diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index c0494b90..438dbc62 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -1,5 +1,6 @@ import decimal import logging +import subprocess from oca.pool import WrongIdError from datacenterlight.models import VMPricing @@ -130,6 +131,24 @@ def get_vm_price_with_vat(cpu, memory, ssd_size, hdd_size=0, return float(price), float(vat), float(vat_percent), discount +def ping_ok(host_ipv6): + """ + A utility method to check if a host responds to ping requests. Note: the + function relies on `ping6` utility of debian to check. + + :param host_ipv6 str type parameter that represets the ipv6 of the host to + checked + :return True if the host responds to ping else returns False + """ + try: + output = subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, + shell=True) + except Exception as ex: + logger.debug(host_ipv6 + " not reachable via ping. Error = " + str(ex)) + return False + return True + + class HostingUtils: @staticmethod def clear_items_from_list(from_list, items_list): From 893c8ed08b1c5513b05ae37af1c5f3e37b4ee507 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 00:14:17 +0200 Subject: [PATCH 32/38] Fix imports --- datacenterlight/tasks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 76216c16..c233f522 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -15,11 +15,12 @@ from hosting.models import HostingOrder from membership.models import CustomUser from opennebula_api.models import OpenNebulaManager from opennebula_api.serializers import VirtualMachineSerializer -from utils.hosting_utils import get_all_public_keys, get_or_create_vm_detail +from utils.hosting_utils import ( + get_all_public_keys, get_or_create_vm_detail, ping_ok +) from utils.mailer import BaseEmail from utils.stripe_utils import StripeUtils from .models import VMPricing -from .utils import ping_ok logger = get_task_logger(__name__) From 2ff7eaea65b6592e20785d89b093a578243f30a9 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 00:25:59 +0200 Subject: [PATCH 33/38] Sleep additional 10 seconds before running manage_public_key --- datacenterlight/tasks.py | 1 + 1 file changed, 1 insertion(+) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index c233f522..b7834343 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -216,6 +216,7 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id): "{} is pingable. Doing a " "manage_public_key".format(vm_ipv6) ) + sleep(10) manager.manage_public_key( keys, hosts=[vm_ipv6] ) From f56933021fdd189550f4d0fbaee53cdfb2938dbe Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 00:37:40 +0200 Subject: [PATCH 34/38] Also send an email if manage_ssh_key does not complete in time --- datacenterlight/tasks.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index b7834343..5f2390bb 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -230,12 +230,22 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id): ) sleep(5) if not did_manage_public_key: - logger.error( - "Waited for over 75 seconds for {} to be " - "pingable. But the VM was not reachable. So," - "gave up manage_public_key. Do this " - "manually".format(vm_ipv6) - ) + emsg = ("Waited for over 75 seconds for {} to be " + "pingable. But the VM was not reachable. " + "So, gave up manage_public_key. Please do " + "this manually".format(vm_ipv6)) + logger.error(emsg) + email_data = { + 'subject': '{} CELERY TASK INCOMPLETE: {} not ' + 'pingable for 75 seconds'.format( + settings.DCL_TEXT, vm_ipv6 + ), + 'from_email': current_task.request.hostname, + 'to': settings.DCL_ERROR_EMAILS_TO_LIST, + 'body': emsg + } + email = EmailMessage(**email_data) + email.send() except Exception as e: logger.error(str(e)) try: From 13876c24c178bf4eaaf4aabeaaaccee21287645a Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 00:42:50 +0200 Subject: [PATCH 35/38] Update doc --- datacenterlight/tasks.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/datacenterlight/tasks.py b/datacenterlight/tasks.py index 5f2390bb..2779f79b 100644 --- a/datacenterlight/tasks.py +++ b/datacenterlight/tasks.py @@ -206,9 +206,8 @@ def create_vm_task(self, vm_template_id, user, specs, template, order_id): host=vm_ipv6, num_keys=len(keys) ) ) - # Let's delay the task by 75 seconds to be sure - # that we run the cdist configure after the host - # is up + # Let's wait until the IP responds to ping before we + # run the cdist configure on the host did_manage_public_key = False for i in range(0, 15): if ping_ok(vm_ipv6): From e66e8202db773a0935f694f7f1776c4e02773d34 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 19:56:56 +0200 Subject: [PATCH 36/38] Remove unused variable --- utils/hosting_utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index 438dbc62..a69af8f5 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -141,8 +141,7 @@ def ping_ok(host_ipv6): :return True if the host responds to ping else returns False """ try: - output = subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, - shell=True) + subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, shell=True) except Exception as ex: logger.debug(host_ipv6 + " not reachable via ping. Error = " + str(ex)) return False From 432b54a86d6c1f7f47b14272a4ee217e3b7e0a09 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 20:27:19 +0200 Subject: [PATCH 37/38] Remove timeout parameter in ping6 request --- utils/hosting_utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/hosting_utils.py b/utils/hosting_utils.py index a69af8f5..1859a82c 100644 --- a/utils/hosting_utils.py +++ b/utils/hosting_utils.py @@ -141,7 +141,7 @@ def ping_ok(host_ipv6): :return True if the host responds to ping else returns False """ try: - subprocess.check_output("ping6 -c 1 -w 2 " + host_ipv6, shell=True) + subprocess.check_output("ping6 -c 1 " + host_ipv6, shell=True) except Exception as ex: logger.debug(host_ipv6 + " not reachable via ping. Error = " + str(ex)) return False From fb4591ef6ae1298c7e5961a90d05c75dbf04a763 Mon Sep 17 00:00:00 2001 From: PCoder Date: Wed, 22 Aug 2018 20:51:32 +0200 Subject: [PATCH 38/38] Update Changelog --- Changelog | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Changelog b/Changelog index bd3873c4..2538c802 100644 --- a/Changelog +++ b/Changelog @@ -1,5 +1,7 @@ +Next: + * 5473: Ping a VM before saving ssh key of the user (PR #655) 2.1: 2018-08-21 - * Bugfix: Increase CC brand name fields from 10 to 128 characters + * Bugfix: Increase CC brand name fields from 10 to 128 characters (PR #654) 2.0.5: 2018-08-08 * Fix IPv6 VM name in the billing invoice 2.0.4: 2018-08-07