
"""Package for installing the Azure credentials."""

import os
from perfkitbenchmarker import object_storage_service

AZURE_CREDENTIAL_LOCATION = '.azure'
AZURE_CREDENTIAL_TOKENS_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'accessTokens.json')
AZURE_CREDENTIAL_PROFILE_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'azureProfile.json')


def Install(vm):
  """Copies Azure credentials to the VM."""
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_TOKENS_FILE)),
      AZURE_CREDENTIAL_LOCATION)
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_PROFILE_FILE)),
      AZURE_CREDENTIAL_LOCATION)


"""Package for installing the Azure credentials."""

import os
from perfkitbenchmarker import object_storage_service

AZURE_CREDENTIAL_LOCATION = '.azure'
AZURE_CREDENTIAL_TOKENS_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'accessTokens.json')
AZURE_CREDENTIAL_PROFILE_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'azureProfile.json')


def Install(vm):
  """Copies Azure credentials to the VM."""
  vm.RemoteCommand('mkdir -p {0}'.format(AZURE_CREDENTIAL_LOCATION))
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_TOKENS_FILE)),
      AZURE_CREDENTIAL_TOKENS_FILE)
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_PROFILE_FILE)),
      AZURE_CREDENTIAL_PROFILE_FILE)

Fix a bug in the Azure credentials package in which they would overwrite the directory.
Fix a bug in the Azure credentials package in which they would overwrite the directory.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=248750675

  
  """Package for installing the Azure credentials."""
  
  import os
  from perfkitbenchmarker import object_storage_service
  
  AZURE_CREDENTIAL_LOCATION = '.azure'
  AZURE_CREDENTIAL_TOKENS_FILE = os.path.join(
      AZURE_CREDENTIAL_LOCATION, 'accessTokens.json')
  AZURE_CREDENTIAL_PROFILE_FILE = os.path.join(
      AZURE_CREDENTIAL_LOCATION, 'azureProfile.json')
  
  
  def Install(vm):
    """Copies Azure credentials to the VM."""
+   vm.RemoteCommand('mkdir -p {0}'.format(AZURE_CREDENTIAL_LOCATION))
    vm.PushFile(
        object_storage_service.FindCredentialFile(
            os.path.join('~', AZURE_CREDENTIAL_TOKENS_FILE)),
-       AZURE_CREDENTIAL_LOCATION)
+       AZURE_CREDENTIAL_TOKENS_FILE)
    vm.PushFile(
        object_storage_service.FindCredentialFile(
            os.path.join('~', AZURE_CREDENTIAL_PROFILE_FILE)),
-       AZURE_CREDENTIAL_LOCATION)
+       AZURE_CREDENTIAL_PROFILE_FILE)
  
Fix a bug in the Azure credentials package in which they would overwrite the directory.
## Code Before:

"""Package for installing the Azure credentials."""

import os
from perfkitbenchmarker import object_storage_service

AZURE_CREDENTIAL_LOCATION = '.azure'
AZURE_CREDENTIAL_TOKENS_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'accessTokens.json')
AZURE_CREDENTIAL_PROFILE_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'azureProfile.json')


def Install(vm):
  """Copies Azure credentials to the VM."""
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_TOKENS_FILE)),
      AZURE_CREDENTIAL_LOCATION)
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_PROFILE_FILE)),
      AZURE_CREDENTIAL_LOCATION)

## Instruction:
Fix a bug in the Azure credentials package in which they would overwrite the directory.
## Code After:

"""Package for installing the Azure credentials."""

import os
from perfkitbenchmarker import object_storage_service

AZURE_CREDENTIAL_LOCATION = '.azure'
AZURE_CREDENTIAL_TOKENS_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'accessTokens.json')
AZURE_CREDENTIAL_PROFILE_FILE = os.path.join(
    AZURE_CREDENTIAL_LOCATION, 'azureProfile.json')


def Install(vm):
  """Copies Azure credentials to the VM."""
  vm.RemoteCommand('mkdir -p {0}'.format(AZURE_CREDENTIAL_LOCATION))
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_TOKENS_FILE)),
      AZURE_CREDENTIAL_TOKENS_FILE)
  vm.PushFile(
      object_storage_service.FindCredentialFile(
          os.path.join('~', AZURE_CREDENTIAL_PROFILE_FILE)),
      AZURE_CREDENTIAL_PROFILE_FILE)
