~rvb/maas/ephemeral-simplestreams

« back to all changes in this revision

Viewing changes to maastest/maasfixture.py

  • Committer: MaaS Lander
  • Author(s): Julian Edwards
  • Date: 2014-02-19 00:46:30 UTC
  • mfrom: (129.2.4 rename-maas)
  • Revision ID: maas_lander-20140219004630-vnljydvnzemtrtdq
[r=rvb][bug=][author=julian-edwards] Update maas-test to work with the renamed maas-region-admin in trunk for Trusty.

Show diffs side-by-side

added added

removed removed

Lines of Context:
94
94
        self.series = series
95
95
        self.architecture = architecture
96
96
        self.installed = False
 
97
        self._maas_admin = None
97
98
 
98
99
    def install_maas(self):
99
100
        """Install and configure MAAS in the virtual machine.
123
124
            ['apt-cache', 'policy', 'maas'], check_call=True)
124
125
        return utils.extract_package_version(policy)
125
126
 
 
127
    @property
 
128
    def maas_admin(self):
 
129
        """Return the correct maas admin command.
 
130
 
 
131
        If maas-region-admin is available, use it (on trusty or later),
 
132
        otherwise fall back to the old 'maas' command.
 
133
        """
 
134
        if self._maas_admin is None:
 
135
            retcode, _, _ = self.kvm_fixture.run_command(
 
136
                ['which', 'maas-region-admin'])
 
137
            if retcode == 0:
 
138
                self._maas_admin = 'maas-region-admin'
 
139
            else:
 
140
                self._maas_admin = 'maas'
 
141
        else:
 
142
            return self._maas_admin
 
143
 
126
144
    def configure_default_maas_url(self):
127
145
        """Set `DEFAULT_MAAS_URL` in the virtual machine.
128
146
 
153
171
        """Return the API key for the given MAAS user."""
154
172
        # The "apikey" command prints the user's API key to stdout.
155
173
        return_code, stdout, stderr = self.kvm_fixture.run_command([
156
 
            'sudo', 'maas', 'apikey',
 
174
            'sudo', self.maas_admin, 'apikey',
157
175
            '--username=%s' % username,
158
176
            ], check_call=True)
159
177
        return stdout.strip()
173
191
        email = 'root@localhost.local'
174
192
 
175
193
        return_code, _, stderr = self.kvm_fixture.run_command([
176
 
            'sudo', 'maas', 'createadmin',
 
194
            'sudo', self.maas_admin, 'createadmin',
177
195
            '--username=%s' % username,
178
196
            '--password=%s' % password,
179
197
            '--email=%s' % email,
189
207
        up.
190
208
        """
191
209
        return_code, stdout, _ = self.kvm_fixture.run_command([
192
 
            'sudo', 'maas', 'dumpdata', 'metadataserver.NodeCommissionResult'
 
210
            'sudo', self.maas_admin, 'dumpdata',
 
211
            'metadataserver.NodeCommissionResult'
193
212
            ])
194
213
 
195
214
    def import_maas_images(self, series, architecture):