Skip to content

Commit

Permalink
add initial values
Browse files Browse the repository at this point in the history
add simple fs
authorize azure cli with service-principal
  • Loading branch information
dievri committed Jan 26, 2021
1 parent f86cf0f commit b2bbf05
Show file tree
Hide file tree
Showing 3 changed files with 233 additions and 0 deletions.
56 changes: 56 additions & 0 deletions src/fs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{% raw %}{% include './common.j2' %}{% endraw %}
fs:
# root
"/":
readdir:
sh: ls /accounts
getattr:
sh: *dir
# /<id>
"/[0-9]+":
name: id
readdir:
list:
- vm
getattr:
sh: *dir
# /<id>/.init.lua
"/.init.lua":
getattr:
sh: *file
read_file:
sh: |
cat <<EOF
{% filter indent(15, first=True) -%}
{% include '.init.lua'%}
{%- endfilter %}
EOF

# /<id>/vm
"/vm":
readdir:
list:
- list
getattr:
sh: *dir
# /<id>/vm/list
"/list":
cache: 360
readdir:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r '.[].name'
getattr:
sh: *dir
# /<id>/vm/list/<instance>
"/[a-z0-9_-]+":
name: instancename
getattr:
sh: *dir
readdir:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\")" | jq -r "keys[]"
# /<id>/vm/list/<instance>/<parameter>
"/[a-zA-Z0-9_-]+":
name: parameter
getattr:
sh: *file
read_file:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\") .\"$parameter\""
62 changes: 62 additions & 0 deletions src/values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
image:
repository: 9mine/9mine-azure-cloud-fs
tag: "main"
pullPolicy: Always

initContainerImage:
repository: 9mine/execfuse-jinja2
tag: "master"
pullPolicy: Always

securityContext:
privileged: true
capabilities:
add:
- SYS_ADMIN

service:
type: ClusterIP
port: 3900

ClusterIPRange:
from: 3901
to: 3920

description: "azurecloudfs"

fs: |
{% filter indent() -%}{% include 'fs.yml'%}
{%- endfilter %}
profile: |
echo --- start of profile loading ---
load file2chan
load std
ndb/cs
for host_var in `{ os env } { '{'$host_var'}' }
dir = $EXPORT_PATH
port = $NINEP_PUBLIC_PORT
echo $NINEP_PUBLIC_HOST > /dev/sysname
test -d /mnt/registry || mkdir -p /mnt/registry
mount -A tcp!registry!registry /mnt/registry
AWS_DIR = /tmp/aws/cmd
test -d $AWS_DIR || mkdir -p $AWS_DIR
load mpexpr
fs_port = ${expr $NINEP_PUBLIC_PORT 1 +}
file2chan $AWS_DIR^/aws {} {
load mpexpr
var=${expr 10 rand}
echo new id is $var
echo hostname is `{os hostname}
(app_id password tenant) = `{echo ${rget data}}
`{os /bin/bash -c 'mkdir -p /accounts/'^$var}
`{os /bin/bash -c 'export AZURE_CONFIG_DIR=/accounts/'^$var^'/credentials && az login --service-principal -u '^$app_id^' -p '^$password^' --tenant '^$tenant^''}
grid/reglisten -A -r description 'user id is '^$var tcp!*!^$fs_port { export $dir^/^$var & } &
fs_port=${expr $fs_port 1 +}
}
grid/reglisten -A -r description ${quote $NINEP_DESCRIPTION} 'tcp!*!'^$port { export $AWS_DIR & }
test -n $status && os pkill -9 emu-g
echo --- end of profile loading ---
115 changes: 115 additions & 0 deletions values.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
image:
repository: 9mine/9mine-azure-cloud-fs
tag: "main"
pullPolicy: Always

initContainerImage:
repository: 9mine/execfuse-jinja2
tag: "master"
pullPolicy: Always

securityContext:
privileged: true
capabilities:
add:
- SYS_ADMIN

service:
type: ClusterIP
port: 3900

ClusterIPRange:
from: 3901
to: 3920

description: "azurecloudfs"

fs: |
{% include './common.j2' %}
fs:
# root
"/":
readdir:
sh: ls /accounts
getattr:
sh: *dir
# /<id>
"/[0-9]+":
name: id
readdir:
list:
- vm
getattr:
sh: *dir
# /<id>/.init.lua
"/.init.lua":
getattr:
sh: *file
read_file:
sh: |
cat <<EOF
print("dump")
EOF
# /<id>/vm
"/vm":
readdir:
list:
- list
getattr:
sh: *dir
# /<id>/vm/list
"/list":
cache: 360
readdir:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r '.[].name'
getattr:
sh: *dir
# /<id>/vm/list/<instance>
"/[a-z0-9_-]+":
name: instancename
getattr:
sh: *dir
readdir:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\")" | jq -r "keys[]"
# /<id>/vm/list/<instance>/<parameter>
"/[a-zA-Z0-9_-]+":
name: parameter
getattr:
sh: *file
read_file:
sh: export AZURE_CONFIG_DIR=/accounts/$id/credentials && az vm list | jq -r ".[] | select (.name==\"$instancename\") .\"$parameter\""
profile: |
echo --- start of profile loading ---
load file2chan
load std
ndb/cs
for host_var in `{ os env } { '{'$host_var'}' }
dir = $EXPORT_PATH
port = $NINEP_PUBLIC_PORT
echo $NINEP_PUBLIC_HOST > /dev/sysname
test -d /mnt/registry || mkdir -p /mnt/registry
mount -A tcp!registry!registry /mnt/registry
AWS_DIR = /tmp/aws/cmd
test -d $AWS_DIR || mkdir -p $AWS_DIR
load mpexpr
fs_port = ${expr $NINEP_PUBLIC_PORT 1 +}
file2chan $AWS_DIR^/aws {} {
load mpexpr
var=${expr 10 rand}
echo new id is $var
echo hostname is `{os hostname}
(app_id password tenant) = `{echo ${rget data}}
`{os /bin/bash -c 'mkdir -p /accounts/'^$var}
`{os /bin/bash -c 'export AZURE_CONFIG_DIR=/accounts/'^$var^'/credentials && az login --service-principal -u '^$app_id^' -p '^$password^' --tenant '^$tenant^''}
grid/reglisten -A -r description 'user id is '^$var tcp!*!^$fs_port { export $dir^/^$var & } &
fs_port=${expr $fs_port 1 +}
}
grid/reglisten -A -r description ${quote $NINEP_DESCRIPTION} 'tcp!*!'^$port { export $AWS_DIR & }
test -n $status && os pkill -9 emu-g
echo --- end of profile loading ---

0 comments on commit b2bbf05

Please sign in to comment.