def destroy(self, yml): u = User.objects.get(email=self.username) #print self.base_yaml+yml xt = XOSTosca(self.base_yaml+yml, parent_dir=parentdir, log_to_console=False) xt.destroy(u)
def DestroyTosca(self, request, context): user = self.authenticate(context, required=True) sys_path_save = sys.path try: sys.path.append(toscadir) from tosca.engine import XOSTosca xt = XOSTosca(request.recipe, parent_dir=toscadir, log_to_console=False) xt.destroy(user) except BaseException: response = utility_pb2.ToscaResponse() response.status = response.ERROR response.messages = traceback.format_exc() return response finally: sys.path = sys_path_save response = utility_pb2.ToscaResponse() response.status = response.SUCCESS response.messages = "\n".join(xt.log_msgs) return response
def execute(self, yml): u = User.objects.get(email=self.username) # save test tosca to a temporary file (tf_h, tf_p) = tempfile.mkstemp(dir="/tmp/", prefix=("tosca_test_%s_" % self.current_test)) # print "Saving TOSCA to file: '%s'" % tf_p os.write(tf_h, self.base_yaml+yml) os.close(tf_h) xt = XOSTosca(self.base_yaml+yml, parent_dir=parentdir, log_to_console=False) xt.execute(u)
def main(): if len(sys.argv)<3: print "Syntax: destroy.py <username> <yaml-template-name>" sys.exit(-1) username = sys.argv[1] template_name = sys.argv[2] u = User.objects.get(email=username) xt = XOSTosca(file(template_name).read(), parent_dir=currentdir, log_to_console=True) xt.destroy(u)
def main(): if len(sys.argv)<3: print "Syntax: run.py <username> <yaml-template-name>" sys.exit(-1) username = sys.argv[1] template_name = sys.argv[2] u = User.objects.get(email=username) xt = XOSTosca(file(template_name).read(), parent_dir=currentdir) xt.execute(u)
def main(): if len(sys.argv)<3: print "Syntax: run.py <username> <yaml-template-name>" sys.exit(-1) username = sys.argv[1] template_name = sys.argv[2] if username.lower()=="none": u=None else: u = User.objects.get(email=username) xt = XOSTosca(file(template_name).read(), parent_dir=currentdir, log_to_console=True) xt.execute(u)
def execute(self, yml): u = User.objects.get(email=self.username) # save test tosca to a temporary file (tf_h, tf_p) = tempfile.mkstemp(dir="/tmp/", prefix=("tosca_test_%s_" % self.current_test)) # print "Saving TOSCA to file: '%s'" % tf_p os.write(tf_h, self.base_yaml + yml) os.close(tf_h) xt = XOSTosca(self.base_yaml + yml, parent_dir=parentdir, log_to_console=False) xt.execute(u)
def post_run(self, request): recipe = request.data.get("recipe", None) sys_path_save = sys.path try: sys.path.append(toscadir) from tosca.engine import XOSTosca xt = XOSTosca(recipe, parent_dir=toscadir, log_to_console=False) xt.execute(request.user) except BaseException: return Response({"error_text": traceback.format_exc()}, status=500) finally: sys.path = sys_path_save
def post_run(self, request): result = [] recipe = request.data.get("recipe", None) sys_path_save = sys.path try: sys.path.append(toscadir) from tosca.engine import XOSTosca xt = XOSTosca(recipe, parent_dir=toscadir, log_to_console=False) xt.execute(request.user) except: return Response( {"error_text": traceback.format_exc()}, status=500 ) finally: sys.path = sys_path_save return Response( {"log_msgs": xt.log_msgs} )
def main(): if len(sys.argv) < 3: print "Syntax: run.py <username> <yaml-template-name>" sys.exit(-1) username = sys.argv[1] template_name = sys.argv[2] if username.lower() == "none": u = None else: u = User.objects.get(email=username) if template_name == "-": tosca_source = sys.stdin.read() else: tosca_source = file(template_name).read() xt = XOSTosca(tosca_source, parent_dir=currentdir, log_to_console=True) xt.execute(u)