Beispiel #1
0
def main():
    signal.signal(signal.SIGUSR1, handle_ipdb)
    set_umask()
    check_arguments(sys.argv)
    if sys.argv[1] == 'uuid':
        print "You can use the following unique name as your bucket name for amazon S3 or google storage:"
        print "cloudfusion_" + get_uuid()
        sys.exit()
    parser = MyParser()
    parser.add_argument('mountpoint')
    parser.add_argument('--config', help='Configuration file.')
    parser.add_argument(
        'args', nargs=argparse.REMAINDER
    )  #collect all arguments positioned after positional and optional parameters
    args = parser.parse_args()
    foreground = 'foreground' in args.args
    profiling_enabled = 'profile' in args.args
    mountpoint = args.mountpoint
    if "stop" in args.args:
        start_stopping_thread(mountpoint)
        exit(0)
    if not "log" in args.args:
        logging.getLogger().addHandler(NullHandler())
    else:
        if not os.path.exists(".cloudfusion/logs"):
            os.makedirs(".cloudfusion/logs")
        logging.config.fileConfig(
            os.path.dirname(cloudfusion.__file__) + '/config/logging.conf')
        db_logging_thread.start()
    if args.config:  #evaluates to false
        if not os.path.exists(args.config):
            exit(1)
        start_configuration_thread(mountpoint, args.config)
    if not os.path.exists(mountpoint):
        os.makedirs(mountpoint)
    if profiling_enabled:
        import inspect
        from profilehooks import profile
        import types
        for name, fn in inspect.getmembers(TransparentConfigurablePyFuseBox):
            if isinstance(fn, types.UnboundMethodType):
                if not name.startswith('_'):
                    setattr(TransparentConfigurablePyFuseBox, name,
                            profile(fn, filename='/tmp/cloudfusion_profile'))
    fuse_operations = TransparentConfigurablePyFuseBox(mountpoint)
    try:
        #first try to mount file system with big_writes option (more performant)
        FUSE(fuse_operations,
             mountpoint,
             foreground=foreground,
             nothreads=True,
             big_writes=True,
             max_read=131072,
             max_write=131072)
    except RuntimeError, e:
        FUSE(fuse_operations,
             mountpoint,
             foreground=foreground,
             nothreads=True)
Beispiel #2
0
def main():
    signal.signal(signal.SIGUSR1, handle_ipdb)
    set_umask()
    check_arguments(sys.argv)
    if sys.argv[1] == 'uuid':
        print "You can use the following unique name as your bucket name for amazon S3 or google storage:"
        print "cloudfusion_"+get_uuid()
        sys.exit()
    parser = MyParser()
    parser.add_argument('mountpoint')
    parser.add_argument('--config', help='Configuration file.')
    parser.add_argument('args', nargs=argparse.REMAINDER) #collect all arguments positioned after positional and optional parameters 
    args = parser.parse_args()
    foreground  = 'foreground' in args.args 
    profiling_enabled = 'profile' in args.args
    mountpoint = args.mountpoint
    if "stop" in args.args:
        start_stopping_thread(mountpoint)
        exit(0)
    if not "log" in args.args:
        logging.getLogger().addHandler(NullHandler())
    else:
        if not os.path.exists(".cloudfusion/logs"):
            os.makedirs(".cloudfusion/logs")
        logging.config.fileConfig(os.path.dirname(cloudfusion.__file__)+'/config/logging.conf')
        db_logging_thread.start()    
    if args.config: #evaluates to false
        if not os.path.exists(args.config):
            exit(1)
        start_configuration_thread(mountpoint, args.config)
    if not os.path.exists(mountpoint):
        os.makedirs(mountpoint)
    if profiling_enabled:
        import inspect
        from profilehooks import profile
        import types
        for name, fn in inspect.getmembers(TransparentConfigurablePyFuseBox):
            if isinstance(fn, types.UnboundMethodType):
                if not name.startswith('_'):
                    setattr(TransparentConfigurablePyFuseBox, name, profile(fn, filename='/tmp/cloudfusion_profile'))
    fuse_operations = TransparentConfigurablePyFuseBox(mountpoint)
    try:
        #first try to mount file system with big_writes option (more performant)
        FUSE(fuse_operations, mountpoint, foreground=foreground, nothreads=True, big_writes=True, max_read=131072, max_write=131072) 
    except RuntimeError, e:
        FUSE(fuse_operations, mountpoint, foreground=foreground, nothreads=True)
Beispiel #3
0
 def reconnect(self):
     self.conn = boto.connect_gs(self.access_key_id,self.secret_access_key)
     buckets = map( lambda x: x.name, self.conn.get_all_buckets())
     if not self.bucket_name in buckets:
         try:
             self.conn.create_bucket(self.bucket_name)
             self.logger.info('Successfully created bucket "%s"' % self.bucket_name)
         except boto.exception.S3CreateError, e:
             uuid = "cloudfusion_"+get_uuid()
             msg = "Failed to create bucket %s; You can try another bucket name, for instance %s" % (self.bucket_name, uuid)
             if len(buckets) > 0:
                 msg += "\nor an already existing bucket: %s" % buckets
             self.logger.error('Failed to create bucket:'+ repr(e))
             self.logger.debug(msg)
             print msg
             sys.exit()
         except boto.exception.StorageCreateError, e:
             self.logger.error('Failed to create bucket:'+ repr(e))
             sys.exit()