Ejemplo n.º 1
0
 def setUp_fake_device(self):
     """
     Fake the install process, to (quickly) make a key and set up the own_device()
     """
     # Could be a fixture, but safer to simply hard-code.
     Settings.set("public_key", u'MIIBCgKCAQEAlbIPLnQH2dORFBK8i9x7/3E0DR571S01aP7M0TJD8vJf8OrgL8pnru3o2Jaoni1XasCZgizvM4GNImk9geqPP/sFkj0cf/MXSLr1VDKo1SoflST9yTbOi7tzVuhTeL4P3LJL6PO6iNiWkjAdqp9QX3mE/DHh/Q40G68meRw6dPDI4z8pyUcshOpxAHTSh2YQ39LJAxP7YS26yjDX/+9UNhetFxemMrBZO0UKtJYggPYRlMZmlTZLBU4ODMmK6MT26fB4DC4ChA3BD4OFiGDHI/iSy+iYJlcWaldbZtc+YfZlGhvsLnJlrp4WYykJSH5qeBuI7nZLWjYWWvMrDepXowIDAQAB')
     Settings.set("private_key", u'-----BEGIN RSA PRIVATE KEY-----\nMIIEqQIBAAKCAQEAlbIPLnQH2dORFBK8i9x7/3E0DR571S01aP7M0TJD8vJf8Org\nL8pnru3o2Jaoni1XasCZgizvM4GNImk9geqPP/sFkj0cf/MXSLr1VDKo1SoflST9\nyTbOi7tzVuhTeL4P3LJL6PO6iNiWkjAdqp9QX3mE/DHh/Q40G68meRw6dPDI4z8p\nyUcshOpxAHTSh2YQ39LJAxP7YS26yjDX/+9UNhetFxemMrBZO0UKtJYggPYRlMZm\nlTZLBU4ODMmK6MT26fB4DC4ChA3BD4OFiGDHI/iSy+iYJlcWaldbZtc+YfZlGhvs\nLnJlrp4WYykJSH5qeBuI7nZLWjYWWvMrDepXowIDAQABAoIBAD8S/a6XGU/BA1ov\n4t4TkvO44TO96nOSTvTkl6x1v4e4dJBwhvHcGP/uIrRQFtA/TpwedxAQmuFa7vrW\n2SHKkX1l6Z0Kvt1yshblH8XQaq8WxqPzKDQGMdVSsHCoB7PScaCOR8nqGGjcyeTi\n/T0NT7JK46vX4N7dgttrE+WixOrtDOUJLX92tGSp8bZgg284fV053nJqYHHROpmZ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SA PRIVATE KEY-----\n')
     Device.initialize_own_device()
Ejemplo n.º 2
0
 def setup_fake_device(cls):
     Device.own_device = None
     Settings.set(
         "public_key",
         u'MIIBCgKCAQEAlbIPLnQH2dORFBK8i9x7/3E0DR571S01aP7M0TJD8vJf8OrgL8pnru3o2Jaoni1XasCZgizvM4GNImk9geqPP/sFkj0cf/MXSLr1VDKo1SoflST9yTbOi7tzVuhTeL4P3LJL6PO6iNiWkjAdqp9QX3mE/DHh/Q40G68meRw6dPDI4z8pyUcshOpxAHTSh2YQ39LJAxP7YS26yjDX/+9UNhetFxemMrBZO0UKtJYggPYRlMZmlTZLBU4ODMmK6MT26fB4DC4ChA3BD4OFiGDHI/iSy+iYJlcWaldbZtc+YfZlGhvsLnJlrp4WYykJSH5qeBuI7nZLWjYWWvMrDepXowIDAQAB'
     )
     Settings.set(
         "private_key",
         u'-----BEGIN RSA PRIVATE KEY-----\nMIIEqQIBAAKCAQEAlbIPLnQH2dORFBK8i9x7/3E0DR571S01aP7M0TJD8vJf8Org\nL8pnru3o2Jaoni1XasCZgizvM4GNImk9geqPP/sFkj0cf/MXSLr1VDKo1SoflST9\nyTbOi7tzVuhTeL4P3LJL6PO6iNiWkjAdqp9QX3mE/DHh/Q40G68meRw6dPDI4z8p\nyUcshOpxAHTSh2YQ39LJAxP7YS26yjDX/+9UNhetFxemMrBZO0UKtJYggPYRlMZm\nlTZLBU4ODMmK6MT26fB4DC4ChA3BD4OFiGDHI/iSy+iYJlcWaldbZtc+YfZlGhvs\nLnJlrp4WYykJSH5qeBuI7nZLWjYWWvMrDepXowIDAQABAoIBAD8S/a6XGU/BA1ov\n4t4TkvO44TO96nOSTvTkl6x1v4e4dJBwhvHcGP/uIrRQFtA/TpwedxAQmuFa7vrW\n2SHKkX1l6Z0Kvt1yshblH8XQaq8WxqPzKDQGMdVSsHCoB7PScaCOR8nqGGjcyeTi\n/T0NT7JK46vX4N7dgttrE+WixOrtDOUJLX92tGSp8bZgg284fV053nJqYHHROpmZ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A PRIVATE KEY-----\n'
     )
     Device.initialize_own_device()
