Esempio n. 1
0
 def test_glancing_metadata_bad_but_force(self):
     # Size & checksum mismatch: 375 MB -> 492 MB
     market_id = 'ME4iRTemHRwhABKV5AgrkQfDerA'
     mdfile = get_local_path('..', 'stratuslab', market_id + '.json')
     self.assertTrue(glancing.main(['-vf', '-n', test_name(), mdfile]))
     self.assertTrue(glance.glance_delete(test_name()))
     self.assertFalse(glancing.main(['-vf', '-n', test_name(), market_id]))
Esempio n. 2
0
 def test_glancing_metadata_bad_but_force(self):
     # Size & checksum mismatch: 375 MB -> 492 MB
     market_id = 'ME4iRTemHRwhABKV5AgrkQfDerA'
     mdfile = get_local_path('..', 'stratuslab', market_id + '.json')
     self.assertTrue(glancing.main(['-vf', '-n', test_name(), mdfile]))
     self.assertTrue(glance.glance_delete(test_name()))
     self.assertFalse(glancing.main(['-vf', '-n', test_name(), market_id]))
Esempio n. 3
0
 def test_glancing_file_dryrun_good_sum(self):
     self.assertTrue(
         glancing.main([
             '-d', '-n',
             test_name(), self._CIRROS_FILE, '-S', self._CIRROS_MD5
         ]))
     self.assertTrue(
         glancing.main([
             '-d', '-n',
             test_name(), self._CIRROS_FILE, '-S', self._CIRROS_SHA1
         ]))
     self.assertTrue(
         glancing.main([
             '-d', '-n',
             test_name(), self._CIRROS_FILE, '-S', self._CIRROS_SHA1, '-S',
             self._CIRROS_MD5
         ]))
     self.assertTrue(
         glancing.main([
             '-d', '-n',
             test_name(), self._CIRROS_FILE, '-S', self._CIRROS_MD5, '-s',
             self._CIRROS_CHK
         ]))
     self.assertTrue(
         glancing.main([
             '-d', '-n',
             test_name(), self._CIRROS_FILE, '-s', self._CIRROS_CHK, '-S',
             self._CIRROS_SHA1
         ]))
Esempio n. 4
0
    def test_glancing_image_ttylinux(self):

        md5 = self._TTYLINUX_MD5
        sha1 = '1b5229d5dad92bc7952553be01608af2180eafbe'
        sha512 = ('79556bc3a25e4555a6cd71afba8eae80eb6d5f23f16a84e6' +
                  '017a54469034cf77ee7bcd74ac285c6ec42c25547b6963c1' +
                  'e7232d4fcca388a326f0ec3e7afb838e')

        self.assertTrue(glancing.main(['-d', self._TTYLINUX_FILE]))

        checksums_true = [
            '', ':', ':::::', sha512, sha1 + ':' + md5, md5 + ':', ':' + md5
        ]

        for chks in checksums_true:
            self.assertTrue(
                glancing.main(['-d', self._TTYLINUX_FILE, '-s', chks]), chks)

        checksums_false = [
            'a' + md5, 'a' + md5 + ':' + md5, md5[:12] + '0' + md5[13:],
            md5 + ':' + md5[:12] + '0' + md5[13:]
        ]

        for chks in checksums_false:
            self.assertFalse(
                glancing.main(['-d', self._TTYLINUX_FILE, '-s', chks]), chks)
Esempio n. 5
0
 def test_glancing_file_dryrun_good_sum(self):
     self.assertTrue(glancing.main(['-d', '-n', test_name(),
         self._CIRROS_FILE, '-S', self._CIRROS_MD5]))
     self.assertTrue(glancing.main(['-d', '-n', test_name(),
         self._CIRROS_FILE, '-S', self._CIRROS_SHA1]))
     self.assertTrue(glancing.main(['-d', '-n', test_name(),
         self._CIRROS_FILE, '-S', self._CIRROS_SHA1, '-S', self._CIRROS_MD5]))
     self.assertTrue(glancing.main(['-d', '-n', test_name(),
         self._CIRROS_FILE, '-S', self._CIRROS_MD5, '-s', self._CIRROS_CHK]))
     self.assertTrue(glancing.main(['-d', '-n', test_name(),
         self._CIRROS_FILE, '-s', self._CIRROS_CHK, '-S', self._CIRROS_SHA1]))
