forked from INTO-CPS-Association/DTaaS
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Astitva
committed
Mar 23, 2024
1 parent
363dfd8
commit 6739fbc
Showing
13 changed files
with
345 additions
and
199 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# This is the config for DTaaS CLI | ||
|
||
name = "Digital Twin as a Service (DTaaS)" | ||
version = "0.1" | ||
owner = "The INTO-CPS-Association" | ||
git-repo = "https://github.com/into-cps-association/DTaaS.git" | ||
|
||
[common] | ||
# absolute path to the DTaaS application directory | ||
server-dns = "domain.com" | ||
path = "/home/astitva/Desktop/yamlstuff" | ||
|
||
[users] | ||
# matching user info must present in this config file | ||
add = ["astitvasehgal05","astitvasehgal19", "prasad"] | ||
delete = ["astitvasehgal19", "prasad"] | ||
|
||
[users.astitvasehgal05] | ||
email = "[email protected]" | ||
|
||
[users.astitvasehgal19] | ||
email = "[email protected]" | ||
|
||
[users.prasad] | ||
email = "[email protected]" | ||
|
||
[client.web] | ||
config = "/home/astitva/Desktop/yamlstuff/env.local.js" |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import click | ||
#from . import service | ||
from .pkg import dtaas as dtaasPkg | ||
from .pkg import users as userPkg | ||
from .pkg import utils | ||
|
||
|
||
|
||
### Groups | ||
@click.group() | ||
def dtaas(): | ||
"""all commands to help with Digital Twins as a Service""" | ||
pass | ||
|
||
@dtaas.group() | ||
def admin(): | ||
"administrative commands for DTaaS" | ||
pass | ||
|
||
@admin.group() | ||
def user(): | ||
"""user management commands""" | ||
pass | ||
|
||
#### user group commands | ||
@user.command() | ||
def add(): | ||
""" | ||
add a list of users to DTaaS at once\n | ||
Specify the list in dtaas.toml [users].add\n | ||
""" | ||
|
||
configObj = dtaasPkg.Config() | ||
|
||
err = userPkg.addUsers(configObj) | ||
if err!=None: | ||
raise click.ClickException("Error while adding users: " + str(err)) | ||
click.echo("Users added successfully") | ||
|
||
@user.command() | ||
def delete(): | ||
""" | ||
removes the USERNAME user from DTaaS\n | ||
Specify the users in dtaas.toml [users].delete\n | ||
""" | ||
|
||
configObj = dtaasPkg.Config() | ||
|
||
err = userPkg.deleteUser(configObj) | ||
if err!=None: | ||
raise click.ClickException("Error while deleting users: " + str(err)) | ||
click.echo("User deleted successfully") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import click | ||
from . import utils | ||
|
||
class Config: | ||
def __init__(self): | ||
config, err = utils.importToml('dtaas.toml') | ||
if err!=None: | ||
raise click.ClickException("config initialisation failed: "+str(err)) | ||
self.data = config | ||
|
||
def getConfig(self): | ||
if self.data!=None: | ||
return self.data,None | ||
return None, Exception("Config not initialised") | ||
|
||
def getCommon(self): | ||
conf, err = self.getConfig() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'common' not in conf: | ||
return None, Exception("Config file error: Missing 'common' tag") | ||
return conf['common'], None | ||
|
||
def getUsers(self): | ||
conf, err = self.getConfig() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'users' not in conf: | ||
return None, Exception("Config file error: Missing 'users' tag") | ||
return conf['users'], None | ||
|
||
|
||
def getPath(self): | ||
confCommon, err = self.getCommon() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'path' not in confCommon or confCommon['path']=="": | ||
return None, Exception("Config file error: The path for DTaaS directory isn't set in TOML") | ||
return str(confCommon['path']), None | ||
|
||
def getServerDNS(self): | ||
confCommon, err = self.getCommon() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'server-dns' not in confCommon and confCommon['server-dns']=="": | ||
return None, Exception("Config file error: The server dns isn't set in TOML") | ||
return str(confCommon['server-dns']), None | ||
|
||
def getAddUsersList(self): | ||
confUsers, err = self.getUsers() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'add' not in confUsers: | ||
return None, Exception("Config file error: No 'add' list in 'users' tag") | ||
addUsersList = [ str(username) for username in confUsers['add']] | ||
return addUsersList, None | ||
|
||
def getDeleteUsersList(self): | ||
confUsers, err = self.getUsers() | ||
if err!=None: | ||
return None, err | ||
|
||
if 'delete' not in confUsers: | ||
return None, Exception("Config file error: No 'delete' list in 'users' tag") | ||
deleteUsersList = [str(username) for username in confUsers['delete']] | ||
return deleteUsersList, None | ||
|
Oops, something went wrong.