tgt interface — VMware Salt API
tgt interface
The LoadedMod class allows for the module loaded onto the sub to return custom sequencing, for instance it can be iterated over to return all functions
Delete one or more target groups.
Parameters
| tgt_uuid: | UUID or list of UUIDs referring to the target groups to delete. |
|---|---|
| force: | Force deletion of target group and scheduled jobs depending on it. |
| raises FailedResourceDependency: | The target group has one or more resources that depend on it and force is false. The message in the exception identifies the dependent resources. |
Get the access metadata for a target group.
Parameters
| tgt_uuid: | Retrieve metadata for target group matching this UUID. |
|---|
Get the set of minions that match a target group according to the currently cached minion data. Minions are keyed by master:
For more information on target groups, see the VMware Salt documentation on Broadcom's TechDocs.
Parameters
| tgt_uuid: | The UUID of the target group for which to resolve minions. |
|---|
Retrieve details for a target group. For more information on target groups, see the VMware Salt documentation on Broadcom's TechDocs.
Parameters
| tgt_uuid: | Retrieve details for this target group. |
|---|---|
| master_id: | Retrieve details for master with this ID (not UUID). |
| pillar_uuid: | Retrieve target details associated with this pillar (UUID). |
| role_uuid: | Retrieve targets assigned to role (UUID) |
| name: | Search the target group name for this text. |
| desc: | Search the target group description for this text. |
| include_pillar_data: | Include attached pillar data in the return payload (default False). |
| sort_by: | Sort by this field, either 'name' or 'desc'. |
| reverse: | Return results in the reverse order. |
| limit: | Limit maximum target groups to this number (default 50). |
| page: | Return target groups from this page (offset = page * limit). |
Use either tgt_uuid or master_id, but not both. If tgt_uuid is used, other filters are not applied.
get_target_group() example:
client.api.tgt.get_target_group()
The return payload is a dictionary with the following elements:
{ 'count': 100, # total target group count 'limit': 50, # results count 'results': [...] # target groups }
Example:
client.api.tgt.get_target_group(tgt_uuid='7f93b928-388b-11e6-b133-346895ecb8f3') RPCResponse( riq=5, ret= { u'results': [ {u'name': u'All Minions', u'tgt': {u'*': {u'tgt_type': u'compound', u'tgt': u'*'}}, u'uuid': u'7f93b928-388b-11e6-b133-346895ecb8f3', u'pillars': [], u'metadata': {u'auth': {u'access': {u'Superuser': {u'write': False, u'read': True, u'discover': True, u'delete': False}, u'Administrator': {u'write': False, u'read': True, u'discover': True, u'delete': False}, u'User': {u'write': False, u'read': True, u'discover': True, u'delete': False}}, u'owner': {u'username': u'--<{internal-access}>--', u'config_name': u'internal', u'uuid': u'c74f8bee-5ead-453e-8c86-344a4780c053'}}}, u'desc': u''}], u'count': 1, u'limit': 1 }, u'error'= None, u'warnings'= [])
Create a new or update an existing target group.
For more information on target groups, see the VMware Salt documentation on Broadcom's TechDocs.
Parameters
| tgt: | Target dictionary. See below for example. |
|---|---|
| name: | Name of the target group |
| tgt_uuid: | UUID for the target group. If empty, generate a new UUID. Otherwise tgt_uuid must point to an existing target group. |
| desc: | Text description of this target group. |
| pillar_uuids: | List of UUIDs referring to related pillar structures. |
| wait_for_match: | If True, block this call until the target group is successfully constructed. This can take some time on large RaaS installations. If False then return immediately. |
The tgt argument takes a dictionary that looks like
{<master_id or '*'>: {u'tgt_type': <target type>, u'tgt': <target string>}}
tgt_type is the type of target: glob, grain, grain_pcre, pillar, pillar_pcre, list, ipcidr, pcre, or node.
tgt is the actual target. For glob this would be any string matching minion IDs and utilizing shell-globbing characters (*, ?, [], etc).
For compound see Salt's description of compound target indicators for a full explanation, but an overview is below:
Compound matchers allow very granular minion targeting using any of Salt's matchers. The default matcher is a glob match, just as with CLI and top file matching. To match using anything other than a glob, prefix the match string with the appropriate letter from the table below, followed by an @ sign.
| Letter | Match Type | Example | Alt Delimiter? |
|---|---|---|---|
| G | Grains glob | G@os:Ubuntu | Yes |
| E | PCRE Minion ID | E@web\d|\.(dev|qa|prod)\.loc | No |
| P | Grains PCRE | P@os:(RedHat|Fedora|CentOS) | Yes |
| L | List of minions | [email protected], minion3.domain.com or bl*.domain.com | No |
| I | Pillar glob | I@pdata:foobar | Yes |
| J | Pillar PCRE | J@pdata:^(foo|bar)$ | Yes |
| S | Subnet/IP address | [email protected]/24 or [email protected] | No |
| R | Range cluster | R@%foo.bar | No |
Matchers can be joined using boolean and, or, and not operators.
Here is an example for creating a target group with a compound target:
wintgtresult = c.api.tgt.save_target_group( name='Windows', desc='Windows', tgt={'*':{'tgt_type':'compound', 'tgt':'G@os_family:Windows'}})
save_target_group() example:
client.api.tgt.save_target_group(tgt={'SSE_master': {'tgt_type': 'grain', 'tgt': 'G@kernel:Linux'}}, name='NewTestLinux')
Update existing target example:
client.api.tgt.save_target_group(tgt={'SSE_master': {'tgt_type': 'grain', 'tgt': 'G@kernel:Linux'}}, name='Linux', tgt_uuid='f2ace00c-4fa0-11e6-88bc-080027a7289c', desc='newdescription')
Save the access metadata for a target group.
Parameters
| tgt_uuid: | Save metadata for target group matching this UUID. |
|---|---|
| access_payload: | Dictionary containing role names as keys and a list of allowed access types as values |