56
54
return ubuntu_names.get(raw_arch, raw_arch)
57
# TODO: Move to utils or kvmfixture.
59
58
def determine_vm_series():
60
59
"""Figure out the Ubuntu release series to run MAAS on.
67
# Standard, non-interactive, "apt-get install" line.
69
'sudo', 'DEBIAN_FRONTEND=noninteractive',
70
'apt-get', 'install', '-y',
74
def install_packages(kvm_fixture, packages):
75
"""Install the given packages on the virtual machine."""
76
kvm_fixture.run_command(APT_GET_INSTALL + list(packages), check_call=True)
79
def install_maas(kvm_fixture):
80
"""Install and configure MAAS in the virtual machine."""
81
# Install the English language pack first. If this is not done before
82
# postgres is installed, on some systems it won't be able to set up its
84
# TODO: Is there no better way to ensure this, e.g. through a dependency?
85
install_packages(kvm_fixture, ['language-pack-en'])
86
# Now we can install maas (which also installs postgres).
87
install_packages(kvm_fixture, ['maas', 'maas-dhcp', 'maas-dns'])
68
90
def query_api_key(kvm_fixture, username):
69
91
"""Return the API key for the given MAAS user."""
70
92
# The "apikey" command prints the user's API key to stdout.
111
133
# TODO: Actually implement.
114
def configure_maas(kvm_fixture):
115
"""Configure the MAAS running inside the virtual machine.
117
MAAS must already have been installed. This function creates an admin user
118
and imports boot images.
136
def set_up_maas(kvm_fixture):
137
"""Install and configure MAAS inside the virtual machine.
120
139
:param kvm_fixture: `KVMFixture` that controls the virtual machine.
121
140
:return: Username and API key for the MAAS admin user.
142
install_maas(kvm_fixture)
123
143
admin_user, password = create_maas_admin(kvm_fixture)
124
144
api_key = query_api_key(kvm_fixture, admin_user)
125
145
import_maas_images(kvm_fixture, admin_user, api_key)
146
return admin_user, api_key