Esempio n. 6
0
 def test_glancing_metadata_cirros_import_no_cksum(self):
     # 12 MB
     mdfile = get_local_path('..', 'stratuslab', 'cirros_no_cksum.json')
     with devnull('stderr'):
         self.assertTrue(
             glancing.main(['-v', '-n',
                            test_name(), mdfile, '-k']))
Esempio n. 7
0
 def test_glancing_image_devnull_sum_bad(self):
     sums = [
         '### BAD CHECKSUM ###', '0' * 32,
         self._DEVNULL_MD5 + ':' + '0' * 32
     ]
     for asum in sums:
         self.assertFalse(glancing.main(['-d', os.devnull, '-s', asum]))
Esempio n. 8
0
 def test_glancing_image_coreos(self):
     fn = 'coreos_production_qemu_image.img'
     imgfile = get_local_path('..', 'images', fn)
     chksumfile = get_local_path('..', 'images', 'coreos-MD5SUMS')
     with open(chksumfile, 'rb') as fin:
         md5 = fin.read(multihash.hash2len('md5'))
     self.assertTrue(glancing.main(['-v', '-d', imgfile, '-s',
         md5 + ':' + md5]))
Esempio n. 9
0
 def test_glancing_image_coreos(self):
     fn = 'coreos_production_qemu_image.img'
     imgfile = get_local_path('..', 'images', fn)
     chksumfile = get_local_path('..', 'images', 'coreos-MD5SUMS')
     with open(chksumfile, 'rb') as fin:
         md5 = fin.read(multihash.hash2len('md5'))
     self.assertTrue(
         glancing.main(['-v', '-d', imgfile, '-s', md5 + ':' + md5]))
Esempio n. 10
0
 def test_glancing_metadata_cern_cirros_import(self):
     # 12 MB
     mdfile = get_local_path('..', 'CERN', 'test_image_list')
     self.assertTrue(
         glancing.main([
             '-v', '-n',
             test_name(), '-c', mdfile, '-k',
             "deadbabe-f00d-beef-cafe-b1ab1ab1a666"
         ]))
Esempio n. 11
0
def upload_image(mpid, name, meta_file):
    '''Upload new image into glance registry, using metadata file content
    '''
    vprint("Uploading new image: %s (%s)" % (mpid, name))
    ret = glancing.main(['-v', '-n', name, meta_file])
    # Invalidate glance image cache
    # TODO: maybe just add the new one
    global _GLANCE_IMAGES
    _GLANCE_IMAGES = None
    return ret
Esempio n. 12
0
def upload_image(mpid, name, meta_file):
    '''Upload new image into glance registry, using metadata file content
    '''
    vprint("Uploading new image: %s (%s)" % (mpid, name))
    ret = glancing.main(['-v', '-n', name, meta_file])
    # Invalidate glance image cache
    # TODO: maybe just add the new one
    global _GLANCE_IMAGES
    _GLANCE_IMAGES = None
    return ret
Esempio n. 13
0
 def test_glancing_metadata_heavies(self):
     market_ids = (
         # 98 MB, size & checksum mismatch: 4 B -> 98 MB
         ('JcqGhHxmTRAEpHMmRF-xhSTM3TO', False, False, False),
         # 102 MB, does not exists any more on SL marketplace
         ('BtSKdXa2SvHlSVTvgFgivIYDq--', True, False, False),
         # 872 MB
         ('IzEOzeHK8-zpgSyAkhNiZujL4nZ', True, True, True),
         # Size & checksum mismatch: 375 MB -> 492 MB
         ('ME4iRTemHRwhABKV5AgrkQfDerA', False, False, False),
     )
     for market_id, status_json, status_xml, status_market in market_ids:
         mdfile_base = get_local_path('..', 'stratuslab', market_id)
         self.assertEqual(status_json, glancing.main(['-d',
             mdfile_base + '.json']), mdfile_base + '.json')
         self.assertEqual(status_xml, glancing.main(['-d',
             mdfile_base + '.xml']), mdfile_base + '.xml')
         self.assertEqual(status_market, glancing.main(['-d',
             market_id]), market_id)
