mirror of
https://github.com/microsoft/onefuzz.git
synced 2025-06-15 11:28:09 +00:00
use installed azcopy if we can't use our own (#126)
This commit is contained in:
@ -1,8 +1,13 @@
|
|||||||
from azure.cosmosdb.table.tableservice import TableService
|
#!/usr/bin/env python
|
||||||
from azure.cosmosdb.table.models import Entity
|
#
|
||||||
from azure.cosmosdb.table.tablebatch import TableBatch
|
# Copyright (c) Microsoft Corporation.
|
||||||
|
# Licensed under the MIT License.
|
||||||
|
|
||||||
import json
|
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:
|
def migrate_task_os(table_service: TableService) -> None:
|
||||||
|
@ -7,6 +7,7 @@ import argparse
|
|||||||
import json
|
import json
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
|
import platform
|
||||||
import shutil
|
import shutil
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
@ -74,6 +75,10 @@ TELEMETRY_NOTICE = (
|
|||||||
"To disable, delete the ONEFUZZ_TELEMETRY application setting in the "
|
"To disable, delete the ONEFUZZ_TELEMETRY application setting in the "
|
||||||
"Azure Functions instance"
|
"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 = (
|
FUNC_TOOLS_ERROR = (
|
||||||
"azure-functions-core-tools is not installed, "
|
"azure-functions-core-tools is not installed, "
|
||||||
"install v3 using instructions: "
|
"install v3 using instructions: "
|
||||||
@ -127,11 +132,21 @@ class Client:
|
|||||||
self.migrations = migrations
|
self.migrations = migrations
|
||||||
self.export_appinsights = export_appinsights
|
self.export_appinsights = export_appinsights
|
||||||
|
|
||||||
if os.name == "nt":
|
machine = platform.machine()
|
||||||
self.azcopy = os.path.join(self.tools, "win64", "azcopy.exe")
|
system = platform.system()
|
||||||
else:
|
|
||||||
|
if system == "Linux" and machine == "x86_64":
|
||||||
self.azcopy = os.path.join(self.tools, "linux", "azcopy")
|
self.azcopy = os.path.join(self.tools, "linux", "azcopy")
|
||||||
subprocess.check_output(["chmod", "+x", self.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:
|
with open(workbook_data) as f:
|
||||||
self.workbook_data = json.load(f)
|
self.workbook_data = json.load(f)
|
||||||
|
@ -8,7 +8,7 @@ import json
|
|||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
from datetime import datetime, timedelta
|
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 uuid import UUID, uuid4
|
||||||
|
|
||||||
from azure.cli.core import get_default_cli # type: ignore
|
from azure.cli.core import get_default_cli # type: ignore
|
||||||
@ -23,7 +23,6 @@ from azure.graphrbac.models import (
|
|||||||
from functional import seq
|
from functional import seq
|
||||||
from msrest.serialization import TZ_UTC
|
from msrest.serialization import TZ_UTC
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger("deploy")
|
logger = logging.getLogger("deploy")
|
||||||
|
|
||||||
|
|
||||||
@ -120,7 +119,8 @@ def create_application_registration(
|
|||||||
required_resource_access=(
|
required_resource_access=(
|
||||||
[
|
[
|
||||||
RequiredResourceAccess(
|
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
|
if len(resource_access) > 0
|
||||||
@ -268,7 +268,10 @@ def main():
|
|||||||
formatter = argparse.ArgumentDefaultsHelpFormatter
|
formatter = argparse.ArgumentDefaultsHelpFormatter
|
||||||
parser = argparse.ArgumentParser(
|
parser = argparse.ArgumentParser(
|
||||||
formatter_class=formatter,
|
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("application_name")
|
||||||
parser.add_argument("-v", "--verbose", action="store_true")
|
parser.add_argument("-v", "--verbose", action="store_true")
|
||||||
|
Reference in New Issue
Block a user