def compile(self, ctx, service_name, service, barts):
        infra = service['infrastructure']

        # Add provider attributes
        for res_kind_name, res_kind_obj in infra.iteritems():
            for res_name, res in res_kind_obj.iteritems():
                res['provider'] = 'aws.%s' % service.get('environment', 'default')
            
        instances = infra.get('aws_instance', {})

        # Convert AMI name to id
        for inst_name, inst in instances.iteritems():
            ami = inst['ami']
            if ami in barts:
                inst['ami'] = barts[ami].id

        # Process commands
        for inst_name, inst in instances.iteritems():
            cmds = inst['cmds']
            boot_cmds = inst['bootCmds']
            if inst.get('user_data'):
                raise RuntimeError('Cannot use user_data, use cmds instead.')
            inst['user_data'] = self.compileStartupScript(cmds, boot_cmds)
            inst.pop('cmds', None)
            inst.pop('bootCmds', None)

        return {
            'service.%s.tf' % self.fullName(ctx, service_name): {
                'resource': infra,
                'output': {
                    k: { 'value': v }
                    for k, v in service['outputs'].iteritems()
                }
            }
        }
Beispiel #2
0
    def compile(self, ctx, service_name, service, barts):
        infra = service['infrastructure']

        # Add provider attributes
        for res_kind_name, res_kind_obj in infra.iteritems():
            for res_name, res in res_kind_obj.iteritems():
                res['provider'] = 'aws.%s' % service.get('environment', 'default')

        instances = infra.get('aws_instance', {})

        # Convert AMI name to id
        for inst_name, inst in instances.iteritems():
            ami = inst['ami']
            if ami in barts:
                inst['ami'] = barts[ami].id

        # Process commands
        for inst_name, inst in instances.iteritems():
            cmds = inst['cmds']
            boot_cmds = inst['bootCmds']
            if inst.get('user_data'):
                raise RuntimeError('Cannot use user_data, use cmds instead.')
            inst['user_data'] = self.compileStartupScript(cmds, boot_cmds)
            inst.pop('cmds', None)
            inst.pop('bootCmds', None)

        return {
            'service.%s.tf' % self.fullName(ctx, service_name): {
                'resource': infra,
                'output': {
                    k: { 'value': v }
                    for k, v in service['outputs'].iteritems()
                }
            }
        }
Beispiel #3
0
def storage(file):
    if request.method == 'GET':
        resp = service.get(file)
        if (resp == -1):
            return 'File not found', 404
        else:
            return resp, 200
    if request.method == 'DELETE':
        service.delete(file)
        return 'File deleted', 204
    if request.method == 'PUT':
        try:
            json.loads(request.data)
        except:
            return 'JSON isn`t right!', 400
        service.put(file, request.data)
        return 'File changed', 201
    return 'Error on server', 405
Beispiel #4
0
    def GET(self, path):
        web.header("Content-Type", "application/xml; charset=UTF-8")
        params = path.split('/')
        data = service.get(self, config=config, data=params)

        items = []
        for line in data:
            title = ""
            if line.has_key('title'):
                title += line['title'][0]

            if line.has_key('prefix'):
                title += ' - ' + line['prefix']

            if line.has_key('level'):
                title += ' [' + line['level'][0] + ']'

            link = ""
            if line.has_key('link'):
                link = line['link']

            desc = ""
            if line.has_key('content'):
                desc = line['content']

            guid = web.ctx.homedomain + '/' + str(line['_id'])
            pubDate = line['time']


            items.append(PyRSS2Gen.RSSItem(
                title = title,
                link = link,
                description = desc,
                guid = PyRSS2Gen.Guid(guid),
                pubDate = pubDate
                ))

        rss = PyRSS2Gen.RSS2(title = "Notification",
                             link = web.ctx.homedomain,
                             description = "Various notifications to the RSS.",
                             lastBuildDate = datetime.datetime.utcnow(),
                             items=items)
        return rss.to_xml()
Beispiel #5
0
def storage(file):
    auth = request.authorization
    if not auth or not auth.username or not auth.password or service.authorization(
            auth.username,
            hashlib.md5(auth.password.encode()).digest()) == False:
        return 'Authorization is failed', 401
    if request.method == 'GET':
        resp = service.get(file)
        if (resp == -1):
            return 'File not found', 404
        else:
            return resp['value'], 200
    if request.method == 'DELETE':
        service.delete(file)
        return 'File deleted', 204
    if request.method == 'PUT':
        try:
            json.loads(request.data)
        except:
            return 'JSON isn`t right!', 400
        service.put(file, request.data)
        return 'File changed', 201
    return 'Error on server', 405
Beispiel #6
0
 def get(self, request):
     """Returns a build by id."""
     build = service.get(request.id)
     if build is None:
         raise errors.BuildNotFoundError()
     return build_to_response_message(build)
Beispiel #7
0
 def get(self, request):
   """Returns a build by id."""
   build = service.get(request.id)
   if build is None:
     raise errors.BuildNotFoundError()
   return build_to_response_message(build)
Beispiel #8
0
 def test_get_with_auth_error(self):
   self.mock_cannot(acl.Action.VIEW_BUILD)
   self.test_build.put()
   with self.assertRaises(auth.AuthorizationError):
     service.get(self.test_build.key.id())
Beispiel #9
0
 def test_get_nonexistent_build(self):
   self.assertIsNone(service.get(42))
Beispiel #10
0
 def test_get(self):
   self.test_build.put()
   build = service.get(self.test_build.key.id())
   self.assertEqual(build, self.test_build)
Beispiel #11
0
def get_all_todos(db_session: session = Depends(get_db)) -> List[Todo]:
    return get(db_session=db_session)