Esempio n. 14
0
 def test_glancing_metadata_heavies(self):
     market_ids = (
         # 98 MB, size & checksum mismatch: 4 B -> 98 MB
         ('JcqGhHxmTRAEpHMmRF-xhSTM3TO', False, False, False),
         # 102 MB, does not exists any more on SL marketplace
         ('BtSKdXa2SvHlSVTvgFgivIYDq--', True, False, False),
         # 872 MB
         ('IzEOzeHK8-zpgSyAkhNiZujL4nZ', True, True, True),
         # Size & checksum mismatch: 375 MB -> 492 MB
         ('ME4iRTemHRwhABKV5AgrkQfDerA', False, False, False),
     )
     for market_id, status_json, status_xml, status_market in market_ids:
         mdfile_base = get_local_path('..', 'stratuslab', market_id)
         self.assertEqual(status_json,
                          glancing.main(['-d', mdfile_base + '.json']),
                          mdfile_base + '.json')
         self.assertEqual(status_xml,
                          glancing.main(['-d', mdfile_base + '.xml']),
                          mdfile_base + '.xml')
         self.assertEqual(status_market, glancing.main(['-d', market_id]),
                          market_id)
Esempio n. 15
0
    def test_glancing_image_ttylinux(self):

        md5 = self._TTYLINUX_MD5
        sha1 = '1b5229d5dad92bc7952553be01608af2180eafbe'
        sha512 = ('79556bc3a25e4555a6cd71afba8eae80eb6d5f23f16a84e6' +
                  '017a54469034cf77ee7bcd74ac285c6ec42c25547b6963c1' +
                  'e7232d4fcca388a326f0ec3e7afb838e')

        self.assertTrue(glancing.main(['-d', self._TTYLINUX_FILE]))

        checksums_true = ['', ':', ':::::', sha512, sha1 + ':' + md5,
            md5 + ':', ':' + md5]

        for chks in checksums_true:
            self.assertTrue(glancing.main(['-d',
                self._TTYLINUX_FILE, '-s', chks]), chks)

        checksums_false = ['a' + md5, 'a' + md5 + ':' + md5, md5[:12] +
            '0' + md5[13:], md5 + ':' + md5[:12] + '0' + md5[13:]]

        for chks in checksums_false:
            self.assertFalse(glancing.main(['-d',
                self._TTYLINUX_FILE, '-s', chks]), chks)
Esempio n. 16
0
 def test_glancing_url_notexistent(self):
     url = 'http://nulle.part.fr/nonexistent_file.txt'
     self.assertFalse(glancing.main(['-d', url]))
Esempio n. 17
0
 def test_glancing_url_md5(self):
     self.assertTrue(glancing.main(['-d', self._CIRROS_URL,
                                    '-s', self._CIRROS_MD5]))
     self.assertTrue(glancing.main(['-d', self._CIRROS_URL,
                                    '-S', self._CIRROS_SUM]))
Esempio n. 18
0
 def test_glancing_metadata_cirros_import_no_cksum(self):
     # 12 MB
     mdfile = get_local_path('..', 'stratuslab', 'cirros_no_cksum.json')
     with devnull('stderr'):
         self.assertTrue(glancing.main(['-v', '-n', test_name(),
             mdfile, '-k']))
Esempio n. 19
0
 def test_glancing_metadata_big(self):
     market_id = 'PIDt94ySjKEHKKvWrYijsZtclxU'
     mdfile = get_local_path('..', 'stratuslab', market_id + '.json')
     self.assertTrue(glancing.main(['-d', mdfile]))
     self.assertTrue(glancing.main(['-d', market_id]))
Esempio n. 20
0
 def test_glancing_image_devnull_sum_bad(self):
     sums = ['### BAD CHECKSUM ###', '0' * 32, self._DEVNULL_MD5 +
         ':' + '0' * 32]
     for asum in sums:
         self.assertFalse(glancing.main(['-d', os.devnull, '-s', asum]))
Esempio n. 21
0
 def test_glancing_url_notexistent(self):
     url = 'http://nulle.part.fr/nonexistent_file.txt'
     self.assertFalse(glancing.main(['-d', url]))
Esempio n. 22
0
 def test_glancing_main_glance_availabilityFail(self):
     with environ('PATH'):
         self.assertFalse(glancing.main([os.devnull]))
