Ejemplo n.º 1
0
def create(caller_id, name, address, directory, capacity):
    """
    Registers new Storage.

    @cmview_admin_cm
    @param_post{name,string} libvirt's pool name
    @param_post{address,string} storage ip address or hostname
    @param_post{directory,string} directory on storage
    @param_post{capacity,int} maximum storage capacity [MB]

    @raises{storage_already_exist,CMException}
    @raises{storage_create,CMException}
    """

    #error if already exists a storage with the same name
    if Storage.objects.filter(name__exact=name).exists():
        raise CMException('storage_already_exist')

    try:
        st = Storage()
        st.name = name
        st.address = address
        st.dir = directory
        st.capacity = capacity
        st.state = storage_states['ok']

    except Exception, e:
        log.debug(caller_id,
                  'Cannot register storage - missing element: %s' % str(e))
        raise CMException('storage_create')
Ejemplo n.º 2
0
def create(caller_id, name, address, directory, capacity):
    """
    Registers new Storage.

    @cmview_admin_cm
    @param_post{name,string} libvirt's pool name
    @param_post{address,string} storage ip address or hostname
    @param_post{directory,string} directory on storage
    @param_post{capacity,int} maximum storage capacity [MB]

    @raises{storage_already_exist,CMException}
    @raises{storage_create,CMException}
    """

    #error if already exists a storage with the same name
    if Storage.objects.filter(name__exact=name).exists():
        raise CMException('storage_already_exist')

    try:
        st = Storage()
        st.name = name
        st.address = address
        st.dir = directory
        st.capacity = capacity
        st.state = storage_states['ok']

    except Exception, e:
        log.debug(caller_id, 'Cannot register storage - missing element: %s' % str(e))
        raise CMException('storage_create')