예제 #1
0
 def render_view(self, req, id):
     template,data,content_type = Droplet.render_view(self, req, id)
     if self._is_disable_api_termination(req, id):
         attrs = data.get('delete_attrs',{})
         attrs['disabled'] = 'disabled'
         data['delete_attrs'] = attrs
     return template, data, content_type
예제 #2
0
 def render_view(self, req, id):
     template,data,content_type = Droplet.render_view(self, req, id)
     deploy = self._get_command('deploy')
     audit = self._get_command('audit')
     
     if deploy:
         attrs = {}
         progress_file = self._is_deploying(id)
         if progress_file:
             href = req.href.cloud(self.name, action='progress',
                                   file=progress_file)
             data['message'] = '<b>Deploying!</b> Track the %s' % id + \
               ' deployment <a href=\\"%s\\">here</a>.' % href
             attrs = {'disabled':'disabled'}
         button = ('execute',_('Deploy to %(label)s',label=self.label),attrs)
         data['buttons'].append(button)
         
     if audit:
         button = ('audit',_('Audit %(label)s',label=self.label),{})
         data['buttons'].append(button)
     
     if not deploy and not audit:
         data['cmd_fields'] = []
         
     return template, data, content_type
예제 #3
0
 def render_view(self, req, id):
     template, data, content_type = Droplet.render_view(self, req, id)
     if self._is_disable_api_termination(req, id):
         attrs = data.get('delete_attrs', {})
         attrs['disabled'] = 'disabled'
         data['delete_attrs'] = attrs
     return template, data, content_type
예제 #4
0
    def render_view(self, req, id):
        template, data, content_type = Droplet.render_view(self, req, id)
        deploy = self._get_command('deploy')
        audit = self._get_command('audit')

        if deploy:
            attrs = {}
            progress_file = self._is_deploying(id)
            if progress_file:
                href = req.href.cloud(self.name,
                                      action='progress',
                                      file=progress_file)
                data['message'] = '<b>Deploying!</b> Track the %s' % id + \
                  ' deployment <a href=\\"%s\\">here</a>.' % href
                attrs = {'disabled': 'disabled'}
            button = ('execute', _('Deploy to %(label)s',
                                   label=self.label), attrs)
            data['buttons'].append(button)

        if audit:
            button = ('audit', _('Audit %(label)s', label=self.label), {})
            data['buttons'].append(button)

        if not deploy and not audit:
            data['cmd_fields'] = []

        return template, data, content_type
예제 #5
0
 def render_view(self, req, id):
     template,data,content_type = Droplet.render_view(self, req, id)
     if id in ('deploy','audit'):
         href = req.href.cloud('env')
         data['message'] = 'To %s, use the respective button in an' % id + \
           ' <a href=\\"%s\\">Environment\\\'s view</a>.' % href
         data['cmd_fields'] = [] # clear command fields
     else:
         button = ('execute',_('Execute %(label)s',label=self.label),{})
         data['buttons'].append(button)
     return template, data, content_type
예제 #6
0
 def render_grid(self, req):
     template,data,content_type = Droplet.render_grid(self, req)
     button = ('audit',_('Audit %(title)s',title=self.title))
     data['buttons'].append(button),
     return template, data, content_type
예제 #7
0
 def render_grid(self, req):
     template, data, content_type = Droplet.render_grid(self, req)
     button = ('audit', _('Audit %(title)s', title=self.title))
     data['buttons'].append(button),
     return template, data, content_type
