threefoldtecharchive / jumpscaleX_archived

Apache License 2.0
1 stars 6 forks source link

flist manipulation SAL in JSX #777

Open despiegk opened 4 years ago

despiegk commented 4 years ago

a sal in JSX 10 to manipulate flists

...

need to do live cycle management of apps in flist

maxim has the code done, we need to bind his C code to python to JSX

muhamadazmy commented 4 years ago

@maxux What is the status of this https://github.com/threefoldtech/0-flist#pyflist ? the python binding for the flister and if we can start using it in jsx already.

zaibon commented 4 years ago

Progress about flist tooling can be followed at: https://github.com/threefoldtech/0-flist/issues/13

maxux commented 4 years ago

Progression about python binding: https://github.com/threefoldtech/0-flist/issues/15

maxux commented 4 years ago

@BolaNasr found some non-working feature on zflist, I'm fixing that first

BolaNasr commented 4 years ago

now we have flist manipulation

j.sal.flist.new_flist()
j.sal.flist.file_copy_from_local("/sandbox/test.py","/") 
j.sal.flist.commit("/sandbox/code/flist_sal.flist") 

and we have builder of zflist to install zflist bin

j.builders.storage.zflist.install(reset=True)
muhamadazmy commented 4 years ago

@BolaNasr do u have a PR open, i need to take a look at the code

BolaNasr commented 4 years ago

@muhamadazmy

Flist Manipulation

we using zflist binary in 0-flist repo

to install it using kosmos

 j.builders.storage.zflist.install(reset=True)

Usage:

 ./zflist [temporary-point] open <filename>
       ./zflist [temporary-point] <action> <arguments>
       ./zflist [temporary-point] commit [optional-new-flist]

  The temporary-point should be a directory where temporary files
  will be used for keeping tracks of your changes.
  You can also use ZFLIST_MNT environment variable to set your
  temporary-point directory and not specify it on the command line.

  By default, this tool will print error and information in text format,
  you can get a json output by setting ZFLIST_JSON=1 environment variable.

  First, you need to -open- an flist, then you can do some -edit-
  and finally you can -commit- (close) your changes to a new flist.

Available actions:
  open            open an flist to enable editing
  init            initialize an empty flist to enable editing
  ls              list the content of a directory
  find            list full contents of files and directories
  stat            dump inode full metadata
  cat             print file contents (backend metadata required)
  put             insert local file into the flist
  putdir          insert local directory into the flist (recursively)
  chmod           change mode of a file (like chmod command)
  rm              remove a file (not a directory)
  rmdir           remove a directory (recursively)
  mkdir           create an empty directory (non-recursive)
  metadata        get or set metadata
  merge           merge another flist into the current one
  commit          commit changes to a new flist
  close           close mountpoint and discard files

create new flist:

create new flist then put file from local then commit it

new_flist = j.sal.flist.new() 
new_flist.put("/sandbox/code/github/test.py","/") 
new_flist.commit("/sandbox/code/test.flist") 
#delete everything in temporary-point
new_flist.close()

open flist and edit on it:

open flist , put dir from local , commit it

new_flist = j.sal.flist.open("/tmp/test.flist") 
new_flist.put_dir ("/tmp/test","/") 
# list all things in flist
new_flist.list_all()
new_flist.commit("/sandbox/code/test2.flist") 
#delete everything in temporary-point
new_flist.close()
maxux commented 4 years ago

Do you use the json output and the release version of zflist ?

BolaNasr commented 4 years ago

@maxux yes i fixed in builder and now use it to return json