def __new__(self, table_type, storage_provider): # noqa: C901 host_architecture = platform.machine() if host_architecture == 'x86_64': if table_type == 'gpt': return PartitionerGpt(storage_provider) elif table_type == 'msdos': return PartitionerMsDos(storage_provider) elif host_architecture == 'i686' or host_architecture == 'i586': if table_type == 'msdos': return PartitionerMsDos(storage_provider) elif 'ppc64' in host_architecture: if table_type == 'gpt': return PartitionerGpt(storage_provider) elif table_type == 'msdos': return PartitionerMsDos(storage_provider) elif 's390' in host_architecture: if table_type == 'dasd': return PartitionerDasd(storage_provider) elif table_type == 'msdos': return PartitionerMsDos(storage_provider) elif 'arm' in host_architecture or host_architecture == 'aarch64': if table_type == 'gpt': return PartitionerGpt(storage_provider) elif table_type == 'msdos': return PartitionerMsDos(storage_provider) raise KiwiPartitionerSetupError( 'Support for partitioner on %s architecture not implemented' % host_architecture)
def __new__(self, table_type, storage_provider, start_sector=None): # noqa: C901 host_architecture = platform.machine() if host_architecture == 'x86_64': if table_type == 'gpt': return PartitionerGpt(storage_provider, start_sector) elif table_type == 'msdos': return PartitionerMsDos(storage_provider, start_sector) elif host_architecture == 'i686' or host_architecture == 'i586': if table_type == 'msdos': return PartitionerMsDos(storage_provider, start_sector) elif 'ppc64' in host_architecture: if table_type == 'gpt': return PartitionerGpt(storage_provider, start_sector) elif table_type == 'msdos': return PartitionerMsDos(storage_provider, start_sector) elif 's390' in host_architecture: if table_type == 'dasd': if start_sector: log.warning('disk_start_sector value is ignored ' 'for dasd partitions') return PartitionerDasd(storage_provider) elif table_type == 'msdos': return PartitionerMsDos(storage_provider, start_sector) elif 'arm' in host_architecture or host_architecture == 'aarch64': if table_type == 'gpt': return PartitionerGpt(storage_provider, start_sector) elif table_type == 'msdos': return PartitionerMsDos(storage_provider, start_sector) raise KiwiPartitionerSetupError( 'Support for partitioner on %s architecture not implemented' % host_architecture)
def test_create_custom_start_sector(self, mock_flag, mock_command): disk_provider = Mock() disk_provider.get_device = Mock(return_value='/dev/loop0') partitioner = PartitionerGpt(disk_provider, 4096) partitioner.create('name', 100, 't.linux', ['t.csm']) partitioner.create('name', 100, 't.linux', ['t.csm']) mock_command.assert_has_calls([ call( ['sgdisk', '-n', '1:4096:+100M', '-c', '1:name', '/dev/loop0']), call(['sgdisk', '-n', '2:0:+100M', '-c', '2:name', '/dev/loop0']) ]) assert mock_flag.call_args_list[0] == \ call(1, 't.linux') assert mock_flag.call_args_list[1] == \ call(1, 't.csm')
def setup(self): disk_provider = mock.Mock() disk_provider.get_device = mock.Mock(return_value='/dev/loop0') self.partitioner = PartitionerGpt(disk_provider)