Skip to content

Commit

Permalink
fix slug
Browse files Browse the repository at this point in the history
  • Loading branch information
copdips committed Jan 21, 2024
1 parent 0362f31 commit 5a5a4da
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ From the [EventHistoryCollector doc](https://pubs.vmware.com/vsphere-6-5/topic/c
>
> HistoryCollector

A quick search on [HistoryCollector](https://pubs.vmware.com/vsphere-6-5/topic/com.vmware.wssdk.smssdk.doc/vim.HistoryCollector.html), we find it has a method `RewindCollector()`:

>RewindCollector(rewind)
Expand All @@ -101,16 +100,20 @@ from datetime import datetime, timedelta
from pyVim.connect import SmartConnectNoSSL
from pyVmomi import vim


time_filter = vim.event.EventFilterSpec.ByTime()
now = datetime.now()
time_filter.beginTime = now - timedelta(hours=1)
time_filter.endTime = now
event_type_list = []
# If you want to also filter on certain events, uncomment the below event_type_list.
# The EventFilterSpec full params details:

# If you want to also filter on certain events, uncomment the below event_type_list

# The EventFilterSpec full params details

# https://pubs.vmware.com/vsphere-6-5/topic/com.vmware.wssdk.smssdk.doc/vim.event.EventFilterSpec.html

# event_type_list = ['VmRelocatedEvent', 'DrsVmMigratedEvent', 'VmMigratedEvent']

filter_spec = vim.event.EventFilterSpec(eventTypeId=event_type_list, time=time_filter)

si = SmartConnectNoSSL(host=host, user=user, pwd=password, port=port)
Expand All @@ -120,13 +123,16 @@ page_size = 1000 # The default and also the max event number per page till vSphe
events = []

while True:
# If there's a huge number of events in the expected time range, this while loop will take a while.

# If there's a huge number of events in the expected time range, this while loop will take a while

events_in_page = event_collector.ReadNextEvents(page_size)
num_event_in_page = len(events_in_page)
if num_event_in_page == 0:
break
events.extend(events_in_page) # or do other things on the collected events
# Please note that the events collected are not ordered by the event creation time, you might find the first event in the third page for example.

# Please note that the events collected are not ordered by the event creation time, you might find the first event in the third page for example

print(
"Got totally {} events in the given time range from {} to {}.".format(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ date:
description: As like [pypi](https://pypi.org/) for Python, [npm](https://www.npmjs.com/)
for Node.js, we also have [Powershell Gallery](https://www.powershellgallery.com/)
and Nuget Gallery for Powershell.
slug: setting-up-powershell-gallery-and-nuget-gallery-for-powershell
---

# Setting Up Powershell gallery And Nuget gallery
Expand Down
2 changes: 2 additions & 0 deletions docs/posts/2018/2018-05-16-powershell-stop-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ date:
created: 2018-05-16
description: Use Powershell stop-parsing (`--%`) to treat the remaining characters
in the line as a literal.
slug: powershell-stop-parsing
---

# Powershell stop-parsing (`--%`)
Expand Down Expand Up @@ -98,6 +99,7 @@ For example, to parse a DateTime to a sortable string :
```

So I added the stop-parsing symbol `--%` just after ssh-keygen.exe, and my ssh keys are managed to be created :

```powershell
[RemoteServer]: PS> ssh-keygen.exe --% -q -t rsa -b 4096 -N '' -C '[email protected]' -f C:\Users\administrator\.ssh\id_rsa
ssh-keygen.exe : Saving key "C:\\Users\\administrator\\.ssh\\id_rsa" failed: No such file or directory
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ comments: true
date:
created: 2018-07-25
description: pyVmomi event manager returns only the last 1000 events. But EventHistoryCollector
object's ReadNextEvents()method can collect all the events.
object's ReadNextEvents()method can collect all the events.q
slug: use-pyvmomi-EventHistoryCollector-to-get-all-the-vcenter-events
---

# Use pyVmomi EventHistoryCollector to get all the vCenter events
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ description: Test-NetConnection is too slow if the remote port is not opened due
its timeout setting. Use System.Net.Sockets.TcpClient instead.
---

# A fast way to check TCP port in Powershell
# Fast TCP port check in Powershell

The [Test-NetConnection](https://docs.microsoft.com/en-us/powershell/module/nettcpip/test-netconnection) cmdlet is great and verbose but too slow if the remote port to check is not opened. This is due to its timeout setting and cannot be modified. In this port, I will show you a custom function that leverages the power of [System.Net.Sockets.TcpClient](https://docs.microsoft.com/dotnet/api/system.net.sockets.tcpclient) to accelerate the port test.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ date:
created: 2019-12-29
description: Github can host package releases, I will show you how to use Powershell
to retrieve the latest release download url.
slug: Using-Powershell-to-retrieve-latest-package-url-from-github-releases
---

# Using Powershell To Retrieve Latest Package Url From Github Releases
Expand Down Expand Up @@ -48,4 +49,3 @@ https://github.com/PowerShell/PowerShell/releases/download/v6.2.3/PowerShell-6.2
!!! note

The powershell pre-release doesn't have a static url, so I cannot retrieve the latest [v7.0.0-rc.1](https://github.com/PowerShell/PowerShell/releases/tag/v7.0.0-rc.1) download url.

0 comments on commit 5a5a4da

Please sign in to comment.