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

Update ip_addresses to match new format in sync #264

Merged
merged 2 commits into from
Oct 5, 2023
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
1 change: 1 addition & 0 deletions unix/.envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake . --impure
27 changes: 27 additions & 0 deletions unix/flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

46 changes: 46 additions & 0 deletions unix/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

outputs = { self, nixpkgs }:
let
supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ];
forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
pkgs = forAllSystems (system: nixpkgs.legacyPackages.${system});
in
{
devShells = forAllSystems (system: {
default = pkgs.${system}.mkShellNoCC {
venvDir = "./.venv";
buildInputs = with pkgs.${system}; [
# A Python interpreter including the 'venv' module is required to bootstrap
# the environment.
python3Packages.python

# This execute some shell code to initialize a venv in $venvDir before
# dropping into the shell
python3Packages.venvShellHook
python3Packages.python-lsp-server
# In this particular example, in order to compile any binary extensions they may
# require, the Python modules listed in the hypothetical requirements.txt need
# the following packages to be installed locally:
python3Packages.wheel
python3Packages.setuptools
libvirt
];

# Run this command, only after creating the virtual environment
postVenvCreation = ''
unset SOURCE_DATE_EPOCH
pip install -r ./requirements.txt
'';

# Now we can execute any commands within the virtual environment.
# This is optional and can be left out to run pip manually.
postShellHook = ''
# allow pip to install wheels
unset SOURCE_DATE_EPOCH
'';
};
});
};
}
4 changes: 4 additions & 0 deletions unix/src/machine_stats/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,10 @@ def cpu_name(proc):
return proc[2]
return "Unknown"

def ip_addresses(facts):
"""Return IP addresses formatted for the tidal API"""
return list(map(lambda ip: {"address": ip},
facts["ansible_all_ipv4_addresses"] + facts["ansible_all_ipv6_addresses"]))

class ResultCallback(CallbackBase):
"""A sample callback plugin used for performing an action as results come in
Expand Down