Esempio n. 1
0
File: views.py Progetto: vpino/kds
    def get(self, request, format=None):

        recipe_Name = request.query_params.get('name', None)
        
        if recipe_Name:

            SERVICE = CharmDirectory(get_path([SERVICEDIR, recipe_Name]))
            
            if SERVICE:
            
                config = {}

                campos = []

                for k, v in SERVICE.config._data.iteritems():
                    d = {}
                    d['field_name'] = k
                    d['nombre'] = v.get('name', None)
                    d['default'] = v.get('default', None)
                    d['tipo'] = v.get('type', None)
                    d['items'] = v.get('items', None)
                    campos.append(d)

                config['campos'] = campos
                config['ipadd'] = ''
                config['username'] = ''
                config['passwd'] = ''

                return Response (config)

            else:

                return Response (status=status.HTTP_404_NOT_FOUND)

        return Response (status=status.HTTP_404_NOT_FOUND)
Esempio n. 2
0
 def get(self, request, service_name, format=None):
     
     SERVICE = RecipeDir(get_path([SERVICEDIR, 'service_name']))
     
     return Response([ServiceObject({
                 'name': SERVICE.metadata.name,
                 'summary': SERVICE.metadata.summary,
                 'maintainer': SERVICE.metadata.maintainer,
                 'description': SERVICE.metadata.description,
                 'components' : SERVICE.metadata.components.items()
             })])
Esempio n. 3
0
    def get(self, request, format=None):

        service_name = request.query_params.get('name', None)
        action = request.query_params.get('action', None)

        #tail = TailLog(BASE_DIR+"/", 'playbook-log')

        if service_name != '':

            try:
                    
                config = {}

                campos = []

                if action == 'install':

                    SERVICE = CharmDirectory(get_path([SERVICEDIR, service_name]))

                    for k, v in SERVICE.config._data.iteritems():

                        d = {}
                        d['field_name'] = k
                        d['nombre'] = v.get('name', None)
                        d['default'] = v.get('default', None)
                        d['tipo'] = v.get('type', None)
                        d['items'] = v.get('items', None)
                        campos.append(d)

                    config['campos'] = campos
                    config['ipadd'] = ''
                    config['username'] = ''
                    config['passwd'] = ''
                    config['receta'] = service_name
                    config['action'] = ''

                if action == 'update':

                    SERVICE = parseYaml(SERVICEDIR + '/' + service_name , '/config.yaml' )

                    for k, v in SERVICE['update'].iteritems():

                        d = {}

                        d['field_name'] = k
                        d['nombre'] = v.get('name', None)
                        d['default'] = v.get('default', None)
                        d['tipo'] = v.get('type', None)
                        d['items'] = v.get('items', None)
                        campos.append(d)

                    config['campos'] = campos
                    config['username'] = ''
                    config['passwd'] = ''
                    config['receta'] = service_name
                    config['action'] = ''

                if action == 'delete':

                    SERVICE = parseYaml(SERVICEDIR + '/' + service_name , '/config.yaml' )
                    
                    d = {}
                    d['nombre'] = 'delete'
                    campos.append(d)

                    config['campos'] = campos
                    config['username'] = ''
                    config['passwd'] = ''
                    config['receta'] = service_name
                    config['action'] = ''

                return Response (config)

            except:
                
               return Response (status=status.HTTP_404_NOT_FOUND)

        return Response (status=status.HTTP_404_NOT_FOUND)