Ejemplo n.º 1
0
 def mail_to_request_user(self):
     send_to = [self.market_image.creator]
     image_type = ""
     for type_choice in PUBLISH_IMAGE_BACKEND['type_choices']:
         if self.market_image.base_type == type_choice[0]:
             image_type = type_choice[1]
     final_info = self.market_image.extra_info.get("final_info", {})
     topic = {
         'creator_id': self.market_image.creator_id,
         'creator': self.market_image.creator,
         'image_id': self.market_image.id,
         'final_image_id': self.market_image.final_image_id,
         'title_en': final_info.get('title_en', ""),
         'details_en': final_info.get('details_en', ""),
         'integrated_software': final_info.get('integrated_software', ""),
         'introduction_en': final_info.get('introduction_en', ""),
         'title': final_info.get('title', ""),
         'details': final_info.get('details', ""),
         'introduction': final_info.get('introduction', ""),
         'image_type': image_type,
         'tags': self.market_image.tags.get("final_tags", "")
     }
     subject = '%s is published successful' % self.market_image.id
     html_content = loader.render_to_string(self.email_template,
                                            {'topic': topic})
     send_mail_task.delay(subject, html_content, jsonpickle.encode(send_to))
Ejemplo n.º 2
0
 def mail_to_admin(self):
     send_to = []
     base_type = ""
     for config in OPENSTACK_CONFIG_BACKEND['configs']:
         if config['region'] == self.request.user.services_region:
             send_to = config['image_admin_email_list']
     for type_choice in PUBLISH_IMAGE_BACKEND['type_choices']:
         if self.market_image.base_type == type_choice[0]:
             base_type = type_choice[1]
     info = self.market_image.extra_info.get("info", {})
     tags = self.market_image.tags.get("tags", "")
     topic = {
         'request_title': _("request update information for image"),
         'creator_id': self.market_image.creator_id,
         'creator': self.market_image.creator,
         'image_id': self.market_image.id,
         'title_en': info.get("title_en", ""),
         'details_en': info.get('details_en', ""),
         'integrated_software': info.get('integrated_software', ""),
         'introduction_en': info.get('introduction_en', ""),
         'title': info.get('title', ""),
         'details': info.get('details', ""),
         'introduction': info.get('introduction', ""),
         'base_type': base_type,
         'tags': tags
     }
     subject = _('%s request update publish image %s') % (
         self.market_image.creator, self.market_image.id)
     html_content = loader.render_to_string(self.email_template,
                                            {'topic': topic})
     LOG.debug('send mail to admin')
     send_mail_task.delay(subject, html_content, jsonpickle.encode(send_to))
Ejemplo n.º 3
0
 def mail_to_request_user(self):
     send_to = [self.market_image.creator]
     image_type = ""
     for type_choice in PUBLISH_IMAGE_BACKEND['type_choices']:
         if self.market_image.base_type == type_choice[0]:
             image_type = type_choice[1]
     final_info = self.market_image.extra_info.get("final_info", {})
     topic = {
         'creator_id': self.market_image.creator_id,
         'creator': self.market_image.creator,
         'image_id': self.market_image.id,
         'final_image_id': self.market_image.final_image_id,
         'title_en': final_info.get('title_en', ""),
         'details_en': final_info.get('details_en', ""),
         'integrated_software': final_info.get('integrated_software', ""),
         'introduction_en': final_info.get('introduction_en', ""),
         'title': final_info.get('title', ""),
         'details': final_info.get('details', ""),
         'introduction': final_info.get('introduction', ""),
         'image_type': image_type,
         'tags': self.market_image.tags.get("final_tags", "")
     }
     subject = '%s is published successful' % self.market_image.id
     html_content = loader.render_to_string(self.email_template, {'topic': topic})
     send_mail_task.delay(subject, html_content, jsonpickle.encode(send_to))
Ejemplo n.º 4
0
    def send_email(self):
        if self.vpn_username and self.vpn_password:
            topic = {
                'vpn_account': self.vpn_username,
                'vpn_password': self.vpn_password
            }
            subject = 'VPN Account for OpenPOWER(This is autoSend email, Please do not reply!)'
            html_content = loader.render_to_string(self.vpn_email_template,
                                                   {'topic': topic})
            user_list = [self.request.user.username]
            if not self.request.user.is_superuser:
                send_mail_task.delay(subject, html_content,
                                     jsonpickle.encode(user_list))
            messages.success(
                self.request,
                _("VPN account has been sent to your email! Please check it!"))

        topic = {
            'region': self.request.user.services_region,
            'instance_name': self.instance_name,
            'fixed_ip': self.private_ip,
            'floating_ip': self.floating_ip.ip
        }
        subject = _(
            'Instance %s (This is autoSend email, Please do not reply!)'
        ) % self.instance_name
        vpns = []
        for region in self.request.user.available_services_regions:
            vpn = {"region": region}
            try:
                vpn_tmp = VpnAccount.objects.get(user_id=self.request.user.id,
                                                 region=region)
                if vpn_tmp.password != "":
                    vpn['title'] = _("VPN Account name: %s") % vpn_tmp.name
                    vpn['body'] = _("Password is %s") % vpn_tmp.password
                else:
                    vpn['title'] = _(
                        "VPN Configure file "
                        "<a href='http://218.75.77.116%s' target='_blank' "
                        "class='link-u' style='color:#40bfc4; "
                        "text-decoration:underline'>"
                        "<span class='link-u' style='color:#40bfc4; text-decoration:underline'>"
                        "%s</span></a> (Click to download)") % (vpn_tmp.link,
                                                                vpn_tmp.name)
                    vpn['body'] = ""
            except Exception:
                vpn['title'] = "No VPN Account"
            vpns.append(vpn)

        html_content = loader.render_to_string(self.instance_email_template, {
            'topic': topic,
            'vpns': vpns,
        })
        user_list = [self.request.user.username]
        if not self.request.user.is_superuser:
            send_mail_task.delay(subject, html_content,
                                 jsonpickle.encode(user_list))
