コード例 #1
0
ファイル: PulpRepo.py プロジェクト: yithian/juicer
    def create(self, name, environment, checksumtype='sha256'):
        repo_id = "{0}-{1}".format(name, environment)
        relative_url = "/{0}/{1}/".format(environment, name)
        checksumtype = checksumtype

        pulp = RepositoryAPI(self.connection)
        response = pulp.create_and_configure(
            id=repo_id,
            display_name=name,
            description=repo_id,
            notes={'_repo-type': 'rpm-repo'},
            importer_type_id='yum_importer',
            importer_config={},
            distributors=[{'distributor_id': 'yum_distributor',
                           'distributor_type_id': 'yum_distributor',
                           'distributor_config': {
                               'relative_url': relative_url,
                               'http': True,
                               'https': True,
                               'checksum_type': checksumtype
                           },
                           'auto_publish': True,
                           'relative_path': relative_url
                       }]
        )

        if response.response_code == Constants.PULP_POST_CREATED:
            Log.log_info("%s created in %s", name, environment)
        else:
            Log.log_info("failed to create %s in %s", name, environment)
            Log.log_debug(response)
コード例 #2
0
ファイル: HelloCommand.py プロジェクト: yithian/juicer
    def run(self):
        from pulp.bindings.server_info import ServerInfoAPI

        for environment in self.args.environment:
            hostname = self.config.get(environment)['hostname']
            pulp = ServerInfoAPI(self.connections[environment])
            response = pulp.get_types()
            if response.response_code == Constants.PULP_GET_OK:
                Log.log_info("%s: %s OK", environment, hostname)
            else:
                Log.log_info("%s: %s FAILED", environment, hostname)
コード例 #3
0
ファイル: RepoDeleteCommand.py プロジェクト: yithian/juicer
    def run(self):
        from pulp.bindings.repository import RepositoryAPI

        for environment in self.args.environment:
            repo_id = "{0}-{1}".format(self.args.repo, environment)

            pulp = RepositoryAPI(self.connections[environment])
            response = pulp.delete(repo_id)

            if response.response_code == Constants.PULP_DELETE_ACCEPTED:
                Log.log_info("%s deleted in %s", self.args.repo, environment)
            else:
                Log.log_info("failed to delete %s in %s", self.args.repo, environment)
                Log.log_debug(response)
コード例 #4
0
    def save(self):
        if self.is_empty():
            Log.log_error('Cart is empty, not saving anything')
            return None

        json_body = json.dumps(self._cart_dict())
        if os.path.exists(self.cart_file):
            Log.log_warn(
                "Cart file '%s' already exists, overwriting with new data." %
                self.cart_file)
        f = open(self.cart_file, 'w')
        f.write(json_body)
        f.flush()
        f.close()
        Log.log_info("Saved cart '%s'." % self.name)
コード例 #5
0
    def run(self):
        from pulp.bindings.repository import RepositoryActionsAPI

        for environment in self.args.environment:
            repo_id = "{0}-{1}".format(self.args.repo, environment)
            display_name = self.args.repo

            pulp = RepositoryActionsAPI(self.connections[environment])
            response = pulp.publish(repo_id, 'yum_distributor', {})

            if response.response_code == Constants.PULP_POST_ACCEPTED:
                Log.log_info("%s published in %s", display_name, environment)
            else:
                Log.log_info("failed to publish %s in %s", display_name,
                             environment)
                Log.log_debug(response)
コード例 #6
0
ファイル: RepoCreateCommand.py プロジェクト: tbielawa/juicer
    def run(self):
        from pulp.bindings.repository import RepositoryAPI
        from pulp.bindings.repository import RepositoryActionsAPI

        for environment in self.args.environment:
            repo_id = "{0}-{1}".format(self.args.repo, environment)
            display_name = self.args.repo
            relative_url = "/{0}/{1}/".format(environment, self.args.repo)
            checksum_type = self.args.checksum_type

            pulp = RepositoryAPI(self.connections[environment])
            response = pulp.create_and_configure(
                id=repo_id,
                display_name=display_name,
                description=repo_id,
                notes={'_repo-type': 'rpm-repo'},
                importer_type_id='yum_importer',
                importer_config={},
                distributors=[{
                    'distributor_id': 'yum_distributor',
                    'distributor_type_id': 'yum_distributor',
                    'distributor_config': {
                        'relative_url': relative_url,
                        'http': True,
                        'https': True,
                        'checksum_type': checksum_type
                    },
                    'auto_publish': True,
                    'relative_path': relative_url
                }])

            if response.response_code == Constants.PULP_POST_CREATED:
                Log.log_info("%s created in %s", display_name, environment)
            else:
                Log.log_info("failed to create %s in %s", display_name,
                             environment)
                Log.log_debug(response)

            pulp = RepositoryActionsAPI(self.connections[environment])
            response = pulp.publish(repo_id, 'yum_distributor', {})

            if response.response_code == Constants.PULP_POST_ACCEPTED:
                Log.log_info("%s published in %s", display_name, environment)
            else:
                Log.log_info("failed to publish %s in %s", display_name,
                             environment)
                Log.log_debug(response)
