Skip to content

Commit c6e59a9

Browse files
committed
Merge branch 'main' into content-library-only
2 parents df91617 + 3824e7a commit c6e59a9

18 files changed

Lines changed: 1844 additions & 30 deletions

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ repos:
1010
- id: mixed-line-ending # Replaces or checks mixed line ending.
1111
args: [--fix=lf]
1212
- id: end-of-file-fixer # Makes sure files end in a newline and only a newline.
13+
exclude: changelog/*
1314
- id: check-merge-conflict # Check for files that contain merge conflict strings.
1415
- id: check-ast # Simply check whether files parse as valid python.
1516

README.md

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ The [Salt Contributing guide][salt-contributing] has a lot of relevant informati
2626
# Change to the repo dir
2727
cd salt-ext-modules-vmware
2828

29-
# Create a new venv
29+
# Create a new venv, after sourcing activate `python` will refer to python3.
3030
python3 -m venv env --prompt vmw-ext
3131
source env/bin/activate
3232

@@ -54,20 +54,53 @@ The [Salt Contributing guide][salt-contributing] has a lot of relevant informati
5454
# 1. Make a local salt dir
5555
mkdir -p local/etc/salt
5656

57-
# 2. Create a minion config
57+
# 2. Make a local dir for salt state files
58+
mkdir -p local/srv/salt
59+
60+
# 3. Make a local dir for salt pillar files
61+
mkdir -p local/srv/pillar
62+
63+
# 4. Create a minion config
5864
cat << EOF> local/etc/salt/minion
5965
user: $(whoami)
6066
root_dir: $PWD/local/
6167
file_root: $PWD/local
6268
master: localhost
6369
id: saltdev
6470
master_port: 55506
71+
pillar_roots:
72+
base:
73+
- $PWD/local/srv/pillar
74+
EOF
75+
76+
# 5. Make a Saltfile
77+
cat << EOF> Saltfile
78+
salt-call:
79+
local: true
80+
config_dir: local/etc/salt
81+
EOF
82+
83+
# 6. Create a pillar file for you configuration
84+
cat << EOF> local/srv/my_vsphere_conf.sls
85+
# vCenter
86+
saltext.vmware:
87+
# Or use IP address, e.g. 203.0.113.42
88+
host: vsphere.example.com
89+
password: CorrectHorseBatteryStaple
90+
user: BobbyTables
91+
EOF
92+
93+
# 7. Create a pillar top file
94+
cat << EOF> local/srv/pillar.sls
95+
base:
96+
saltdev:
97+
- my_vsphere_conf
6598
EOF
6699

67-
# 3. Create a test config file:
100+
# 8. (deprecated but not removed yet) If you're contributing to the project and need to run the tests, create a test config file:
68101
python tools/test_value_scraper.py -c local/vcenter.conf
69102

70-
# 4. Create a test config file for VMC:
103+
# 9. (deprecated but not removed yet) Create a test config file for VMC:
71104
python tools/test_value_scraper_vmc.py --help
72105
This command will return the required information.
73106

changelog/333.added

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Added modules storage_policy.find and storage_policy.save.
2+
Added state storage_policy.config.

docs/ref/modules/all.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ Execution Modules
3232
saltext.vmware.modules.nsxt_transport_zone
3333
saltext.vmware.modules.nsxt_uplink_profiles
3434
saltext.vmware.modules.ssl_adapter
35+
saltext.vmware.modules.storage_policies
3536
saltext.vmware.modules.subscribed_library
3637
saltext.vmware.modules.tag
3738
saltext.vmware.modules.vm
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
saltext.vmware.modules.storage_policies
3+
=======================================
4+
5+
.. automodule:: saltext.vmware.modules.storage_policies
6+
:members:

docs/ref/states/all.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ State Modules
2626
saltext.vmware.states.nsxt_transport_node_profiles
2727
saltext.vmware.states.nsxt_transport_zone
2828
saltext.vmware.states.nsxt_uplink_profiles
29+
saltext.vmware.states.storage_policies
2930
saltext.vmware.states.tag
3031
saltext.vmware.states.vm
3132
saltext.vmware.states.vmc_dhcp_profiles
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
saltext.vmware.states.storage_policies
3+
======================================
4+
5+
.. automodule:: saltext.vmware.states.storage_policies
6+
:members:

src/saltext/vmware/modules/esxi.py

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1775,6 +1775,63 @@ def remove_user(
17751775
raise salt.exceptions.SaltException(str(exc))
17761776

17771777

1778+
def get_user(
1779+
user_name,
1780+
datacenter_name=None,
1781+
cluster_name=None,
1782+
host_name=None,
1783+
service_instance=None,
1784+
profile=None,
1785+
):
1786+
"""
1787+
Get local user on matching ESXi hosts.
1788+
1789+
user_name
1790+
User to delete on matching ESXi hosts. (required).
1791+
1792+
datacenter_name
1793+
Filter by this datacenter name (required when cluster is specified)
1794+
1795+
cluster_name
1796+
Filter by this cluster name (optional)
1797+
1798+
host_name
1799+
Filter by this ESXi hostname (optional)
1800+
1801+
service_instance
1802+
Use this vCenter service connection instance instead of creating a new one. (optional).
1803+
1804+
profile
1805+
Profile to use (optional)
1806+
1807+
.. code-block:: bash
1808+
1809+
salt '*' vmware_esxi.get_user user_name=foo
1810+
"""
1811+
log.debug("Running vmware_esxi.get_user")
1812+
ret = {}
1813+
service_instance = service_instance or utils_connect.get_service_instance(
1814+
config=__opts__, profile=profile
1815+
)
1816+
hosts = utils_esxi.get_hosts(
1817+
service_instance=service_instance,
1818+
host_names=[host_name] if host_name else None,
1819+
cluster_name=cluster_name,
1820+
datacenter_name=datacenter_name,
1821+
get_all_hosts=host_name is None,
1822+
)
1823+
1824+
try:
1825+
for host in hosts:
1826+
user_account = host.configManager.userDirectory.RetrieveUserGroups(
1827+
None, user_name, None, None, True, True, False
1828+
)
1829+
ret[host.name] = user_account
1830+
return ret
1831+
except DEFAULT_EXCEPTIONS as exc:
1832+
raise salt.exceptions.SaltException(str(exc))
1833+
1834+
17781835
def _get_net_stack(network_tcpip_stack):
17791836
return {
17801837
"default": "defaultTcpipStack",

0 commit comments

Comments
 (0)