示例#1
0
 def UploadFile(self, request, context):
     instance_id = request.vdu.name
     port = u.get_port_from_vdu(request.vdu)
     if port == None:
         raise ValueError("VDU metadata does not contain a port")
     ssh_exec = ssh_client.SSHExecutor(vm_name=instance_id, port=port)
     type = request.property[0]
     if (type == "withPath"):
         remotePath = request.property[4]
         hostPath = request.property[3]
         logging.info("Uploading a file " + hostPath + " to " + remotePath)
         ssh_exec.upload_file_from_path(hostPath=hostPath,
                                        remotePath=remotePath)
         return client_pb2.Empty()
     else:
         path = request.property[0]
         logging.info("Uploading a file to " + path)
         file = request.file
         ssh_exec.upload_file(path, file)
         return client_pb2.Empty()
示例#2
0
    def UploadFile(self, request, context):

        instance_id = request.vdu.ip
        # TODO: FIX
        user = "******"
        password = ""
        ssh_exec = ssh_client.SSHExecutor(instance_id, user, password=password)
        type = request.property[0]
        if (type == "withPath"):
            remotePath = request.property[4]
            hostPath = request.property[3]
            logging.info("Uploading a file " + hostPath + " to " + remotePath)
            ssh_exec.upload_file_from_path(hostPath=hostPath,
                                           remotePath=remotePath)
            return client_pb2.Empty()
        else:
            path = request.property[0]
            logging.info("Uploading a file to " + path)
            file = request.file
            ssh_exec.upload_file(path, file)
            return client_pb2.Empty()
示例#3
0
 def Start(self, request, context):
     instance_id = request.resource_id
     db = shelve.open('auths.db')
     auth = db[str(instance_id) + "_auth"]
     db.close()
     logging.info("Starting instance " + instance_id)
     if auth.has_key("auth_url") and auth.has_key(
             "username") and auth.has_key("password"):
         ansible_executor.execute_play(
             start_instance_play(instance_id, auth))
     elif auth.has_key("aws_access_key") and auth.has_key("aws_secret_key"):
         ansible_executor.execute_play(
             start_instance_play_aws(instance_id, auth))
     else:
         raise ValueError("No proper auth found!")
     return client_pb2.Empty()
示例#4
0
 def Remove(self, request, context):
     logging.debug(request)
     for vdu in request.vdu:
         instance_id = vdu.computeId
         auth = epm_utils.check_package_pop(request.pop.auth)
         if auth.has_key("auth_url") and auth.has_key(
                 "username") and auth.has_key("password"):
             ansible_executor.execute_play(
                 delete_instance_play(instance_id, auth))
         elif auth.has_key("aws_access_key") and auth.has_key(
                 "aws_secret_key"):
             ansible_executor.execute_play(
                 delete_instance_play_aws(instance_id, auth))
         else:
             raise ValueError("No proper auth found!")
     logging.info("Removed all VDUs")
     return client_pb2.Empty()
示例#5
0
 def Stop(self, request, context):
     name = request.vdu.name
     vbox_handler.stop_vm(name)
     return client_pb2.Empty()
示例#6
0
 def Remove(self, request, context):
     package_name = request.resource_id
     vbox_handler.delete_vms(package_name)
     return client_pb2.Empty()