Skip to content
This repository has been archived by the owner on Nov 1, 2023. It is now read-only.

Commit

Permalink
use installed azcopy if we can't use our own (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
bmc-msft authored Oct 9, 2020
1 parent 1c5be99 commit f43c44e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 11 deletions.
13 changes: 9 additions & 4 deletions src/deployment/data_migration.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
from azure.cosmosdb.table.tableservice import TableService
from azure.cosmosdb.table.models import Entity
from azure.cosmosdb.table.tablebatch import TableBatch
#!/usr/bin/env python
#
# Copyright (c) Microsoft Corporation.
# Licensed under the MIT License.

import json
from typing import Optional, Callable, Dict, List
from typing import Callable, Dict, List

from azure.cosmosdb.table.tablebatch import TableBatch
from azure.cosmosdb.table.tableservice import TableService


def migrate_task_os(table_service: TableService) -> None:
Expand Down
21 changes: 18 additions & 3 deletions src/deployment/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import json
import logging
import os
import platform
import shutil
import subprocess
import sys
Expand Down Expand Up @@ -74,6 +75,10 @@
"To disable, delete the ONEFUZZ_TELEMETRY application setting in the "
"Azure Functions instance"
)
AZCOPY_MISSING_ERROR = (
"azcopy is not installed and unable to use the built-in version. "
"Installation instructions are available at https://aka.ms/azcopy"
)
FUNC_TOOLS_ERROR = (
"azure-functions-core-tools is not installed, "
"install v3 using instructions: "
Expand Down Expand Up @@ -127,11 +132,21 @@ def __init__(
self.migrations = migrations
self.export_appinsights = export_appinsights

if os.name == "nt":
self.azcopy = os.path.join(self.tools, "win64", "azcopy.exe")
else:
machine = platform.machine()
system = platform.system()

if system == "Linux" and machine == "x86_64":
self.azcopy = os.path.join(self.tools, "linux", "azcopy")
subprocess.check_output(["chmod", "+x", self.azcopy])
elif system == "Windows" and machine == "AMD64":
self.azcopy = os.path.join(self.tools, "win64", "azcopy.exe")
else:
azcopy = shutil.which("azcopy")
if not azcopy:
raise Exception(AZCOPY_MISSING_ERROR)
else:
logger.warn("unable to use built-in azcopy, using system install")
self.azcopy = azcopy

with open(workbook_data) as f:
self.workbook_data = json.load(f)
Expand Down
11 changes: 7 additions & 4 deletions src/deployment/register_pool_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import logging
import os
from datetime import datetime, timedelta
from typing import Dict, List, Tuple, NamedTuple, Optional
from typing import Dict, List, NamedTuple, Optional, Tuple
from uuid import UUID, uuid4

from azure.cli.core import get_default_cli # type: ignore
Expand All @@ -23,7 +23,6 @@
from functional import seq
from msrest.serialization import TZ_UTC


logger = logging.getLogger("deploy")


Expand Down Expand Up @@ -120,7 +119,8 @@ def create_application_registration(
required_resource_access=(
[
RequiredResourceAccess(
resource_access=resource_access, resource_app_id=app.app_id,
resource_access=resource_access,
resource_app_id=app.app_id,
)
]
if len(resource_access) > 0
Expand Down Expand Up @@ -268,7 +268,10 @@ def main():
formatter = argparse.ArgumentDefaultsHelpFormatter
parser = argparse.ArgumentParser(
formatter_class=formatter,
description="Create an application registration and/or generate a password for the pool agent",
description=(
"Create an application registration and/or "
"generate a password for the pool agent"
),
)
parser.add_argument("application_name")
parser.add_argument("-v", "--verbose", action="store_true")
Expand Down

0 comments on commit f43c44e

Please sign in to comment.