Esempio n. 23
0
 def test_glancing_url_import_good_sum(self):
     self.assertTrue(glancing.main(['-n', test_name(),
         self._CIRROS_URL, '-S', self._CIRROS_SUM]))
Esempio n. 24
0
 def test_glancing_url_import_good_md5(self):
     self.assertTrue(
         glancing.main(
             ['-n',
              test_name(), self._CIRROS_URL, '-s', self._CIRROS_MD5]))
Esempio n. 25
0
 def test_glancing_url_import_good_sum(self):
     self.assertTrue(
         glancing.main(
             ['-n',
              test_name(), self._CIRROS_URL, '-S', self._CIRROS_SUM]))
Esempio n. 26
0
 def test_glancing_url_import_no_md5(self):
     self.assertTrue(glancing.main(['-n', test_name(), self._CIRROS_URL]))
Esempio n. 27
0
 def test_glancing_url_import_bad_md5_but_force(self):
     self.assertTrue(
         glancing.main(
             ['-f', '-n',
              test_name(), self._CIRROS_URL, '-s', '0' * 32]))
Esempio n. 28
0
 def test_glancing_url_import_bad_md5(self):
     self.assertFalse(
         glancing.main(
             ['-n', test_name(), self._CIRROS_URL, '-s', '0' * 32]))
Esempio n. 29
0
 def test_glancing_url_import_bad_md5(self):
     self.assertFalse(glancing.main(['-n', test_name(),
         self._CIRROS_URL, '-s', '0' * 32]))
Esempio n. 30
0
 def test_glancing_main_glance_availabilityOK(self):
     self.assertTrue(glancing.main([os.devnull]))
Esempio n. 31
0
 def test_glancing_url_import_no_md5(self):
     self.assertTrue(glancing.main(['-n', test_name(),
         self._CIRROS_URL]))
Esempio n. 32
0
 def test_glancing_empty_cli_param(self):
     self.assertFalse(glancing.main(['']))
     self.assertFalse(glancing.main(['-d', '']))
Esempio n. 33
0
 def test_glancing_url_import_no_name(self):
     name, _ = os.path.splitext(os.path.basename(self._CIRROS_URL))
     with cleanup(glance.glance_delete, name):
         self.assertTrue(glancing.main([self._CIRROS_URL]))
Esempio n. 34
0
 def test_glancing_image_notexistent(self):
     self.assertFalse(glancing.main(['-d', '/notexistent.txt']))
Esempio n. 35
0
 def test_glancing_url_notenough_param(self):
     with devnull('stderr'):
         with self.assertRaises(SystemExit):
             url = 'http://nulle.part.fr/nonexistent_file.txt'
             glancing.main(['-d', url, '-s'])
Esempio n. 36
0
 def test_glancing_image_notexistent_sum(self):
     self.assertFalse(
         glancing.main(['-d', '/notexistent.txt', '-s', '0' * 32]))
Esempio n. 37
0
 def test_glancing_image_import_name_bad_md5(self):
     self.assertFalse(
         glancing.main(
             ['-n', test_name(), self._TTYLINUX_FILE, '-s', '0' * 32]))
Esempio n. 38
0
 def test_glancing_image_devnull(self):
     self.assertTrue(glancing.main(['-d', os.devnull]))
Esempio n. 39
0
 def test_glancing_metadata_cirros_import_bad_size(self):
     # 12 MB
     mdfile = get_local_path('..', 'stratuslab', 'cirros_bad_size.json')
     with devnull('stderr'):
         self.assertFalse(glancing.main(['-v', '-n', test_name(), mdfile]))
         self.assertTrue(glancing.main(['-f', '-n', test_name(), mdfile]))
Esempio n. 40
0
 def test_glancing_image_notenough_param(self):
     with devnull('stderr'):
         with self.assertRaises(SystemExit):
             glancing.main(['-d', os.devnull, '-s'])
Esempio n. 41
0
 def test_glancing_url_notenough_param(self):
     with devnull('stderr'):
         with self.assertRaises(SystemExit):
             url = 'http://nulle.part.fr/nonexistent_file.txt'
             glancing.main(['-d', url, '-s'])
