def update(openstack_resource, args):
    """
    Update openstack router by passing args dict that contains the info that
    need to be updated
    :param openstack_resource: instance of openstack router resource
    :param args: dict of information need to be updated
    """
    args = reset_dict_empty_keys(args)
    openstack_resource.update(args)
def update(openstack_resource, args):
    """
    Update openstack floating ip by passing args dict that contains the info
    that need to be updated
    :param openstack_resource: instance of openstack floating ip resource
    :param args: dict of information need to be updated
    """
    # At some case like remove ip from port, openstack API refuse to to set
    # port_id to '' empty string in order to delete the port, it should be
    # set to None in order to set it, so it is required to change '' to None
    new_config = reset_dict_empty_keys(args)
    openstack_resource.update(new_config)
Esempio n. 3
0
def update(openstack_resource, args):
    """
    Update openstack host aggregate by passing args dict that contains
    the info that need to be updated
    :param openstack_resource: Instance of openstack host aggregate resource
    :param dict args: dict of information need to be updated
    """
    args = reset_dict_empty_keys(args)
    if not args:
        raise NonRecoverableError(
            'Unable to update aggregate {0}, '
            'args cannot be empty'.format(openstack_resource.resource_id))

    # Check if metadata is exist so that we can update it if needed
    if 'metadata' in args:
        metadata = args.pop('metadata')
        openstack_resource.set_metadata(metadata)

    # Update only if args has value like (name | availability_zone)
    if args:
        openstack_resource.update(args)