Ejemplo n.º 5
0
    def send_email(self):
        if self.vpn_username and self.vpn_password:
            topic = {'vpn_account': self.vpn_username, 'vpn_password': self.vpn_password}
            subject = 'VPN Account for OpenPOWER(This is autoSend email, Please do not reply!)'
            html_content = loader.render_to_string(
                self.vpn_email_template,
                {
                    'topic': topic
                }
            )
            user_list = [self.request.user.username]
            if not self.request.user.is_superuser:
                send_mail_task.delay(subject, html_content, jsonpickle.encode(user_list))
            messages.success(self.request, _("VPN account has been sent to your email! Please check it!"))

        topic = {
            'region': self.request.user.services_region,
            'instance_name': self.instance_name,
            'fixed_ip': self.private_ip,
            'floating_ip': self.floating_ip.ip
        }
        subject = _('Instance %s (This is autoSend email, Please do not reply!)') % self.instance_name
        vpns = []
        for region in self.request.user.available_services_regions:
            vpn = {"region": region}
            try:
                vpn_tmp = VpnAccount.objects.get(user_id=self.request.user.id, region=region)
                if vpn_tmp.password != "":
                    vpn['title'] = _("VPN Account name: %s") % vpn_tmp.name
                    vpn['body'] = _("Password is %s") % vpn_tmp.password
                else:
                    vpn['title'] = _("VPN Configure file "
                                     "<a href='http://218.75.77.116%s' target='_blank' "
                                     "class='link-u' style='color:#40bfc4; "
                                     "text-decoration:underline'>"
                                     "<span class='link-u' style='color:#40bfc4; text-decoration:underline'>"
                                     "%s</span></a> (Click to download)") % (vpn_tmp.link,
                                                                             vpn_tmp.name)
                    vpn['body'] = ""
            except Exception:
                vpn['title'] = "No VPN Account"
            vpns.append(vpn)

        html_content = loader.render_to_string(
            self.instance_email_template,
            {
                'topic': topic,
                'vpns': vpns,
            }
        )
        user_list = [self.request.user.username]
        if not self.request.user.is_superuser:
            send_mail_task.delay(subject, html_content, jsonpickle.encode(user_list))
Ejemplo n.º 6
0
 def mail_to_request_user(self):
     send_to = [self.market_image.creator]
     image_type = ""
     for type_choice in PUBLISH_IMAGE_BACKEND['type_choices']:
         if self.market_image.base_type == type_choice[0]:
             image_type = type_choice[1]
     topic = {
         'creator_id':
         self.market_image.creator_id,
         'creator':
         self.market_image.creator,
         'image_id':
         self.market_image.id,
         'final_image_id':
         self.market_image.final_image_id,
         'title_en':
         self.market_image.extra_info['final_info']['title_en'],
         'details_en':
         self.market_image.extra_info['final_info']['details_en'],
         'integrated_software':
         self.market_image.extra_info['final_info']['integrated_software'],
         'introduction_en':
         self.market_image.extra_info['final_info']['introduction_en'],
         'title':
         self.market_image.extra_info['final_info']['title'],
         'details':
         self.market_image.extra_info['final_info']['details'],
         'introduction':
         self.market_image.extra_info['final_info']['introduction'],
         'image_type':
         image_type,
         'tags':
         self.market_image.tags['final_tags']
     }
     subject = 'information for image %s is updated.' % self.market_image.id
     html_content = loader.render_to_string(self.email_template,
                                            {'topic': topic})
     send_mail_task.delay(subject, html_content, jsonpickle.encode(send_to))
Ejemplo n.º 7
0
 def mail_to_request_user(self):
     send_to = [self.market_image.creator]
     image_type = ""
     for type_choice in PUBLISH_IMAGE_BACKEND['type_choices']:
         if self.market_image.base_type == type_choice[0]:
             image_type = type_choice[1]
     topic = {
         'creator_id': self.market_image.creator_id,
         'creator': self.market_image.creator,
         'image_id': self.market_image.id,
         'final_image_id': self.market_image.final_image_id,
         'title_en': self.market_image.extra_info['final_info']['title_en'],
         'details_en': self.market_image.extra_info['final_info']['details_en'],
         'integrated_software': self.market_image.extra_info['final_info']['integrated_software'],
         'introduction_en': self.market_image.extra_info['final_info']['introduction_en'],
         'title': self.market_image.extra_info['final_info']['title'],
         'details': self.market_image.extra_info['final_info']['details'],
         'introduction': self.market_image.extra_info['final_info']['introduction'],
         'image_type': image_type,
         'tags': self.market_image.tags['final_tags']
     }
     subject = 'information for image %s is updated.' % self.market_image.id
     html_content = loader.render_to_string(self.email_template, {'topic': topic})
     send_mail_task.delay(subject, html_content, jsonpickle.encode(send_to))