Skip to content

Commit d229e23

Browse files
committed
merge conflict
2 parents 33247c1 + 64d9625 commit d229e23

20 files changed

+392
-66
lines changed

.env.example

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,35 @@
66
# Used by CLI tools and local scripts to connect to Infrahub
77
# Note: The Service Catalog container uses http://infrahub-server:8000 automatically
88
# via docker-compose.override.yml for proper Docker networking
9-
INFRAHUB_ADDRESS=http://localhost:8000
9+
export INFRAHUB_ADDRESS=http://localhost:8000
1010

1111
# Infrahub UI URL for browser links
1212
# Used by the Service Catalog to generate clickable links to Infrahub UI pages
1313
# Should be the URL accessible from your browser (typically http://localhost:8000)
14-
INFRAHUB_UI_URL=http://localhost:8000
14+
export INFRAHUB_UI_URL=http://localhost:8000
1515

1616
# Infrahub API authentication token
1717
# Generate a token in the Infrahub UI under Settings > API Tokens
18-
INFRAHUB_API_TOKEN=06438eb2-8019-4776-878c-0941b1f1d1ec
18+
export INFRAHUB_API_TOKEN=06438eb2-8019-4776-878c-0941b1f1d1ec
1919

2020
# Infrahub version to use
2121
# Specify the version of Infrahub to run (e.g., 1.5.1, stable, latest)
22-
INFRAHUB_VERSION=1.5.1
22+
export INFRAHUB_VERSION=1.5.1
2323

2424
# Enable Infrahub Enterprise features
2525
# Set to "true" to enable enterprise features, "false" for community edition
26-
INFRAHUB_ENTERPRISE=false
26+
export INFRAHUB_ENTERPRISE=false
27+
28+
# Use local git repository instead of GitHub
29+
# Set to "true" to mount the current directory as the git repository in Infrahub
30+
# This is useful for local development and testing of generator/transform changes
31+
# When enabled:
32+
# - Infrahub will use /upstream (the mounted current directory) as the repo
33+
# - Bootstrap script loads objects/git-repo/local-dev.yml
34+
# When disabled (default):
35+
# - Infrahub will clone from GitHub
36+
# - Bootstrap script loads objects/git-repo/github.yml
37+
export INFRAHUB_GIT_LOCAL=false
2738

2839
# =============================================================================
2940
# Service Catalog Configuration
@@ -33,23 +44,23 @@ INFRAHUB_ENTERPRISE=false
3344
# Set to "true" to start the service catalog container with 'uv run invoke start'
3445
# Set to "false" (default) to run only the core Infrahub services
3546
# The service catalog provides a web UI for managing data center deployments
36-
INFRAHUB_SERVICE_CATALOG=false
47+
export INFRAHUB_SERVICE_CATALOG=false
3748

3849
# Default branch to use when the service catalog application starts
3950
# This is the branch that will be selected by default in the UI
40-
DEFAULT_BRANCH=main
51+
export DEFAULT_BRANCH=main
4152

4253
# Time to wait (in seconds) for the Infrahub generator to complete after creating a DC
4354
# Increase this value if your generators take longer to complete
44-
GENERATOR_WAIT_TIME=60
55+
export GENERATOR_WAIT_TIME=60
4556

4657
# API request timeout in seconds
4758
# Maximum time to wait for API requests to complete
48-
API_TIMEOUT=30
59+
export API_TIMEOUT=30
4960

5061
# Number of retry attempts for failed API requests
5162
# The service catalog will retry failed requests this many times before giving up
52-
API_RETRY_COUNT=3
63+
export API_RETRY_COUNT=3
5364

5465
# Streamlit server port (optional)
5566
# Port on which the Streamlit application will run

CLAUDE.md

Lines changed: 25 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,10 @@ uv run infrahubctl object load objects/bootstrap --branch main
4545
# Load security data
4646
uv run infrahubctl object load objects/security/ --branch main
4747

48-
# Add demo repository
49-
uv run infrahubctl repository add DEMO https://github.com/opsmill/infrahub-bundle-dc.git --read-only --ref main
48+
# Add bundle-dc repository (loaded from objects/git-repo/*.yml based on INFRAHUB_GIT_LOCAL)
49+
# - objects/git-repo/github.yml for GitHub (default)
50+
# - objects/git-repo/local-dev.yml for local /upstream mount
51+
uv run infrahubctl object load objects/git-repo/github.yml --branch main
5052