Esempio n. 42
0
 def test_glancing_url(self):
     self.assertTrue(glancing.main(['-d', self._CIRROS_URL]))
Esempio n. 43
0
 def test_glancing_url(self):
     self.assertTrue(glancing.main(['-d', self._CIRROS_URL]))
Esempio n. 44
0
 def test_glancing_metadata_cirros_import_bad_size(self):
     # 12 MB
     mdfile = get_local_path('..', 'stratuslab', 'cirros_bad_size.json')
     with devnull('stderr'):
         self.assertFalse(glancing.main(['-v', '-n', test_name(), mdfile]))
         self.assertTrue(glancing.main(['-f', '-n', test_name(), mdfile]))
Esempio n. 45
0
 def test_glancing_url_import_no_name(self):
     name, _ = os.path.splitext(os.path.basename(self._CIRROS_URL))
     with cleanup(glance.glance_delete, name):
         self.assertTrue(glancing.main([self._CIRROS_URL]))
Esempio n. 46
0
 def test_glancing_main_glance_availabilityOK(self):
     self.assertTrue(glancing.main([os.devnull]))
Esempio n. 47
0
 def test_glancing_url_import_bad_md5_but_force(self):
     self.assertTrue(glancing.main(['-f', '-n', test_name(),
         self._CIRROS_URL, '-s', '0' * 32]))
Esempio n. 48
0
 def test_glancing_image_notexistent(self):
     self.assertFalse(glancing.main(['-d', '/notexistent.txt']))
Esempio n. 49
0
 def test_glancing_url_import_good_md5(self):
     self.assertTrue(glancing.main(['-n', test_name(),
         self._CIRROS_URL, '-s', self._CIRROS_MD5]))
Esempio n. 50
0
 def test_glancing_image_devnull(self):
     self.assertTrue(glancing.main(['-d', os.devnull]))
Esempio n. 51
0
 def test_glancing_main_glance_availabilityFail(self):
     with environ('PATH'):
         self.assertFalse(glancing.main([os.devnull]))
Esempio n. 52
0
 def test_glancing_url_md5(self):
     self.assertTrue(
         glancing.main(['-d', self._CIRROS_URL, '-s', self._CIRROS_MD5]))
     self.assertTrue(
         glancing.main(['-d', self._CIRROS_URL, '-S', self._CIRROS_SUM]))
Esempio n. 53
0
 def test_glancing_empty_cli_param(self):
     self.assertFalse(glancing.main(['']))
     self.assertFalse(glancing.main(['-d', '']))
Esempio n. 54
0
 def test_glancing_image_import_name_force(self):
     self.assertTrue(
         glancing.main(
             ['-f', '-n',
              test_name(), self._TTYLINUX_FILE, '-s', '0' * 32]))
Esempio n. 55
0
 def test_glancing_image_notexistent_sum(self):
     self.assertFalse(glancing.main(['-d', '/notexistent.txt',
         '-s', '0' * 32]))
Esempio n. 56
0
 def test_glancing_image_import_name_bad_md5(self):
     self.assertFalse(glancing.main(['-n', test_name(),
         self._TTYLINUX_FILE, '-s', '0' * 32]))
Esempio n. 57
0
 def test_glancing_image_notenough_param(self):
     with devnull('stderr'):
         with self.assertRaises(SystemExit):
             glancing.main(['-d', os.devnull, '-s'])
Esempio n. 58
0
 def test_glancing_image_import_name_force(self):
     self.assertTrue(glancing.main(['-f', '-n', test_name(),
         self._TTYLINUX_FILE, '-s', '0' * 32]))
Esempio n. 59
0
 def test_glancing_metadata_cern_cirros_import(self):
     # 12 MB
     mdfile = get_local_path('..', 'CERN', 'test_image_list')
     self.assertTrue(glancing.main(['-v', '-n', test_name(), '-c',
         mdfile, '-k', "deadbabe-f00d-beef-cafe-b1ab1ab1a666"]))
Esempio n. 60
0
 def test_glancing_metadata_big(self):
     market_id = 'PIDt94ySjKEHKKvWrYijsZtclxU'
     mdfile = get_local_path('..', 'stratuslab', market_id + '.json')
     self.assertTrue(glancing.main(['-d', mdfile]))
     self.assertTrue(glancing.main(['-d', market_id]))