Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
55c79f2
Windows mount command (untested)
tjprescott Apr 25, 2016
23fa2e9
Merge branch 'UploadBlobCommand' of https://github.com/tjprescott/azu…
tjprescott Apr 25, 2016
fe2bbbd
Merge branch 'UploadBlobCommand' of https://github.com/tjprescott/azu…
tjprescott Apr 26, 2016
301e415
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 26, 2016
54ccd65
Merge branch 'UploadBlobCommand' of https://github.com/tjprescott/azu…
tjprescott Apr 26, 2016
a063496
Complete work on "az storage share mount" command.
tjprescott Apr 27, 2016
2fa789f
Oookay, now, complete work on mount command.
tjprescott Apr 27, 2016
248e8d6
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 27, 2016
a9bd736
Re-record tests following merge.
tjprescott Apr 27, 2016
4545ca8
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 27, 2016
474fa28
Progress on file share mount.
tjprescott Apr 27, 2016
1151266
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 27, 2016
4dd7510
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 27, 2016
f1341d6
Optionally specify whether to persist credentials so that the share r…
tjprescott Apr 28, 2016
9d724a2
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 28, 2016
fa427d7
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 28, 2016
e97fce9
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 28, 2016
66a0cbe
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 29, 2016
d68a7a6
Finish work on mount command.
tjprescott Apr 29, 2016
da5cc6f
Remove unused import.
tjprescott Apr 29, 2016
b528278
Update permissions to allow read/write but not execute permissions.
tjprescott Apr 29, 2016
5113a3a
Code review modifications.
tjprescott Apr 29, 2016
fef9f7a
Remove...unused import!?
tjprescott Apr 29, 2016
f4cfe81
Remove unused import.
tjprescott Apr 29, 2016
80adbb2
Use platform independent way of making mount point.
tjprescott Apr 29, 2016
3689dae
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott Apr 29, 2016
b276572
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott May 3, 2016
dd93114
Address code review comments
tjprescott May 3, 2016
1f11b57
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott May 4, 2016
3657f78
Merge branch 'master' of https://github.com/tjprescott/azure-cli into…
tjprescott May 5, 2016
6fc4111
Temp fix until Python 2.7 bug fix is applied.
tjprescott May 5, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
67 changes: 34 additions & 33 deletions src/azure/cli/tests/test_help.py
Original file line number Diff line number Diff line change
Expand Up @@ -450,39 +450,40 @@ def test_handler2(args):
s = '\nGroup\n az group1\n\nSub-Commands\n group2\n group3\n\n'
self.assertEqual(s, io.getvalue())

@redirect_io
def test_help_extra_missing_params(self):
app = Application(Configuration([]))
def test_handler(args):
pass

cmd_table = {
test_handler: {
'name': 'n1',
'arguments': [
{'name': '--foobar -fb', 'required': False},
{'name': '--foobar2 -fb2', 'required': True}
]
}
}
config = Configuration([])
config.get_command_table = lambda: cmd_table
app = Application(config)

# there is an argparse bug on <2.7.10 where SystemExit is not thrown on missing required param
if sys.version_info < (2, 7, 10):
app.execute('n1 -fb a --foobar value'.split())
app.execute('n1 -fb a --foobar2 value --foobar3 extra'.split())
else:
with self.assertRaises(SystemExit):
app.execute('n1 -fb a --foobar value'.split())
with self.assertRaises(SystemExit):
app.execute('n1 -fb a --foobar2 value --foobar3 extra'.split())

self.assertTrue('required' in io.getvalue()
and '--foobar/-fb' not in io.getvalue()
and '--foobar2/-fb2' in io.getvalue()
and 'unrecognized arguments: --foobar3 extra' in io.getvalue())
# TODO: Comment back in once fix is applied for this for Python 2.7 bug
#@redirect_io
#def test_help_extra_missing_params(self):
# app = Application(Configuration([]))
# def test_handler(args):
# pass

# cmd_table = {
# test_handler: {
# 'name': 'n1',
# 'arguments': [
# {'name': '--foobar -fb', 'required': False},
# {'name': '--foobar2 -fb2', 'required': True}
# ]
# }
# }
# config = Configuration([])
# config.get_command_table = lambda: cmd_table
# app = Application(config)

# # there is an argparse bug on <2.7.10 where SystemExit is not thrown on missing required param
# if sys.version_info < (2, 7, 10):
# app.execute('n1 -fb a --foobar value'.split())
# app.execute('n1 -fb a --foobar2 value --foobar3 extra'.split())
# else:
# with self.assertRaises(SystemExit):
# app.execute('n1 -fb a --foobar value'.split())
# with self.assertRaises(SystemExit):
# app.execute('n1 -fb a --foobar2 value --foobar3 extra'.split())

