Exemplo n.º 1
0
    def __init__(self, management_cert_path, subscription_id,
            management_key_path=None):
        """Initialise the various API interfaces.
        
        Note that management_key_path is not required (except for Python 2.5),
        as the key can be included in the certificate chain file. The OpenSSL
        command line can create an appropriate PEM file like so:
        openssl pkcs12 -in azure.pfx -out azure.pem -nodes
        """
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
            subscription_id, management_key_path)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
            subscription_id, management_key_path)
        self.location_api = Locations(management_cert_path,
            subscription_id, management_key_path)
        self._sme = ServiceManagementEndpoint(management_cert_path,
            subscription_id, management_key_path)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 2
0
    def __init__(self, management_cert_path, subscription_id):
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
                                          subscription_id)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
                                           subscription_id)
        self.location_api = Locations(management_cert_path, subscription_id)
        self._sme = ServiceManagementEndpoint(management_cert_path,
                                              subscription_id)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 3
0
    def __init__(self,
                 management_cert_path,
                 subscription_id,
                 management_key_path=None):
        """Initialise the various API interfaces.
        
        Note that management_key_path is not required (except for Python 2.5),
        as the key can be included in the certificate chain file. The OpenSSL
        command line can create an appropriate PEM file like so:
        openssl pkcs12 -in azure.pfx -out azure.pem -nodes
        """
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
                                          subscription_id, management_key_path)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
                                           subscription_id,
                                           management_key_path)
        self.location_api = Locations(management_cert_path, subscription_id,
                                      management_key_path)
        self._sme = ServiceManagementEndpoint(management_cert_path,
                                              subscription_id,
                                              management_key_path)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 4
0
    def __init__(self, management_cert_path, subscription_id):
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
            subscription_id)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
            subscription_id)
        self.location_api = Locations(management_cert_path,
            subscription_id)
        self._sme = ServiceManagementEndpoint(management_cert_path,
            subscription_id)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 5
0
class WASM(object):
    """Single class that conveniently exposes Windows Azure Service Management
    operations from those implemented and explicitly exposed by the individual
    service wrappers.
    
    Using WASM
    ----------
    >>> import pyazure
    >>> pa = pyazure.PyAzure(management_cert_path=MANAGEMENT_CERT, 
    ... subscription_id=SUBSCRIPTION_ID, management_key_path=MANAGEMENT_KEY)
    >>> 'Anywhere Asia' in pa.wasm.list_locations()
    True
    >>> request_id = pa.wasm.create_storage_account('pyazuretest','doctest',
    ... 'anywhere us', 'Here is my description, not great is it?')
    >>> pa.wasm.wait_for_request(request_id)
    True
    >>> (pa.wasm.get_operation_status(request_id) == 
    ... {'HttpStatusCode': 200, 'Status': 'Succeeded'})
    True
    >>> request_id = pa.wasm.create_storage_account(
    ... 'pyazuretestwithaverylongname','doctest','anywhere us')
    Traceback (most recent call last):
        ...
    ValueError: ('pyazuretestwithaverylongname', 'name must be between 3 and 24 characters in length and use numbers and lower-case letters only.')
    >>> 'pyazuretest' in pa.wasm.list_storage_accounts()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    True
    >>> 'pyazuretest' in pa.wasm.list_services()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    Traceback (most recent call last):
        ...
    WASMError: (409, 'ConflictError', 'The specified DNS name is already taken.')
    >>> pa.wasm.create_service('pyazuretest','create service doctest' * 10,
    ... 'anywhere europe') # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ('create service doctest...', 'label exceeds 100 char limit')
    >>> pa.wasm.get_service_properties('pyazuretest') # doctest: +ELLIPSIS
    ...                                   # doctest: +NORMALIZE_WHITESPACE
    OrderedDict([('Url', 'http...'),
                 ('ServiceName', 'pyazuretest'),
                 ('HostedServiceProperties',
                     OrderedDict([('Description', ''),
                                  ('Location', 'Anywhere Europe'),
                                  ('Label', 'create service doctest')]))])
    >>> pa.wasm.delete_service('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    Traceback (most recent call last):
        ...
    WASMError: (404, 'ResourceNotFound', 'The requested storage account was not found.')
    """
    def __init__(self,
                 management_cert_path,
                 subscription_id,
                 management_key_path=None):
        """Initialise the various API interfaces.
        
        Note that management_key_path is not required (except for Python 2.5),
        as the key can be included in the certificate chain file. The OpenSSL
        command line can create an appropriate PEM file like so:
        openssl pkcs12 -in azure.pfx -out azure.pem -nodes
        """
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
                                          subscription_id, management_key_path)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
                                           subscription_id,
                                           management_key_path)
        self.location_api = Locations(management_cert_path, subscription_id,
                                      management_key_path)
        self._sme = ServiceManagementEndpoint(management_cert_path,
                                              subscription_id,
                                              management_key_path)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 6
0
class WASM(object):
    """Single class that conveniently exposes Windows Azure Service Management
    operations from those implemented and explicitly exposed by the individual
    service wrappers.
    
    Using WASM
    ----------
    >>> import pyazure
    >>> pa = pyazure.PyAzure(management_cert_path=MANAGEMENT_CERT, 
    ... subscription_id=SUBSCRIPTION_ID, management_key_path=MANAGEMENT_KEY)
    >>> 'Anywhere Asia' in pa.wasm.list_locations()
    True
    >>> request_id = pa.wasm.create_storage_account('pyazuretest','doctest',
    ... 'anywhere us', 'Here is my description, not great is it?')
    >>> pa.wasm.wait_for_request(request_id)
    True
    >>> (pa.wasm.get_operation_status(request_id) == 
    ... {'HttpStatusCode': 200, 'Status': 'Succeeded'})
    True
    >>> request_id = pa.wasm.create_storage_account(
    ... 'pyazuretestwithaverylongname','doctest','anywhere us')
    Traceback (most recent call last):
        ...
    ValueError: ('pyazuretestwithaverylongname', 'name must be between 3 and 24 characters in length and use numbers and lower-case letters only.')
    >>> 'pyazuretest' in pa.wasm.list_storage_accounts()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    True
    >>> 'pyazuretest' in pa.wasm.list_services()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    Traceback (most recent call last):
        ...
    WASMError: (409, 'ConflictError', 'The specified DNS name is already taken.')
    >>> pa.wasm.create_service('pyazuretest','create service doctest' * 10,
    ... 'anywhere europe') # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ('create service doctest...', 'label exceeds 100 char limit')
    >>> pa.wasm.get_service_properties('pyazuretest') # doctest: +ELLIPSIS
    ...                                   # doctest: +NORMALIZE_WHITESPACE
    OrderedDict([('Url', 'http...'),
                 ('ServiceName', 'pyazuretest'),
                 ('HostedServiceProperties',
                     OrderedDict([('Description', ''),
                                  ('Location', 'Anywhere Europe'),
                                  ('Label', 'create service doctest')]))])
    >>> pa.wasm.delete_service('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    Traceback (most recent call last):
        ...
    WASMError: (404, 'ResourceNotFound', 'The requested storage account was not found.')
    """

    def __init__(self, management_cert_path, subscription_id,
            management_key_path=None):
        """Initialise the various API interfaces.
        
        Note that management_key_path is not required (except for Python 2.5),
        as the key can be included in the certificate chain file. The OpenSSL
        command line can create an appropriate PEM file like so:
        openssl pkcs12 -in azure.pfx -out azure.pem -nodes
        """
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
            subscription_id, management_key_path)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
            subscription_id, management_key_path)
        self.location_api = Locations(management_cert_path,
            subscription_id, management_key_path)
        self._sme = ServiceManagementEndpoint(management_cert_path,
            subscription_id, management_key_path)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 7
0
class WASM(object):
    """Class exposing Windows Azure Service Management operations.
    
    Using WASM
    ----------
    >>> import pyazure
    >>> pa = pyazure.PyAzure(management_cert_path=MANAGEMENT_CERT, 
    ... subscription_id=SUBSCRIPTION_ID)
    >>> 'Anywhere Asia' in pa.wasm.list_locations()
    True
    >>> request_id = pa.wasm.create_storage_account('pyazuretest','doctest',
    ... 'anywhere us', 'Here is my description, not great is it?')
    >>> pa.wasm.wait_for_request(request_id)
    True
    >>> (pa.wasm.get_operation_status(request_id) == 
    ... {'HttpStatusCode': '200', 'Status': 'Succeeded'})
    True
    >>> request_id = pa.wasm.create_storage_account(
    ... 'pyazuretestwithaverylongname','doctest','anywhere us')
    Traceback (most recent call last):
        ...
    ValueError: ('pyazuretestwithaverylongname', 'name must be between 3 and 24 characters in length and use numbers and lower-case letters only.')
    >>> 'pyazuretest' in pa.wasm.list_storage_accounts()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    True
    >>> 'pyazuretest' in pa.wasm.list_services()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    Traceback (most recent call last):
        ...
    WASMError: (409, 'ConflictError', 'The specified DNS name is already taken.')
    >>> pa.wasm.create_service('pyazuretest','create service doctest' * 10,
    ... 'anywhere europe') # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ('create service doctest...', 'label exceeds 100 char limit')
    >>> pa.wasm.get_service_properties('pyazuretest') # doctest: +ELLIPSIS
    ...                                   # doctest: +NORMALIZE_WHITESPACE
    OrderedDict([('Url', 'http...'),
                 ('ServiceName', 'pyazuretest'),
                 ('HostedServiceProperties',
                     OrderedDict([('Description', ''),
                                  ('Location', 'Anywhere Europe'),
                                  ('Label', 'create service doctest')]))])
    >>> pa.wasm.delete_service('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    Traceback (most recent call last):
        ...
    WASMError: (404, 'ResourceNotFound', 'The requested storage account was not found.')
    """
    def __init__(self, management_cert_path, subscription_id):
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
                                          subscription_id)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
                                           subscription_id)
        self.location_api = Locations(management_cert_path, subscription_id)
        self._sme = ServiceManagementEndpoint(management_cert_path,
                                              subscription_id)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)
Exemplo n.º 8
0
class WASM(object):
    """Class exposing Windows Azure Service Management operations.
    
    Using WASM
    ----------
    >>> import pyazure
    >>> pa = pyazure.PyAzure(management_cert_path=MANAGEMENT_CERT, 
    ... subscription_id=SUBSCRIPTION_ID)
    >>> 'Anywhere Asia' in pa.wasm.list_locations()
    True
    >>> request_id = pa.wasm.create_storage_account('pyazuretest','doctest',
    ... 'anywhere us', 'Here is my description, not great is it?')
    >>> pa.wasm.wait_for_request(request_id)
    True
    >>> (pa.wasm.get_operation_status(request_id) == 
    ... {'HttpStatusCode': '200', 'Status': 'Succeeded'})
    True
    >>> request_id = pa.wasm.create_storage_account(
    ... 'pyazuretestwithaverylongname','doctest','anywhere us')
    Traceback (most recent call last):
        ...
    ValueError: ('pyazuretestwithaverylongname', 'name must be between 3 and 24 characters in length and use numbers and lower-case letters only.')
    >>> 'pyazuretest' in pa.wasm.list_storage_accounts()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    True
    >>> 'pyazuretest' in pa.wasm.list_services()
    True
    >>> pa.wasm.create_service('pyazuretest','create service doctest',
    ... 'anywhere europe')
    Traceback (most recent call last):
        ...
    WASMError: (409, 'ConflictError', 'The specified DNS name is already taken.')
    >>> pa.wasm.create_service('pyazuretest','create service doctest' * 10,
    ... 'anywhere europe') # doctest: +ELLIPSIS
    Traceback (most recent call last):
        ...
    ValueError: ('create service doctest...', 'label exceeds 100 char limit')
    >>> pa.wasm.get_service_properties('pyazuretest') # doctest: +ELLIPSIS
    ...                                   # doctest: +NORMALIZE_WHITESPACE
    OrderedDict([('Url', 'http...'),
                 ('ServiceName', 'pyazuretest'),
                 ('HostedServiceProperties',
                     OrderedDict([('Description', ''),
                                  ('Location', 'Anywhere Europe'),
                                  ('Label', 'create service doctest')]))])
    >>> pa.wasm.delete_service('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    True
    >>> pa.wasm.delete_storage_account('pyazuretest')
    Traceback (most recent call last):
        ...
    WASMError: (404, 'ResourceNotFound', 'The requested storage account was not found.')
    """

    def __init__(self, management_cert_path, subscription_id):
        from hostedservices import HostedServices, ServiceConfiguration
        from storageaccounts import StorageAccounts
        from locations import Locations
        self.service_api = HostedServices(management_cert_path,
            subscription_id)
        self.ServiceConfiguration = ServiceConfiguration
        self.storage_api = StorageAccounts(management_cert_path,
            subscription_id)
        self.location_api = Locations(management_cert_path,
            subscription_id)
        self._sme = ServiceManagementEndpoint(management_cert_path,
            subscription_id)
        self.WASMError = WASMError
        self.get_operation_status = self._sme.get_operation_status
        self.request_done = self._sme.request_done
        self.wait_for_request = self._sme.wait_for_request

        for op in self.service_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.storage_api.get_wasm_ops():
            setattr(self, op.__name__, op)
        for op in self.location_api.get_wasm_ops():
            setattr(self, op.__name__, op)