Ejemplo n.º 3
0
    def handle(self, *args, **options):
        if DeviceMetadata.objects.filter(is_own_device=True).count() > 0:
            raise CommandError("Error: This device has already been initialized; aborting.\n")

        name        = args[0] if (len(args) >= 1 and args[0]) else get_host_name()
        description = args[1] if (len(args) >= 2 and args[1]) else ""
        data_file   = args[2] if (len(args) >= 3 and args[2]) else self.data_json_file

        own_device = Device.initialize_own_device(name=name, description=description)
        self.stdout.write("Device '%s'%s has been successfully initialized.\n"
            % (name, description and (" ('%s')" % description) or ""))

        # Nothing to do with a central server
        if settings.CENTRAL_SERVER:
            return

        # Now we're definitely not central server, so ... go for it!
        # Import a zone (for machines sharing zones), and join if it works!
        invitation = None
        if not os.path.exists(data_file):
            sys.stderr.write("Could not find resource file %s.  This may cause warnings to appear when updating your KA Lite version.\n" % data_file)
        else:
            try:
                invitation = load_data_for_offline_install(in_file=data_file)
                self.stdout.write("Successfully imported offline data from %s\n" % data_file)

                # Doesn't hurt to keep data around.
                #if not settings.DEBUG:
                #    os.remove(data_file)
            except Exception as e:
                raise CommandError("Error importing offline data from %s: %s\n" % (data_file, str(e))) 

        confirm_or_generate_zone(invitation)

        initialize_facility(options["facility_name"])
Ejemplo n.º 4
0
 def handle(self, *args, **options):
     if DeviceMetadata.objects.filter(is_own_device=True).count() > 0:
         self.stderr.write("Error: This device has already been initialized; aborting.\n")
         return
     if len(args) >= 1 and args[0]:
         name = args[0]
     else:
         name = get_host_name()
     if len(args) >= 2 and args[1]:
         description = args[1]
     else:
         description = ""
     Device.initialize_own_device(name=name, description=description)
     self.stdout.write("Device '%s'%s has been successfully initialized.\n"
         % (name, description and (" ('%s')" % description) or ""))
     
Ejemplo n.º 5
0
 def handle(self, *args, **options):
     if DeviceMetadata.objects.filter(is_own_device=True).count() > 0:
         self.stderr.write("Error: This device has already been initialized; aborting.\n")
         return
     if len(args) >= 1 and args[0]:
         name = args[0]
     else:
         name = get_host_name()
     if len(args) >= 2 and args[1]:
         description = args[1]
     else:
         description = ""
     Device.initialize_own_device(name=name, description=description, version=version.VERSION)
     self.stdout.write("Device '%s'%s has been successfully initialized.\n"
         % (name, description and (" ('%s')" % description) or ""))
     
Ejemplo n.º 6
0
    def handle(self, *args, **options):
        if DeviceMetadata.objects.filter(is_own_device=True).count() > 0:
            raise CommandError(
                "Error: This device has already been initialized; aborting.\n")

        name = args[0] if (len(args) >= 1 and args[0]) else get_host_name()
        description = args[1] if (len(args) >= 2 and args[1]) else ""
        data_file = args[2] if (len(args) >= 3
                                and args[2]) else self.data_json_file

        own_device = Device.initialize_own_device(name=name,
                                                  description=description)
        self.stdout.write(
            "Device '%s'%s has been successfully initialized.\n" %
            (name, description and (" ('%s')" % description) or ""))

        # Nothing to do with a central server
        if settings.CENTRAL_SERVER:
            return
        elif True:  # for 0.10.3, short-cut to avoid invitation logic.
            return

        # Now we're definitely not central server, so ... go for it!
        # Import a zone (for machines sharing zones), and join if it works!
        invitation = None
        if not os.path.exists(data_file):
            sys.stderr.write(
                "Could not find resource file %s.  This may cause warnings to appear when updating your KA Lite version.\n"
                % data_file)
        else:
            try:
                invitation = load_data_for_offline_install(in_file=data_file)
                self.stdout.write(
                    "Successfully imported offline data from %s\n" % data_file)

                # Doesn't hurt to keep data around.
                #if not settings.DEBUG:
                #    os.remove(data_file)
            except Exception as e:
                raise CommandError(
                    "Error importing offline data from %s: %s\n" %
                    (data_file, e))

        confirm_or_generate_zone(invitation)

        initialize_facility(options["facility_name"])