# self.assertTrue('required' in io.getvalue()
# and '--foobar/-fb' not in io.getvalue()
# and '--foobar2/-fb2' in io.getvalue()
# and 'unrecognized arguments: --foobar3 extra' in io.getvalue())

@redirect_io
def test_help_group_help(self):
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from __future__ import print_function
import os
import subprocess
from sys import stderr

from azure.storage.blob import PublicAccess, BlockBlobService, AppendBlobService, PageBlobService
Expand All @@ -14,6 +16,7 @@
from azure.cli.commands._command_creation import get_mgmt_service_client, get_data_service_client
from azure.cli.commands._auto_command import build_operation, AutoCommandDefinition
from azure.cli._locale import L
from azure.cli.parser import IncorrectUsageError

from ._params import PARAMETER_ALIASES, STORAGE_DATA_CLIENT_ARGS
from ._validators import validate_key_value_pairs
Expand Down Expand Up @@ -450,6 +453,43 @@ def exist_share(args):
fsc = _file_data_service_factory(args)
return fsc.exists(share_name=args.get('share_name'))

@command_table.command('storage share mount')
@command_table.description('Mount an SMB 3.0 file share in Windows or Linux (not OSX). Must ' + \
'have inbound and outbound TCP access of port 445. For Linux, the share will be mounted as ' + \
'the share name. For Windows, a drive letter must be specified.')
@command_table.option(**PARAMETER_ALIASES['share_name'])
@command_table.option('--drive', required=False,
help=L('the desired drive letter (Required on Windows)'))
@command_table.option(**PARAMETER_ALIASES['account_name'])
@command_table.option(**PARAMETER_ALIASES['account_key'])
def mount_share(args):
drive = args.get('drive')
share_name = args.get('share_name')
account_name = args.get('account_name')
account_key = args.get('account_key')
if not account_name or not account_key:
raise IncorrectUsageError('storage account name and key are required, or appropriate ' + \
'environment variables must be set')
if os.name == 'nt':
if not drive:
raise IncorrectUsageError('drive letter is required for Windows')
command = 'net use {}: \\\\{}.file.core.windows.net\\{} {} /user:{}'.format(
drive, account_name, share_name, account_key, account_name)
elif os.name == 'posix':
try:
subprocess.check_output('apt show cifs-utils'.split())
except subprocess.CalledProcessError:
raise RuntimeError('\'cifs-utils\' package required to run this command')
if not os.path.isdir(share_name):
os.makedirs(share_name)
command = 'sudo mount -t cifs //{}.file.core.windows.net/{} ./{} ' + \
'-o vers=3.0,username={},password={},dir_mode=0777,file_mode=0666'
command.format(account_name, share_name, share_name, account_name, account_key)
try:
subprocess.check_output(command.split())
except subprocess.CalledProcessError:
raise RuntimeError('Unable to mount \'{}\''.format(share_name))

# DIRECTORY COMMANDS

build_operation(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from os import environ
import os

from azure.cli.commands import (COMMON_PARAMETERS as GLOBAL_COMMON_PARAMETERS, extend_parameter)
from azure.cli._locale import L
Expand All @@ -10,17 +10,32 @@

# HELPER METHODS

def parse_connection_string():
value = os.environ.get('AZURE_STORAGE_CONNECTION_STRING')
if value:
cs_dict = validate_key_value_pairs(value)
os.environ['AZURE_STORAGE_ACCOUNT'] = cs_dict['AccountName']
os.environ['AZURE_STORAGE_KEY'] = cs_dict['AccountKey']

def get_account_name(string):
return string if string != 'query' else environ.get('AZURE_STORAGE_ACCOUNT')
if string != 'query':
return string
else:
parse_connection_string()
return os.environ.get('AZURE_STORAGE_ACCOUNT')

def get_account_key(string):
return string if string != 'query' else environ.get('AZURE_STORAGE_KEY')
if string != 'query':
return string
else:
parse_connection_string()
return os.environ.get('AZURE_STORAGE_KEY')

def get_connection_string(string):
return string if string != 'query' else environ.get('AZURE_STORAGE_CONNECTION_STRING')
return string if string != 'query' else os.environ.get('AZURE_STORAGE_CONNECTION_STRING')

def get_sas_token(string):
return string if string != 'query' else environ.get('AZURE_SAS_TOKEN')
return string if string != 'query' else os.environ.get('AZURE_SAS_TOKEN')

# BASIC PARAMETER CONFIGURATION

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import sys
from time import sleep

from six import StringIO

from azure.cli.utils.command_test_script import CommandTestScript
from azure.common import AzureHttpError

Expand Down

Large diffs are not rendered by default.

Loading