Skip to content

Commit 06897f5

Browse files
authored
Merge pull request #294 from Azure/endpoint-updates
Endpoint Updates + Build Enhancements
2 parents 35bb35a + d1ec3a5 commit 06897f5

31 files changed

+2639
-707
lines changed

.github/workflows/azure-ipam-build.yml

+19
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ jobs:
3232
with:
3333
node-version: 18
3434

35+
- name: "Setup Python v3.9"
36+
id: setupPython
37+
uses: actions/setup-python@v5
38+
with:
39+
python-version: '3.9'
40+
3541
- name: "Extract Pull Request Details"
3642
id: getPullRequestData
3743
uses: actions/github-script@v7
@@ -91,6 +97,19 @@ jobs:
9197
run: |
9298
npm install
9399
100+
- name: Install PIP Packages
101+
id: installPipPackages
102+
working-directory: engine
103+
run: |
104+
pip install -r requirements.txt
105+
106+
- name: Freeze PIP Packages
107+
id: freezePipPackages
108+
working-directory: engine
109+
run: |
110+
echo "# Dependencies for Azure IPAM v${{ steps.updateVersion.outputs.ipamVersion }}" > requirements.lock.txt
111+
pip freeze >> requirements.lock.txt
112+
94113
- name: "Create Azure IPAM ZIP Asset"
95114
id: buildZipAsset
96115
working-directory: tools

Dockerfile.deb

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ WORKDIR /tmp
1515
COPY ./ui/. ./
1616

1717
# Install UI Dependencies
18-
RUN npm install
18+
RUN npm ci
1919
RUN chmod 777 -R node_modules
2020

2121
# Build IPAM UI
@@ -52,13 +52,13 @@ RUN mkdir /var/run/sshd
5252
WORKDIR /ipam
5353

5454
# Install Engine Dependencies
55-
COPY ./engine/requirements.txt /code/requirements.txt
55+
COPY ./engine/requirements.lock.txt /code/requirements.lock.txt
5656

5757
# Upgrade PIP
5858
RUN pip install --upgrade pip --progress-bar off
5959

6060
# Install Dependencies
61-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt --progress-bar off
61+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.lock.txt --progress-bar off
6262

6363
# Copy Engine Code
6464
COPY ./engine/app ./app

Dockerfile.func

+3-3
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ WORKDIR /tmp
1313
COPY ./ui/. ./
1414

1515
# Install UI Dependencies
16-
RUN npm install
16+
RUN npm ci
1717
RUN chmod 777 -R node_modules
1818

1919
# Build IPAM UI
@@ -31,13 +31,13 @@ ENV PIP_ROOT_USER_ACTION=ignore
3131
WORKDIR /tmp
3232

3333
# Copy Requirements File
34-
COPY ./engine/requirements.txt .
34+
COPY ./engine/requirements.lock.txt .
3535

3636
# Upgrade PIP
3737
RUN pip install --upgrade pip --progress-bar off
3838

3939
# Install Dependencies
40-
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt --progress-bar off
40+
RUN pip install --no-cache-dir --upgrade -r ./requirements.lock.txt --progress-bar off
4141

4242
# Copy Application Code to Function App Root Directory
4343
COPY ./engine/. /home/site/wwwroot

Dockerfile.rhel

+3-3
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ USER root
1818
COPY ./ui/. ./
1919

2020
# Install UI Dependencies
21-
RUN npm install
21+
RUN npm ci
2222
RUN chmod 777 -R node_modules
2323

2424
# Build IPAM UI
@@ -62,13 +62,13 @@ RUN mkdir /var/run/sshd
6262
WORKDIR /ipam
6363

6464
# Install Engine Dependencies
65-
COPY ./engine/requirements.txt /code/requirements.txt
65+
COPY ./engine/requirements.lock.txt /code/requirements.lock.txt
6666

6767
# Upgrade PIP
6868
RUN pip install --upgrade pip --progress-bar off
6969

7070
# Install Dependencies
71-
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt --progress-bar off
71+
RUN pip install --no-cache-dir --upgrade -r /code/requirements.lock.txt --progress-bar off
7272

7373
# Copy Engine Code
7474
COPY ./engine/app ./app

deploy/deploy.ps1

+1-1
Original file line numberDiff line numberDiff line change
@@ -1252,7 +1252,7 @@ process {
12521252
Write-Host
12531253
Stop-Transcript | Out-Null
12541254

1255-
if ($script:deploymentSuccess) {
1255+
if (($PSCmdlet.ParameterSetName -notin 'AppsOnly') -and $script:deploymentSuccess) {
12561256
Write-Output "ipamURL=https://$($deployment.Outputs["appServiceHostName"].Value)" >> $Env:GITHUB_OUTPUT
12571257
Write-Output "ipamUIAppId=$($appDetails.UIAppId)" >> $Env:GITHUB_OUTPUT
12581258
Write-Output "ipamEngineAppId=$($appDetails.EngineAppId)" >> $Env:GITHUB_OUTPUT

deploy/main.parameters.example.json

-3
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@
2828
},
2929
"privateAcr": {
3030
"value": false
31-
},
32-
"disableUi": {
33-
"value": false
3431
}
3532
}
3633
}