コード例 #7
0
ファイル: PulpRepo.py プロジェクト: yithian/juicer
    def create(self, name, environment, checksumtype='sha256'):
        repo_id = "{0}-{1}".format(name, environment)
        relative_url = "/{0}/{1}/".format(environment, name)
        checksumtype = checksumtype

        pulp = RepositoryAPI(self.connection)
        response = pulp.create_and_configure(id=repo_id,
                                             display_name=name,
                                             description=repo_id,
                                             notes={'_repo-type': 'rpm-repo'},
                                             importer_type_id='yum_importer',
                                             importer_config={},
                                             distributors=[{
                                                 'distributor_id':
                                                 'yum_distributor',
                                                 'distributor_type_id':
                                                 'yum_distributor',
                                                 'distributor_config': {
                                                     'relative_url':
                                                     relative_url,
                                                     'http': True,
                                                     'https': True,
                                                     'checksum_type':
                                                     checksumtype
                                                 },
                                                 'auto_publish':
                                                 True,
                                                 'relative_path':
                                                 relative_url
                                             }])

        if response.response_code == Constants.PULP_POST_CREATED:
            Log.log_info("%s created in %s", name, environment)
        else:
            Log.log_info("failed to create %s in %s", name, environment)
            Log.log_debug(response)
コード例 #8
0
ファイル: RepoCreateCommand.py プロジェクト: tbielawa/juicer
    def run(self):
        from pulp.bindings.repository import RepositoryAPI
        from pulp.bindings.repository import RepositoryActionsAPI

        for environment in self.args.environment:
            repo_id = "{0}-{1}".format(self.args.repo, environment)
            display_name = self.args.repo
            relative_url = "/{0}/{1}/".format(environment, self.args.repo)
            checksum_type = self.args.checksum_type

            pulp = RepositoryAPI(self.connections[environment])
            response = pulp.create_and_configure(
                id=repo_id,
                display_name=display_name,
                description=repo_id,
                notes={'_repo-type': 'rpm-repo'},
                importer_type_id='yum_importer',
                importer_config={},
                distributors=[{'distributor_id': 'yum_distributor',
                               'distributor_type_id': 'yum_distributor',
                               'distributor_config': {
                                   'relative_url': relative_url,
                                   'http': True,
                                   'https': True,
                                   'checksum_type': checksum_type
                               },
                               'auto_publish': True,
                               'relative_path': relative_url
                           }]
            )

            if response.response_code == Constants.PULP_POST_CREATED:
                Log.log_info("%s created in %s", display_name, environment)
            else:
                Log.log_info("failed to create %s in %s", display_name, environment)
                Log.log_debug(response)

            pulp = RepositoryActionsAPI(self.connections[environment])
            response = pulp.publish(repo_id, 'yum_distributor', {})

            if response.response_code == Constants.PULP_POST_ACCEPTED:
                Log.log_info("%s published in %s", display_name, environment)
            else:
                Log.log_info("failed to publish %s in %s", display_name, environment)
                Log.log_debug(response)
