Commit 90be72f9 by Szabolcs Gelencser

Implement create_azure_storage_profile task.

parent 7b358f8c
amqp==1.4.9
anyjson==0.3.3
azure==2.0.0rc6
azure-batch==1.0.0
azure-common==1.1.4
azure-mgmt==0.30.0rc6
azure-mgmt-batch==1.0.0
azure-mgmt-compute==0.30.0rc6
azure-mgmt-keyvault==0.30.0rc6
azure-mgmt-logic==1.0.0
azure-mgmt-network==0.30.0rc6
azure-mgmt-nspkg==1.0.0
azure-mgmt-redis==1.0.0
azure-mgmt-resource==0.30.0rc6
azure-mgmt-scheduler==1.0.0
azure-mgmt-storage==0.30.0rc6
azure-nspkg==1.0.0
azure-servicebus==0.20.3
azure-servicemanagement-legacy==0.20.4
azure-storage==0.33.0
billiard==3.3.0.23
celery==3.1.17 celery==3.1.17
requests==2.5.3 certifi==2016.9.26
cffi==1.8.3
chardet==2.3.0
cryptography==1.5.2
enum34==1.1.6
filemagic==1.6 filemagic==1.6
futures==3.0.5
idna==2.1
ipaddress==1.0.17
isodate==0.5.4
keyring==9.3.1
kombu==3.0.35
msrest==0.4.4
msrestazure==0.4.3
oauthlib==2.0.0
pyasn1==0.1.9
pycparser==2.14
python-dateutil==2.5.3
pytz==2016.6.1
requests==2.5.3
requests-oauthlib==0.7.0
six==1.10.0
wsgiref==0.1.2
from disk import Disk from disk import Disk
from storagecelery import celery from storagecelery import celery
from os import path, unlink, statvfs, listdir, mkdir from os import path, unlink, statvfs, listdir, mkdir, getenv
from shutil import move from shutil import move
from celery.contrib.abortable import AbortableTask from celery.contrib.abortable import AbortableTask
import logging import logging
...@@ -9,6 +9,48 @@ logger = logging.getLogger(__name__) ...@@ -9,6 +9,48 @@ logger = logging.getLogger(__name__)
trash_directory = "trash" trash_directory = "trash"
from azure.common.credentials import ServicePrincipalCredentials
import azure.mgmt.storage
from azure.mgmt.storage.models import StorageAccountCreateParameters, Sku, Kind
SUBSCRIPTION_ID = getenv('SUBSCRIPTION_ID')
CLIENT_ID = getenv('CLIENT_ID')
SECRET = getenv('SECRET')
TENANT = getenv('TENANT')
GROUP_NAME = getenv('GROUP_NAME')
REGION = getenv('REGION')
credentials = ServicePrincipalCredentials(
client_id = CLIENT_ID,
secret = SECRET,
tenant = TENANT,
)
storage_client = azure.mgmt.storage.StorageManagementClient(
credentials,
SUBSCRIPTION_ID
)
@celery.task()
def create_azure_storage_profile(name):
poller = storage_client.storage_accounts.create(
GROUP_NAME,
name,
StorageAccountCreateParameters(
sku=Sku('Standard_LRS'),
kind=Kind.storage,
location=REGION,
),
)
try:
poller.wait()
logger.info("created storage profile with id: %s" % poller.result().id)
return poller.result().id
except Exception, e:
logger.error("cloud not create storage profile")
logger.error(str(e))
return None
@celery.task() @celery.task()
def list(dir): def list(dir):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment