@@ -0,0 +1,3158 @@
+'''%0ACreated on May 1, 2013%0A%0A@author: mpastern%0A'''%0A%0Afrom ovirtsdk.xml import params%0Afrom src.resource.abstractresourcemanager import AbstractResourceManager%0Afrom src.resource.resourcefactory import ResourceFactory%0Afrom src.infrastructure.annotations import requires%0Afrom src.resource.datacenterresourcemanager import DataCenterResourceManager%0A%0Aclass StorageDomainResourceManager(AbstractResourceManager):%0A    '''%0A    StorageDomain ResourceManager provides StorageDomain construction,%0A    location and manipulation services.%0A    '''%0A%0A    def __init__(self):%0A        super(StorageDomainResourceManager, self).__init__(params.StorageDomain)%0A        self.dataCenterResourceManager = DataCenterResourceManager()%0A%0A    # abstract impl%0A    def get(self, get_only=False, **kwargs):%0A        %22%22%22%0A        Fetches given StorageDomain%0A        %0A        @param get_only: do not create on absence%0A        @param kwargs: list args %0A        %22%22%22%0A        if not kwargs:%0A            kwargs = %7B'name': self.getName()%7D%0A%0A        resource = self.__doGet(**kwargs)%0A        if not resource and not get_only:%0A            if self.isCreateOnDemand():%0A                return self.add()%0A            else:%0A                self.raiseNotFoundError()%0A        return resource%0A%0A    def __doGet(self, **kwargs):%0A        return self.getResourceManager() %5C%0A                   .getSdk() %5C%0A                   .storagedomains %5C%0A                   .get(**kwargs)%0A%0A    # abstract impl%0A    def list(self, **kwargs):%0A        %22%22%22%0A        Lists available storagedomains%0A        %0A        @param kwargs: list args %0A        %22%22%22%0A        return self.getResourceManager() %5C%0A                   .getSdk() %5C%0A                   .storagedomains %5C%0A                   .list(**kwargs)%0A%0A    # abstract impl%0A    @requires.resources(%5Bparams.DataCenter, params.Host%5D)%0A    def add(self, **kwargs):%0A        %22%22%22%0A        Adds new storagedomain%0A        %0A        @param kwargs: keyword args %0A        %22%22%22%0A%0A        storagedomain = self.get(get_only=True)%0A        if not storagedomain:%0A            # create storage domain%0A            self.injectExpectParam(kwargs)%0A            storagedomain = self.getResourceManager() %5C%0A                                .getSdk() %5C%0A                                .storagedomains.add(%0A                                      ResourceFactory.create(%0A                                                 self.getType(),%0A                                                 **kwargs)%0A                                )%0A            if storagedomain:%0A                # attach storage domain%0A                datacenter = self.dataCenterResourceManager.get(storagedomain)%0A                return datacenter.storagedomains.add(**kwargs)%0A            else:%0A                self.raiseNotCreatedError()%0A        return storagedomain%0A%0A    # abstract impl%0A    def update(self, **kwargs):%0A        storagedomain = self.get()%0A        if not storagedomain:%0A            self.raiseNotFoundError()%0A        return storagedomain.update(**kwargs)%0A%0A    # abstract impl%0A    def remove(self, **kwargs):%0A        storagedomain = self.get()%0A        if not storagedomain:%0A            self.raiseNotFoundError()%0A        return storagedomain.delete()%0A

implement storagedomainresourcemanager