v0.1.0-dev4
This commit is contained in:
		@@ -55,7 +55,7 @@ def init(session: Session, args: argparse.Namespace) -> None:
 | 
			
		||||
    capabilities = session.get_capabilities()
 | 
			
		||||
    node_info = session.get_node_info()
 | 
			
		||||
    base_instance_config = {
 | 
			
		||||
        'name': str(uuid.uuid4()),
 | 
			
		||||
        'name': str(uuid.uuid4()).split('-')[0],
 | 
			
		||||
        'title': None,
 | 
			
		||||
        'description': None,
 | 
			
		||||
        'arch': capabilities.arch,
 | 
			
		||||
@@ -70,16 +70,28 @@ def init(session: Session, args: argparse.Namespace) -> None:
 | 
			
		||||
            'topology': None,
 | 
			
		||||
            'features': None,
 | 
			
		||||
        },
 | 
			
		||||
        'network_interfaces': [
 | 
			
		||||
            {
 | 
			
		||||
                'source': 'default',
 | 
			
		||||
                'mac': ids.random_mac(),
 | 
			
		||||
            },
 | 
			
		||||
        ],
 | 
			
		||||
        'boot': {'order': ['cdrom', 'hd']},
 | 
			
		||||
        'cloud_init': None,
 | 
			
		||||
    }
 | 
			
		||||
    data = dictutil.override(base_instance_config, data)
 | 
			
		||||
    net_default_interface = {
 | 
			
		||||
        'model': 'virtio',
 | 
			
		||||
        'source': 'default',
 | 
			
		||||
        'mac': ids.random_mac(),
 | 
			
		||||
    }
 | 
			
		||||
    net_config = data.get('network', 'DEFAULT')
 | 
			
		||||
    if net_config == 'DEFAULT' or net_config is True:
 | 
			
		||||
        data['network'] = {'interfaces': [net_default_interface]}
 | 
			
		||||
    elif net_config is None or net_config is False:
 | 
			
		||||
        pass  # allow creating instance without network interfaces
 | 
			
		||||
    else:
 | 
			
		||||
        interfaces = data['network'].get('interfaces')
 | 
			
		||||
        if interfaces:
 | 
			
		||||
            interfaces_configs = [
 | 
			
		||||
                dictutil.override(net_default_interface, interface)
 | 
			
		||||
                for interface in interfaces
 | 
			
		||||
            ]
 | 
			
		||||
            data['network']['interfaces'] = interfaces_configs
 | 
			
		||||
    volumes = []
 | 
			
		||||
    targets = []
 | 
			
		||||
    for volume in data['volumes']:
 | 
			
		||||
@@ -246,8 +258,8 @@ def shutdown(session: Session, args: argparse.Namespace) -> None:
 | 
			
		||||
        method = 'SOFT'
 | 
			
		||||
    elif args.hard:
 | 
			
		||||
        method = 'HARD'
 | 
			
		||||
    elif args.unsafe:
 | 
			
		||||
        method = 'UNSAFE'
 | 
			
		||||
    elif args.destroy:
 | 
			
		||||
        method = 'DESTROY'
 | 
			
		||||
    else:
 | 
			
		||||
        method = 'NORMAL'
 | 
			
		||||
    instance.shutdown(method)
 | 
			
		||||
 
 | 
			
		||||
@@ -226,7 +226,7 @@ def get_parser() -> argparse.ArgumentParser:
 | 
			
		||||
        '-s',
 | 
			
		||||
        '--soft',
 | 
			
		||||
        action='store_true',
 | 
			
		||||
        help='normal guest OS shutdown, guest agent is used',
 | 
			
		||||
        help='guest OS shutdown using guest agent',
 | 
			
		||||
    )
 | 
			
		||||
    shutdown_opts.add_argument(
 | 
			
		||||
        '-n',
 | 
			
		||||
@@ -244,12 +244,12 @@ def get_parser() -> argparse.ArgumentParser:
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
    shutdown_opts.add_argument(
 | 
			
		||||
        '-u',
 | 
			
		||||
        '--unsafe',
 | 
			
		||||
        '-d',
 | 
			
		||||
        '--destroy',
 | 
			
		||||
        action='store_true',
 | 
			
		||||
        help=(
 | 
			
		||||
            'destroy instance, this is similar to a power outage '
 | 
			
		||||
            'and may result in data loss or corruption'
 | 
			
		||||
            'and may result in data corruption'
 | 
			
		||||
        ),
 | 
			
		||||
    )
 | 
			
		||||
    shutdown.set_defaults(func=commands.shutdown)
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user