Example #1
0
def do_segment_show(service, args):
    """Show a segment details."""
    try:
        segment_id = utils.get_uuid_by_name(service, args.id)
        segment = service.get_segment(segment_id)
        utils.print_dict(segment.to_dict())
    except Exception as e:
        print(e)
Example #2
0
def do_notification_show(service, args):
    """Show a notification details."""
    try:
        notification = service.get_notification(args.id)
        utils.print_dict(notification.to_dict())

    except Exception as e:
        print(e)
Example #3
0
def do_segment_delete(service, args):
    """Delete a segment."""
    try:
        segment_id = utils.get_uuid_by_name(service, args.id)
        segment = service.delete_segment(segment_id, ignore_missing=True)
        utils.print_dict(segment.to_dict())
    except Exception as e:
        print(e)
Example #4
0
def do_host_delete(service, args):
    """Delete a host."""
    try:
        segment_id = utils.get_uuid_by_name(service, args.segment_id)
        host_id = utils.get_uuid_by_name(service, args.id, segment=segment_id)
        host = service.delete_host(host_id, segment_id=segment_id)
        if host:
            utils.print_dict(host.to_dict())
    except Exception as e:
        print(e)
Example #5
0
def do_segment_create(service, args):
    """Create segment."""
    try:
        attrs = {
            'name': args.name,
            'description': args.description,
            'recovery_method': args.recovery_method,
            'service_type': args.service_type,
        }
        segment = service.create_segment(**attrs)
        utils.print_dict(segment.to_dict())
    except Exception as e:
        print(e)
Example #6
0
def do_notification_create(service, args):
    """Create a notification."""
    try:
        payload = jsonutils.loads(args.payload)
        attrs = {
            'type': args.type,
            'hostname': args.hostname,
            'generated_time': args.generated_time,
            'payload': payload,
        }
        notification = service.create_notification(**attrs)
        utils.print_dict(notification.to_dict())

    except Exception as e:
        print(e)
Example #7
0
def do_segment_update(service, args):
    """Update a segment."""
    try:
        segment_id = utils.get_uuid_by_name(service, args.id)
        attrs = {
            'name': args.name,
            'description': args.description,
            'recovery_method': args.recovery_method,
            'service_type': args.service_type,
        }
        attrs = utils.remove_unspecified_items(attrs)
        segment = service.update_segment(segment_id, **attrs)
        utils.print_dict(segment.to_dict())
    except Exception as e:
        print(e)
Example #8
0
def do_host_create(service, args):
    """Create a host."""
    try:
        segment_id = utils.get_uuid_by_name(service, args.segment_id)
        attrs = {
            'name': args.name,
            'type': args.type,
            'control_attributes': args.control_attributes,
            'reserved': args.reserved,
            'on_maintenance': args.on_maintenance,
        }
        utils.remove_unspecified_items(attrs)
        host = service.create_host(segment_id, **attrs)
        utils.print_dict(host.to_dict())
    except Exception as e:
        print(e)