Added proxmox lxc mapping python script
This commit is contained in:
parent
0c25e2d3c5
commit
4016ecfb3b
|
@ -0,0 +1,36 @@
|
|||
import numpy as np
|
||||
|
||||
uid_map = np.array([[1000, 33]])
|
||||
gid_map = np.array([[1000, 33]])
|
||||
|
||||
uid_cont = np.vstack(([0, 100000], uid_map, np.column_stack((uid_map[:, 0] + 1, uid_map[:, 0] + 1 + 100000))))
|
||||
uid_cont = uid_cont[uid_cont[:, 0].argsort()]
|
||||
|
||||
uid_delta = np.diff(uid_cont[:, 0])
|
||||
uid_delta = np.concatenate((uid_delta, np.array([65536 - uid_cont[-1, 0]])))
|
||||
uid_cont = np.column_stack((uid_cont, uid_delta))
|
||||
|
||||
gid_cont = np.vstack(([0, 100000], gid_map, np.column_stack((gid_map[:, 0] + 1, gid_map[:, 0] + 1 + 100000))))
|
||||
gid_cont = gid_cont[gid_cont[:, 0].argsort()]
|
||||
|
||||
gid_delta = np.diff(gid_cont[:, 0])
|
||||
gid_delta = np.concatenate((gid_delta, np.array([65536 - gid_cont[-1, 0]])))
|
||||
gid_cont = np.column_stack((gid_cont, gid_delta))
|
||||
|
||||
print("\n---- CONTAINER CONFIGURATION FILE ----")
|
||||
|
||||
for i in range(len(uid_cont)):
|
||||
print("lxc.idmap = u {} {} {}".format(int(uid_cont[i, 0]), int(uid_cont[i, 1]), int(uid_cont[i, 2])))
|
||||
|
||||
for i in range(len(gid_cont)):
|
||||
print("lxc.idmap = g {} {} {}".format(int(gid_cont[i, 0]), int(gid_cont[i, 1]), int(gid_cont[i, 2])))
|
||||
|
||||
print("\n---- /etc/subuid FILE ----")
|
||||
|
||||
for i in range(len(uid_map[:,1])):
|
||||
print("root:{}:1".format(int(uid_map[i,1])))
|
||||
|
||||
print("\n---- /etc/subgid FILE ----")
|
||||
|
||||
for i in range(len(gid_map[:,1])):
|
||||
print("root:{}:1".format(int(gid_map[i,1])))
|
Loading…
Reference in New Issue