engine/Dockerfile.deb

+2-2
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ ENV PIP_ROOT_USER_ACTION=ignore
1313
WORKDIR /ipam
1414

1515
# Copy Requirements File
16-
ADD ./requirements.txt .
16+
ADD ./requirements.lock.txt .
1717

1818
# Upgrade PIP
1919
RUN pip install --upgrade pip --progress-bar off
2020

2121
# Install Dependencies
22-
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt --progress-bar off
22+
RUN pip install --no-cache-dir --upgrade -r ./requirements.lock.txt --progress-bar off
2323

2424
# Copy Application Scripts & Sources
2525
ADD ./app ./app

engine/Dockerfile.func

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ ENV AzureWebJobsScriptRoot=/home/site/wwwroot \
66
AzureFunctionsJobHost__Logging__Console__IsEnabled=true
77

88
# Copy Requirements File
9-
ADD ./requirements.txt .
9+
ADD ./requirements.lock.txt .
1010

1111
# Upgrade PIP
1212
RUN pip install --upgrade pip --progress-bar off
1313

1414
# Install Dependencies
15-
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt --progress-bar off
15+
RUN pip install --no-cache-dir --upgrade -r ./requirements.lock.txt --progress-bar off
1616

1717
# Copy Application Code to Function App Root Directory
1818
COPY . /home/site/wwwroot

engine/Dockerfile.rhel

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ WORKDIR /ipam
1616
USER root
1717

1818
# Copy Requirements File
19-
ADD ./requirements.txt /ipam
19+
ADD ./requirements.lock.txt /ipam
2020

2121
# Upgrade PIP
2222
RUN pip install --upgrade pip --progress-bar off
2323

2424
# Install Dependencies
25-
RUN pip install --no-cache-dir --upgrade -r ./requirements.txt --progress-bar off
25+
RUN pip install --no-cache-dir --upgrade -r ./requirements.lock.txt --progress-bar off
2626

2727
# Copy Application Scripts & Sources
2828
ADD ./app ./appDockerfile

engine/app/main.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,10 @@ async def ipam_init():
152152
"env": globals.AZURE_ENV
153153
}
154154

155-
requests.post(url = "https://azureipammetrics.azurewebsites.net/api/heartbeat", json = hb_message)
155+
try:
156+
requests.post(url = "https://azureipammetrics.azurewebsites.net/api/heartbeat", json = hb_message)
157+
except Exception:
158+
pass
156159

157160
async def upgrade_db():
158161
managed_identity_credential = ManagedIdentityCredential(

engine/app/models.py

+7-1
Original file line numberDiff line numberDiff line change
@@ -445,7 +445,7 @@ def validate_request(cls, data: Any) -> Any:
445445

446446
return data
447447

448-
class ExtEndpointUpdate(BaseModel):
448+
class ExtEndpointReq(BaseModel):
449449
"""DOCSTRING"""
450450

451451
name: str
@@ -463,6 +463,12 @@ class JSONPatch(BaseModel):
463463

464464
BlockUpdate = Annotated[List[JSONPatch], None]
465465

466+
ExtNetUpdate = Annotated[List[JSONPatch], None]
467+
468+
ExtSubnetUpdate = Annotated[List[JSONPatch], None]
469+
470+
ExtEndpointUpdate = Annotated[List[JSONPatch], None]
471+
466472
VNetsUpdate = Annotated[List[str], None]
467473

468474
ExtNetsUpdate = Annotated[List[ExtNet], None]

engine/app/routers/admin.py

+33
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,39 @@ async def update_admins(
171171

172172
return PlainTextResponse(status_code=status.HTTP_200_OK)
173173

174+
@router.get(
175+
"/admins/{objectId}",
176+
summary = "Get IPAM Admin",
177+
response_model = Admin,
178+
status_code = 200
179+
)
180+
async def get_admins(
181+
objectId: UUID = Path(..., description="Azure AD ObjectID for the target user"),
182+
authorization: str = Header(None, description="Azure Bearer token"),
183+
tenant_id: str = Depends(get_tenant_id),
184+
is_admin: str = Depends(get_admin)
185+
):
186+
"""
187+
Get a specific IPAM admin.
188+
"""
189+
190+
if not is_admin:
191+
raise HTTPException(status_code=403, detail="API restricted to admins.")
192+
193+
admin_query = await cosmos_query("SELECT * FROM c WHERE c.type = 'admin'", tenant_id)
194+
195+
try:
196+
admins = copy.deepcopy(admin_query[0])
197+
except:
198+
raise HTTPException(status_code=400, detail="No admins found in database.")
199+
200+
target_admin = next((x for x in admins['admins'] if x['id'] == str(objectId)), None)
201+
202+
if target_admin:
203+
return target_admin
204+
else:
205+
raise HTTPException(status_code=404, detail="Admin not found.")
206+
174207
@router.delete(
175208
"/admins/{objectId}",
176209
summary = "Delete IPAM Admin",

0 commit comments

Comments
 (0)