Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Runt pivotout support and docstrings #1851

Merged
merged 3 commits into from
Aug 19, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions synapse/lib/ast.py
Original file line number Diff line number Diff line change
Expand Up @@ -1283,6 +1283,11 @@ async def getPivsOut(self, runt, node, path):
if form is None:
continue

if prop.isrunt:
async for pivo in runt.snap.nodesByPropValu(form.name, '=', valu):
yield pivo, path.fork(pivo)
continue

pivo = await runt.snap.getNodeByNdef((form.name, valu))
if pivo is None: # pragma: no cover
continue
Expand Down
11 changes: 11 additions & 0 deletions synapse/lib/hiveauth.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,17 @@ def reqAuthGate(self, iden):
return gate

async def addUser(self, name, passwd=None, email=None):
'''
Add a User to the Hive.

Args:
name (str): The name of the User.
passwd (str): A optional password for the user.
email (str): A optional emall for the user.

Returns:
HiveUser: A Hive User.
'''

if self.usersbyname.get(name) is not None:
raise s_exc.DupUserName(name=name)
Expand Down
5 changes: 4 additions & 1 deletion synapse/lib/stormlib/backup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

@s_stormtypes.registry.registerLib
class BackupLib(s_stormtypes.Lib):

'''
A Storm Library for interacting with the backup APIs in the Cortex.
'''
_storm_lib_path = ('backup',)

def getObjLocals(self):
Expand All @@ -19,6 +21,7 @@ async def _runBackup(self, name=None, wait=True):

Args:
name (str): The name of the backup to generate.

wait (bool): If true, wait for the backup to complete before returning.

Returns:
Expand Down
7 changes: 7 additions & 0 deletions synapse/tests/test_model_syn.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ async def delExtModelConfigs(cortex):
nodes = await core.nodes(q)
self.ge(len(nodes), 7)

# Wildcard pivot out from a prop and ensure we got the form
q = 'syn:prop=test:comp -> * '
nodes = await core.nodes(q)
self.len(2, nodes)
self.eq({('syn:form', 'test:comp'), ('syn:type', 'test:comp')},
{n.ndef for n in nodes})

# Some forms inherit from a single type
nodes = await core.nodes('syn:type="inet:addr" -> syn:type:subof')
self.ge(len(nodes), 2)
Expand Down