-
Notifications
You must be signed in to change notification settings - Fork 40
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for unit file enable/disable and daemon-reload
Add Reload, EnableUnitFiles and DisableUnitFiles in Node and internal Agent Implement and use passthough methods in manager node and agent Implement hirtectl enable/disable/daemon-reload hirtectl - call daemon-reload after unit enable/disable Update the man page Add doc and example Signed-off-by: Ygal Blum <[email protected]>
- Loading branch information
Showing
9 changed files
with
434 additions
and
2 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
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
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,33 @@ | ||
#!/usr/bin/python3 | ||
|
||
import sys | ||
from collections import namedtuple | ||
import dasbus.connection | ||
bus = dasbus.connection.SystemMessageBus() | ||
|
||
EnabledServiceInfo = namedtuple("EnabledServicesInfo", ["op_type", "symlink_file", "symlink_dest"]) | ||
EnableResponse = namedtuple("EnableResponse", ["carries_install_info", "enabled_services_info"]) | ||
|
||
if len(sys.argv) < 2: | ||
print(f"Usage: {sys.argv[0]} node_name unit_name...") | ||
sys.exit(1) | ||
|
||
node_name = sys.argv[1] | ||
|
||
manager = bus.get_proxy("org.containers.hirte", "/org/containers/hirte") | ||
node_path = manager.GetNode(node_name) | ||
node = bus.get_proxy("org.containers.hirte", node_path) | ||
|
||
response = node.EnableUnitFiles(sys.argv[2:], False, False) | ||
enable_response = EnableResponse(*response) | ||
if enable_response.carries_install_info: | ||
print("The unit files included enablement information") | ||
else: | ||
print("The unit files did not include any enablement information") | ||
|
||
for e in enable_response.enabled_services_info: | ||
enabled_service_info = EnabledServiceInfo(*e) | ||
if enabled_service_info.op_type == "symlink": | ||
print(f"Created symlink {enabled_service_info.symlink_file} -> {enabled_service_info.symlink_dest}") | ||
elif enabled_service_info.op_type == "unlink": | ||
print(f"Removed \"{enabled_service_info.symlink_file}\".") |
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
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 |
---|---|---|
|
@@ -66,3 +66,11 @@ pip3 install dasbus | |
``` | ||
|
||
--- | ||
|
||
### Enable unit files | ||
|
||
```python | ||
--8<-- "api-examples/enable-unit.py" | ||
``` | ||
|
||
--- |
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
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
Oops, something went wrong.