5153
# Load event actions (optional)
5254
uv run infrahubctl object load objects/events/ --branch main
@@ -344,7 +346,22 @@ INFRAHUB_ADDRESS="http://localhost:8000"
344346
INFRAHUB_API_TOKEN="06438eb2-8019-4776-878c-0941b1f1d1ec"
345347
```
346348

347-
Note: The token above is a demo token for local development only.
349+
Optional environment variables for development:
350+
351+
```bash
352+
# Use local git repository instead of GitHub (for development/testing)
353+
INFRAHUB_GIT_LOCAL="true" # Default: false
354+
```
355+
356+
When `INFRAHUB_GIT_LOCAL=true`:
357+
358+
- Infrahub will use the current directory mounted at `/upstream` as the git repository
359+
- Useful for testing generator, transform, and check changes without pushing to GitHub
360+
- The volume mount is configured in `docker-compose.override.yml`
361+
- Bootstrap script automatically loads `objects/git-repo/local-dev.yml` (pointing to `/upstream`)
362+
- When disabled (default), bootstrap loads `objects/git-repo/github.yml` (pointing to GitHub URL)
363+
364+
Note: The API token above is a demo token for local development only.
348365

349366
## Bootstrap Process
350367

@@ -366,8 +383,8 @@ uv run infrahubctl object load objects/bootstrap
366383
# 5. Load security data (optional)
367384
uv run infrahubctl object load objects/security/
368385
369-
# 6. Add repository
370-
uv run infrahubctl repository add DEMO https://github.com/opsmill/infrahub-bundle-dc.git --read-only --ref main
386+
# 6. Add repository (loaded from objects/git-repo/*.yml based on INFRAHUB_GIT_LOCAL)
387+
uv run infrahubctl object load objects/git-repo/github.yml --branch main
371388
372389
# 7. Load event actions (optional)
373390
uv run infrahubctl object load objects/events/
@@ -446,6 +463,9 @@ The project includes a Streamlit-based service catalog application:
446463
- `18_devices.yml` - Pre-configured devices (corp-firewall, cisco-switch-01, etc.)
447464
- `19_docs.yml` - Documentation links
448465
- `objects/dc/` - Data center demo scenario files (Arista, Cisco, Juniper, SONiC)
466+
- `objects/git-repo/` - Repository configuration objects
467+
- `github.yml` - GitHub repository configuration (default)
468+
- `local-dev.yml` - Local development repository configuration (when INFRAHUB_GIT_LOCAL=true)
449469
- `objects/security/` - Security-related demo data
450470
- `objects/cloud_security/` - Cloud security examples
451471
- `objects/events/` - Event action definitions

docker-compose.override.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@ services:
99
- NEO4J_dbms_memory_heap_max__size=4g
1010
- NEO4J_dbms_memory_pagecache_size=2g
1111

12+
# Mount local repository for local development
13+
# Used when INFRAHUB_GIT_LOCAL=true to work with local generator/transform changes
14+
task-worker:
15+
volumes:
16+
- ./:/upstream
17+
1218
streamlit-service-catalog:
1319
build:
1420
context: ./service_catalog

generators/common.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -959,6 +959,9 @@ async def create_oob_connections(
959959
},
960960
)
961961

962+
# Save the cable first so it exists in the database
963+
await cable.save(allow_upsert=True)
964+
962965
# Set the connector relationship on both interfaces
963966
source_endpoint.connector = cable.id
964967
target_endpoint.connector = cable.id
@@ -969,9 +972,6 @@ async def create_oob_connections(
969972
batch.add(
970973
task=target_endpoint.save, allow_upsert=True, node=target_endpoint
971974
)
972-
batch.add(
973-
task=cable.save, allow_upsert=True, node=cable
974-
)
975975
try:
976976
async for node, _ in batch.execute():
977977
hfid_str = ' -> '.join(node.hfid) if isinstance(node.hfid, list) else str(node.hfid)

generators/generate_dc.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,21 +182,21 @@ async def create_fabric_peering(self) -> None:
182182
},
183183
)
184184

185+
# Save the cable first so it exists in the database
186+
await cable.save(allow_upsert=True)
187+
185188
# Set bidirectional connector relationship
186189
# This allows queries to traverse: interface → connector → cable → connected_endpoints
187190
source_endpoint.connector = cable.id
188191
target_endpoint.connector = cable.id
189192

190-
# Queue all objects for batch save
193+
# Queue interface saves for batch
191194
batch.add(
192195
task=source_endpoint.save, allow_upsert=True, node=source_endpoint
193196
)
194197
batch.add(
195198
task=target_endpoint.save, allow_upsert=True, node=target_endpoint
196199
)
197-
batch.add(
198-
task=cable.save, allow_upsert=True, node=cable
199-
)
200200

201201
# Execute batch and log results
202202
async for node, _ in batch.execute():

objects/dc/dc-arista-s.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Object
44
spec:
55
kind: TopologyDataCenter
66
data:
7-
- name: DC-3
7+
- name: dc-arista
88
location: Frankfurt
9-
description: Frankfurt Data Center
9+
description: Arista Data Center with cEOS switches
1010
strategy: ospf-ibgp
1111
design: PHYSICAL DC ARISTA S
1212
emulation: true

objects/dc/dc-cisco-s-border-leafs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Object
44
spec:
55
kind: TopologyDataCenter
66
data:
7-
- name: DC-1
7+
- name: dc-cisco-border
88
location: Katowice
9-
description: Katowice Data Center
9+
description: Cisco Data Center with border leafs
1010
strategy: ospf-ibgp
1111
design: PHYSICAL DC CISCO S WITH BORDER LEAFS
1212
emulation: true

objects/dc/dc-cisco-s.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Object
44
spec:
55
kind: TopologyDataCenter
66
data:
7-
- name: DC-2
7+
- name: dc-cisco
88
location: Munich
9-
description: Munich Data Center
9+
description: Cisco Data Center with Nexus switches
1010
strategy: ebgp-ibgp
1111
design: PHYSICAL DC CISCO S
1212
emulation: true

objects/dc/dc-juniper-s.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Object
44
spec:
55
kind: TopologyDataCenter
66
data:
7-
- name: DC-5
7+
- name: dc-juniper
88
location: London
9-
description: London Data Center with Juniper QFX5220-32CD
9+
description: Juniper Data Center with Juniper QFX5220-32CD
1010
strategy: ospf-ibgp
1111
design: PHYSICAL DC JUNIPER S
1212
emulation: true

objects/dc/dc-sonic-border-leafs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ kind: Object
44
spec:
55
kind: TopologyDataCenter
66
data:
7-
- name: DC-4
7+
- name: dc-sonic
88
location: Barcelona
9-
description: Barcelona Data Center 4
9+
description: SONiC Data Center with border leafs
1010
strategy: ebgp-ibgp
1111
design: PHYSICAL DC SONIC S WITH BORDER LEAFS
1212
emulation: true

0 commit comments

Comments
 (0)