コード例 #9
0
ファイル: PulpUpload.py プロジェクト: yithian/juicer
    def upload(self, path, repo, environment):
        pulp = UploadAPI(self.connection)
        unit_key, unit_metadata = self.generate_upload_data(path)
        name = os.path.basename(path)
        repo_id = "{0}-{1}".format(repo, environment)

        ################################################################
        # Initialize upload
        ################################################################
        response = pulp.initialize_upload()
        if response.response_code == Constants.PULP_POST_CREATED:
            Log.log_debug("Initialized upload process for %s" % name)
        else:
            raise SystemError("Failed to initialize upload process for %s" %
                              name)
        upload_id = response.response_body['upload_id']

        ################################################################
        # Upload chunks w/ Constants.UPLOAD_AT_ONCE size
        ################################################################
        size = os.path.getsize(path)
        rpm_fd = open(path, 'rb')
        total_seeked = 0
        rpm_fd.seek(0)

        while total_seeked < size:
            chunk = rpm_fd.read(Constants.UPLOAD_AT_ONCE)
            last_offset = total_seeked
            total_seeked += len(chunk)

            Log.log_notice("Seeked %s data... (total seeked: %s)" %
                           (len(chunk), total_seeked))

            response = pulp.upload_segment(upload_id, last_offset, chunk)
            if response.response_code is not Constants.PULP_PUT_OK:
                Log.log_debug("Failed to upload %s" % name)
                raise SystemError("Failed to upload %s" % name)

        ################################################################
        # Import upload
        ################################################################
        response = pulp.import_upload(upload_id, repo_id, 'rpm', unit_key,
                                      unit_metadata)
        if response.response_code not in [
                Constants.PULP_POST_OK, Constants.PULP_POST_ACCEPTED
        ]:
            Log.log_error("Failed to import upload for %s" % name)
            raise SystemError("Failed to import upload for %s" % name)

        Log.log_debug("RPM upload %s complete" % name)

        ################################################################
        # Finalize upload by cleaning up request on server
        ################################################################
        response = pulp.delete_upload(upload_id)
        if response.response_code != Constants.PULP_DELETE_OK:
            Log.log_error("Failed to clean up upload for %s" % name)
            raise SystemError("Failed to clean up upload for %s" % name)

        ################################################################
        # Publish the repo
        ################################################################
        pulp_repo = PulpRepo(self.connection)
        pulp_repo.publish(name=repo, environment=environment)

        ################################################################
        # FIN
        ################################################################
        Log.log_info("successfully uploaded %s" % name)
コード例 #10
0
ファイル: PulpUpload.py プロジェクト: yithian/juicer
    def upload(self, path, repo, environment):
        pulp = UploadAPI(self.connection)
        unit_key, unit_metadata = self.generate_upload_data(path)
        name = os.path.basename(path)
        repo_id = "{0}-{1}".format(repo, environment)

        ################################################################
        # Initialize upload
        ################################################################
        response = pulp.initialize_upload()
        if response.response_code == Constants.PULP_POST_CREATED:
            Log.log_debug("Initialized upload process for %s" % name)
        else:
            raise SystemError("Failed to initialize upload process for %s" %
                              name)
        upload_id = response.response_body['upload_id']

        ################################################################
        # Upload chunks w/ Constants.UPLOAD_AT_ONCE size
        ################################################################
        size = os.path.getsize(path)
        rpm_fd = open(path, 'rb')
        total_seeked = 0
        rpm_fd.seek(0)

        while total_seeked < size:
            chunk = rpm_fd.read(Constants.UPLOAD_AT_ONCE)
            last_offset = total_seeked
            total_seeked += len(chunk)

            Log.log_notice("Seeked %s data... (total seeked: %s)" %
                           (len(chunk), total_seeked))

            response = pulp.upload_segment(upload_id, last_offset, chunk)
            if response.response_code is not Constants.PULP_PUT_OK:
                Log.log_debug("Failed to upload %s" % name)
                raise SystemError("Failed to upload %s" % name)

        ################################################################
        # Import upload
        ################################################################
        response = pulp.import_upload(upload_id,
                                      repo_id,
                                      'rpm',
                                      unit_key,
                                      unit_metadata)
        if response.response_code not in [Constants.PULP_POST_OK,
                                          Constants.PULP_POST_ACCEPTED]:
            Log.log_error("Failed to import upload for %s" % name)
            raise SystemError("Failed to import upload for %s" % name)

        Log.log_debug("RPM upload %s complete" % name)

        ################################################################
        # Finalize upload by cleaning up request on server
        ################################################################
        response = pulp.delete_upload(upload_id)
        if response.response_code != Constants.PULP_DELETE_OK:
            Log.log_error("Failed to clean up upload for %s" % name)
            raise SystemError("Failed to clean up upload for %s" % name)

        ################################################################
        # Publish the repo
        ################################################################
        pulp_repo = PulpRepo(self.connection)
        pulp_repo.publish(name=repo,
                          environment=environment)

        ################################################################
        # FIN
        ################################################################
        Log.log_info("successfully uploaded %s" % name)
コード例 #11
0
ファイル: CartDeleteCommand.py プロジェクト: yithian/juicer
 def run(self):
     cart = Cart(self.args.cartname)
     cart.delete()
     Log.log_info("successfully deleted cart %s" % cart.name)
コード例 #12
0
ファイル: RPMUploadCommand.py プロジェクト: yithian/juicer
 def run(self):
     for environment in self.args.environment:
         Log.log_info("Starting upload for %s environment" % environment)
         cart = Cart('upload-cart', self.args.r)
         cart.upload_items(environment, self.connections[environment])
コード例 #13
0
ファイル: CartShowCommand.py プロジェクト: yithian/juicer
 def run(self):
     cart = Cart(self.args.cartname, autoload=True)
     Log.log_info(str(cart))