def vmedia_mount_create(handle, volume_name, remote_share, remote_file,
                        map="www", mount_options="noauto", username="",
                        password="", server_id=1, timeout=60):
    """
    This method will setup the vmedia mapping
    Args:
        handle (ImcHandle)
        volume_name (string): Name of the volume or identity of the image
        map (string): "cifs", "nfs", "www"
        mount_options (string): Options to be passed while mounting the image
        remote_share (string): URI of the image
        remote_file (string): name of the image
        username (string): username
        password (string): password
        server_id (int): Server Id to be specified for C3260 platforms
    Returns:
        CommVMediaMap object
    Examples:
        vmedia_mount_add(
            handle,
            volume_name="c",
            map="www",
            mount_options="noauto", "nolock" etc.
            remote_share="http://1.1.1.1/files",
            remote_file="ubuntu-14.04.2-server-amd64.iso",
            username="******",
            password="******")
    """
    image_type = remote_file.split('.')[-1]
    vmedia_mount_remove_image(handle, image_type)

    mo = CommVMediaMap(parent_mo_or_dn=_get_vmedia_mo_dn(handle, server_id),
                       volume_name=volume_name)
    mo.map = map
    if mount_options:
        mo.mount_options = mount_options
    mo.remote_share = remote_share
    mo.remote_file = remote_file
    mo.username = username
    mo.password = password

    handle.add_mo(mo, modify_present="True")

    wait_time = 0
    interval = 10
    while wait_time < timeout:
        time.sleep(interval)
        mo = handle.query_dn(mo.dn)
        existing_mapping_status = mo.mapping_status
        if existing_mapping_status == "OK":
            return mo
        elif re.match(r"ERROR", existing_mapping_status):
            raise ImcOperationError("vmedia_mount_create",
                                    mo.mapping_status)
        wait_time += interval

    raise ImcOperationError("vmedia_mount_create",
                            "ERROR - Mapped image status stuck at %s" %
                            existing_mapping_status)
Exemple #2
0
def vmedia_mount_add(handle,
                     volume_name,
                     mount_protocol,
                     mount_options=None,
                     remote_share=None,
                     remote_file=None,
                     user_id="",
                     password="",
                     server_id=1):
    """
    This method will setup the vmedia mapping
    Args:
        handle (ImcHandle)
        volume_name (string): Name of the volume or identity of the image
        mount_protocol (string): "cifs", "nfs", "www"
        mount_options (string): Options to be passed while mounting the image
        remote_share (string): URI of the image
        remote_file (string): name of the image
        user_id (string): username
        password (string): password
        server_id (int): Server Id to be specified for C3260 platforms

    Returns:
        CommVMediaMap object

    Examples:
        vmedia_mount_add(
            handle,
            volume_name="c",
            mount_protocol="www",
            mount_options="noauto", "nolock" etc.
            remote_share="http://1.1.1.1/files",
            remote_file="ubuntu-14.04.2-server-amd64.iso",
            user_id="abcd",
            password="******")
    """

    vmediamap_mo = CommVMediaMap(parent_mo_or_dn=_get_vmedia_mo_dn(
        handle, server_id),
                                 volume_name=volume_name)
    vmediamap_mo.map = mount_protocol
    if mount_options:
        vmediamap_mo.mount_options = mount_options
    vmediamap_mo.remote_share = remote_share
    vmediamap_mo.remote_file = remote_file
    vmediamap_mo.username = user_id
    vmediamap_mo.password = password

    handle.add_mo(vmediamap_mo, modify_present="True")
    return vmediamap_mo
Exemple #3
0
def vmedia_mount_add(handle, volume_name, mount_protocol,
                     mount_options=None, remote_share=None,
                     remote_file=None, user_id="", password="", server_id=1):
    """
    This method will setup the vmedia mapping
    Args:
        handle (ImcHandle)
        volume_name (string): Name of the volume or identity of the image
        mount_protocol (string): "cifs", "nfs", "www"
        mount_options (string): Options to be passed while mounting the image
        remote_share (string): URI of the image
        remote_file (string): name of the image
        user_id (string): username
        password (string): password
        server_id (int): Server Id to be specified for C3260 platforms

    Returns:
        CommVMediaMap object

    Examples:
        vmedia_mount_add(
            handle,
            volume_name="c",
            mount_protocol="www",
            mount_options="noauto", "nolock" etc.
            remote_share="http://1.1.1.1/files",
            remote_file="ubuntu-14.04.2-server-amd64.iso",
            user_id="abcd",
            password="******")
    """

    vmediamap_mo = CommVMediaMap(
        parent_mo_or_dn=_get_vmedia_mo_dn(handle, server_id),
        volume_name=volume_name)
    vmediamap_mo.map = mount_protocol
    if mount_options:
        vmediamap_mo.mount_options = mount_options
    vmediamap_mo.remote_share = remote_share
    vmediamap_mo.remote_file = remote_file
    vmediamap_mo.username = user_id
    vmediamap_mo.password = password

    handle.add_mo(vmediamap_mo, modify_present="True")
    return vmediamap_mo
Exemple #4
0
def vmedia_mount_create(handle, volume_name, remote_share, remote_file,
                        map="www", mount_options="noauto", username="",
                        password="", server_id=1, timeout=60):
    """
    This method will setup the vmedia mapping
    Args:
        handle (ImcHandle)
        volume_name (string): Name of the volume or identity of the image
        map (string): "cifs", "nfs", "www"
        mount_options (string): Options to be passed while mounting the image
        remote_share (string): URI of the image
        remote_file (string): name of the image
        username (string): username
        password (string): password
        server_id (int): Server Id to be specified for C3260 platforms

    Returns:
        CommVMediaMap object

    Examples:
        vmedia_mount_add(
            handle,
            volume_name="c",
            map="www",
            mount_options="noauto", "nolock" etc.
            remote_share="http://1.1.1.1/files",
            remote_file="ubuntu-14.04.2-server-amd64.iso",
            username="******",
            password="******")
    """
    image_type = remote_file.split('.')[-1]
    vmedia_mount_remove_image(handle, image_type)

    mo = CommVMediaMap(parent_mo_or_dn=_get_vmedia_mo_dn(handle, server_id),
                       volume_name=volume_name)
    mo.map = map
    if mount_options:
        mo.mount_options = mount_options
    mo.remote_share = remote_share
    mo.remote_file = remote_file
    mo.username = username
    mo.password = password

    handle.add_mo(mo, modify_present="True")

    wait_time = 0
    interval = 10
    while wait_time < timeout:
        time.sleep(interval)
        mo = handle.query_dn(mo.dn)
        existing_mapping_status = mo.mapping_status
        if existing_mapping_status == "OK":
            return mo
        elif re.match(r"ERROR", existing_mapping_status):
            raise ImcOperationError("vmedia_mount_create",
                                    mo.mapping_status)
        wait_time += interval

    raise ImcOperationError("vmedia_mount_create",
                            "ERROR - Mapped ISO status stuck at %s" %
                            existing_mapping_status)