-
Notifications
You must be signed in to change notification settings - Fork 181
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Mangirdas Judeikis <[email protected]>
- Loading branch information
Showing
23 changed files
with
619 additions
and
163 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
PYTHONPATH=python/az/aro |
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,27 @@ | ||
name: pull_request-test-python | ||
on: | ||
pull_request: | ||
types: | ||
- opened | ||
- synchronize | ||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: | ||
- 2.7 | ||
- 3.5.7 | ||
- 3.6.9 | ||
steps: | ||
- name: Set up Python | ||
uses: actions/setup-python@v1 | ||
with: | ||
python-version: ${{ matrix.python-version }} | ||
- name: Check out source | ||
uses: actions/checkout@v1 | ||
- name: Test | ||
run: | | ||
set -x | ||
pip install virtualenv | ||
make test-python |
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 |
---|---|---|
@@ -1,9 +1,16 @@ | ||
__pycache__ | ||
*.egg-info | ||
*.pyc | ||
/.vscode | ||
/*.crt | ||
/*.key | ||
/*.pem | ||
/*.kubeconfig | ||
/*.pem | ||
/env* | ||
!/env.example | ||
/id_rsa | ||
/pyenv* | ||
/python/az/aro/build | ||
/python/az/aro/dist | ||
/rp | ||
/secrets |
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 |
---|---|---|
@@ -1,14 +1,11 @@ | ||
# Deploy production cluster | ||
|
||
export VNET_RESOURCEGROUP=$RESOURCEGROUP-vnet | ||
|
||
export CLUSTER=cluster | ||
VNET_RESOURCEGROUP=$RESOURCEGROUP-vnet | ||
CLUSTER=cluster | ||
|
||
az group create -g "$VNET_RESOURCEGROUP" -l "$LOCATION" | ||
az network vnet create -g "$VNET_RESOURCEGROUP" -n vnet --address-prefixes 10.0.0.0/9 | ||
az network vnet subnet create -g "$VNET_RESOURCEGROUP" --vnet-name vnet -n "$CLUSTER-master" --address-prefixes 10.$((RANDOM & 127)).$((RANDOM & 255)).0/24 | ||
az network vnet subnet create -g "$VNET_RESOURCEGROUP" --vnet-name vnet -n "$CLUSTER-worker" --address-prefixes 10.$((RANDOM & 127)).$((RANDOM & 255)).0/24 | ||
|
||
az role assignment create --role "ARO v4 Development Subnet Contributor" --assignee-object-id "$(az ad sp list --all --query "[?appId=='f1dd0a37-89c6-4e07-bcd1-ffd3d43d8875'].objectId" -o tsv)" --scope "/subscriptions/$AZURE_SUBSCRIPTION_ID/resourceGroups/$VNET_RESOURCEGROUP/providers/Microsoft.Network/virtualNetworks/vnet" | ||
|
||
az aro create --resource-group $RESOURCEGROUP --name $CLUSTER --client-id $AZURE_CLUSTER_CLIENT_ID --client-secret $AZURE_CLUSTER_CLIENT_SECRET --vnet-rg-name $VNET_RESOURCEGROUP | ||
az aro create -g "$RESOURCEGROUP" -n "$CLUSTER" --vnet-resource-group "$VNET_RESOURCEGROUP" --vnet vnet --master-subnet "$CLUSTER-master" --worker-subnet "$CLUSTER-worker" |
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 was deleted.
Oops, something went wrong.
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,68 @@ | ||
import datetime | ||
import uuid | ||
|
||
from azure.cli.core._profile import Profile | ||
from azure.cli.core.commands.client_factory import configure_common_settings | ||
from azure.graphrbac import GraphRbacManagementClient | ||
from azure.graphrbac.models import ApplicationCreateParameters | ||
from azure.graphrbac.models import PasswordCredential | ||
from azure.graphrbac.models import ServicePrincipalCreateParameters | ||
|
||
|
||
class AADManager(object): | ||
MANAGED_APP_PREFIX = "https://az.aro.azure.com/" | ||
|
||
def __init__(self, cli_ctx): | ||
profile = Profile(cli_ctx=cli_ctx) | ||
credentials, _, tenant_id = profile.get_login_credentials( | ||
resource=cli_ctx.cloud.endpoints.active_directory_graph_resource_id) | ||
self.client = GraphRbacManagementClient( | ||
credentials, tenant_id, base_url=cli_ctx.cloud.endpoints.active_directory_graph_resource_id) | ||
configure_common_settings(cli_ctx, self.client) | ||
|
||
def createManagedApplication(self, display_name): | ||
password = uuid.uuid4() | ||
|
||
try: | ||
end_date = datetime.datetime(2299, 12, 31, tzinfo=datetime.timezone.utc) | ||
except AttributeError: | ||
end_date = datetime.datetime(2299, 12, 31) | ||
|
||
app = self.client.applications.create(ApplicationCreateParameters( | ||
display_name=display_name, | ||
identifier_uris=[ | ||
self.MANAGED_APP_PREFIX + str(uuid.uuid4()), | ||
], | ||
password_credentials=[ | ||
PasswordCredential( | ||
end_date=end_date, | ||
value=password, | ||
), | ||
], | ||
)) | ||
|
||
return app, password | ||
|
||
def getApplication(self, app_id): | ||
apps = list(self.client.applications.list( | ||
filter="appId eq '%s'" % app_id)) | ||
if apps: | ||
return apps[0] | ||
return None | ||
|
||
def deleteManagedApplication(self, app_id): | ||
app = self.getApplication(app_id) | ||
if app and app.identifier_uris and app.identifier_uris[0].startswith(self.MANAGED_APP_PREFIX): | ||
self.client.applications.delete(app.object_id) | ||
|
||
def getServicePrincipal(self, app_id): | ||
sps = list(self.client.service_principals.list( | ||
filter="appId eq '%s'" % app_id)) | ||
if sps: | ||
return sps[0] | ||
return None | ||
|
||
def createServicePrincipal(self, app_id): | ||
return self.client.service_principals.create(ServicePrincipalCreateParameters( | ||
app_id=app_id, | ||
)) |
Oops, something went wrong.