예제 #8
0
    def process_request(self, req):
        req.perm.require('CLOUD_VIEW')

        # setup cloud droplets
        if not hasattr(self, 'droplets'):
            # setup chefapi and cloudapi
            chefapi = Chef(self.chef_base_path, self.aws_keypair_pem,
                           self.aws_username, self.chef_boot_run_list,
                           self.chef_boot_sudo, self.chef_boot_version,
                           self.log)

            cloudapi = Aws(self.aws_key, self.aws_secret, self.aws_keypair,
                           self.aws_security_groups, self.rds_username,
                           self.rds_password, self.log)

            # instantiate each droplet (singletons)
            self.droplets = {}
            self.titles = Droplet.titles(self.env)
            for _order, droplet_name, _title in self.titles:
                self.droplets[droplet_name] = Droplet.new(
                    self.env, droplet_name, chefapi, cloudapi,
                    self.field_handlers, self.log)

        # ensure at least one droplet exists
        if not self.droplets:
            raise ResourceNotFound(_("No cloud resources found in trac.ini."),
                                   _('Missing Cloud Resource'))

        droplet_name = req.args.get('droplet_name', '')
        id = req.args.get('id', '')
        action = req.args.get('action', 'view')
        file = req.args.get('file', '')

        if not droplet_name:
            droplet_name = self.default_resource
            if not droplet_name:
                _order, droplet_name, _title = self.titles[0]
            req.redirect(req.href.cloud(droplet_name))

        # check for valid kind
        if droplet_name not in self.droplets:
            raise ResourceNotFound(
                _("Cloud resource '%(droplet_name)s' does not exist.",
                  droplet_name=droplet_name), _('Invalid Cloud Resource'))

        # retrieve the droplet
        droplet = self.droplets[droplet_name]

        # route the request
        if req.method == 'POST':
            if 'cancel' in req.args:
                req.redirect(req.href.cloud(droplet_name, id))
            elif action == 'new':
                droplet.create(req)
            elif action == 'delete':
                droplet.delete(req, id)
            elif action == 'edit':
                droplet.save(req, id)
            elif action == 'audit' or 'audit' in req.args:
                droplet.audit(req, id)
            elif action == 'execute' or 'execute' in req.args:
                droplet.execute(req, id)
        else:  # req.method == 'GET':
            if action in ('edit', 'new'):
                template, data, content_type = droplet.render_edit(req, id)
                Chrome(self.env).add_wiki_toolbars(req)
            elif action == 'delete':
                template, data, content_type = droplet.render_delete(req, id)
            elif action == 'progress':
                template, data, content_type = droplet.render_progress(
                    req, file)
            elif id == '':
                template, data, content_type = droplet.render_grid(req)
                if content_type:  # i.e. alternate format
                    return template, data, content_type
            else:
                template, data, content_type = droplet.render_view(req, id)
                if content_type:  # i.e. alternate format
                    return template, data, content_type

        # add contextual nav
        for _order, droplet_name, title in self.titles:
            add_ctxtnav(req, title, href=req.href.cloud(droplet_name))

        add_stylesheet(req, 'common/css/report.css')  # reuse css
        return template, data, None
예제 #9
0
 def process_request(self, req):
     req.perm.require('CLOUD_VIEW')
     
     # setup cloud droplets
     if not hasattr(self, 'droplets'):
         # setup chefapi and cloudapi
         chefapi = Chef(self.chef_base_path,
                           self.aws_keypair_pem,
                           self.aws_username,
                           self.chef_boot_run_list,
                           self.chef_boot_sudo,
                           self.chef_boot_version,
                           self.log)
         
         cloudapi = Aws(self.aws_key,
                           self.aws_secret,
                           self.aws_keypair,
                           self.aws_security_groups,
                           self.rds_username,
                           self.rds_password,
                           self.log)
         
         # instantiate each droplet (singletons)
         self.droplets = {}
         self.titles = Droplet.titles(self.env)
         for _order,droplet_name,_title in self.titles:
             self.droplets[droplet_name] = Droplet.new(self.env,
                 droplet_name, chefapi, cloudapi,
                 self.field_handlers, self.log)
     
     # ensure at least one droplet exists
     if not self.droplets:
         raise ResourceNotFound(
             _("No cloud resources found in trac.ini."),
             _('Missing Cloud Resource'))
     
     droplet_name = req.args.get('droplet_name', '')
     id = req.args.get('id', '')
     action = req.args.get('action', 'view')
     file = req.args.get('file', '')
     
     if not droplet_name:
         droplet_name = self.default_resource
         if not droplet_name:
             _order,droplet_name,_title = self.titles[0]
         req.redirect(req.href.cloud(droplet_name))
     
     # check for valid kind
     if droplet_name not in self.droplets:
         raise ResourceNotFound(
             _("Cloud resource '%(droplet_name)s' does not exist.",
               droplet_name=droplet_name),
             _('Invalid Cloud Resource'))
         
     # retrieve the droplet
     droplet = self.droplets[droplet_name]
     
     # route the request
     if req.method == 'POST':
         if 'cancel' in req.args:
             req.redirect(req.href.cloud(droplet_name,id))
         elif action == 'new':
             droplet.create(req)
         elif action == 'delete':
             droplet.delete(req, id)
         elif action == 'edit':
             droplet.save(req, id)
         elif action == 'audit' or 'audit' in req.args:
             droplet.audit(req, id)
         elif action == 'execute' or 'execute' in req.args:
             droplet.execute(req, id)
     else: # req.method == 'GET':
         if action in ('edit', 'new'):
             template,data,content_type = droplet.render_edit(req, id)
             Chrome(self.env).add_wiki_toolbars(req)
         elif action == 'delete':
             template,data,content_type = droplet.render_delete(req, id)
         elif action == 'progress':
             template,data,content_type = droplet.render_progress(req,file)
         elif id == '':
             template,data,content_type = droplet.render_grid(req)
             if content_type: # i.e. alternate format
                 return template,data,content_type
         else:
             template,data,content_type = droplet.render_view(req, id)
             if content_type: # i.e. alternate format
                 return template,data,content_type
     
     # add contextual nav
     for _order,droplet_name,title in self.titles:
         add_ctxtnav(req, title, href=req.href.cloud(droplet_name))
     
     add_stylesheet(req, 'common/css/report.css') # reuse css
     return template, data, None