示例#1
0
    def execute(self):
        log.debug('application name will be: %s', self.fullname)

        if self.manifest:
            manifestPath = self.manifest
        else:
            try:
                manifestPath = _locateFile(self.path, 'manifest.json')
            except IOError:
                log.error("unable to locate manifest.json")
                raise ToolsError("unable to locate manifest.json")

        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(manifestPath)

        with printer('Uploading manifest'):
            channel = yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)
            yield channel.rx.get()

        try:
            response = yield self.client.build(self.path, tag=self.fullname, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('building failed with error code {0} {1}'.format(response.code,
                                                                                  response.body))
            response = yield self.client.push(self.fullname, auth={}, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('pushing failed with error code {0} {1}'.format(response.code,
                                                                                 response.body))
        except Exception as err:
            log.error("Error occurred. %s Erase manifest" % err)
            channel = yield self.storage.remove('manifests', self.name)
            yield channel.rx.get()
            raise err
示例#2
0
文件: app.py 项目: padm/cocaine-tools
    def execute(self):
        log.debug('application name will be: %s', self.fullname)

        if self.manifest:
            manifestPath = self.manifest
        else:
            manifestPath = _locateFile(self.path, 'manifest.json')

        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(manifestPath)

        with printer('Uploading manifest'):
            yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)

        try:
            response = yield self.client.build(self.path, tag=self.fullname, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('upload failed with error code {0}'.format(response.code))

            response = yield self.client.push(self.fullname, {}, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('upload failed with error code {0}'.format(response.code))
        except Exception as err:
            log.error("Error occurred. Erase manifest")
            yield self.storage.remove('manifests', self.name)
            raise err
示例#3
0
    def execute(self):
        log.debug('application name will be: %s', self.fullname)

        if self.manifest:
            manifestPath = self.manifest
        else:
            try:
                manifestPath = _locateFile(self.path, 'manifest.json')
            except IOError:
                log.error("unable to locate manifest.json")
                raise ToolsError("unable to locate manifest.json")

        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(manifestPath)

        with printer('Uploading manifest'):
            channel = yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)
            yield channel.rx.get()

        try:
            response = yield self.client.build(self.path, tag=self.fullname, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('building failed with error code {0} {1}'.format(response.code,
                                                                                  response.body))
            response = yield self.client.push(self.fullname, auth={}, streaming=self._on_read)
            if response.code != 200:
                raise ToolsError('pushing failed with error code {0} {1}'.format(response.code,
                                                                                 response.body))
        except Exception as err:
            log.error("Error occurred. %s Erase manifest", err)
            channel = yield self.storage.remove('manifests', self.name)
            yield channel.rx.get()
            raise err
示例#4
0
 def execute(self):
     if self.content:
         content = CocaineConfigReader.load(self.content,
                                            validate=self._validate)
     else:
         content = msgpack.dumps({})
     yield self.storage.write(GROUP_COLLECTION, self.name, content,
                              GROUPS_TAGS)
示例#5
0
 def execute(self):
     """
     Encodes manifest and package files and (if successful) uploads them into storage
     """
     log.info('Uploading "%s"... ', self.name)
     manifest = CocaineConfigReader.load(self.manifest)
     package = msgpack.dumps(readArchive(self.package))
     yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)
     yield self.storage.write('apps', self.name, package, APPS_TAGS)
     log.info('OK')
示例#6
0
    def execute(self):
        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(self.manifest)

        with printer('Reading package "%s"', self.package):
            package = msgpack.dumps(readArchive(self.package))

        with printer('Uploading manifest'):
            yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)

        with printer('Uploading application "%s"', self.name):
            yield self.storage.write('apps', self.name, package, APPS_TAGS)
示例#7
0
    def execute(self):
        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(self.manifest)

        with printer('Reading package "%s"', self.package):
            package = msgpack.dumps(readArchive(self.package))

        with printer('Uploading manifest'):
            yield self.storage.write('manifests', self.name, manifest,
                                     APPS_TAGS)

        with printer('Uploading application "%s"', self.name):
            yield self.storage.write('apps', self.name, package, APPS_TAGS)
示例#8
0
    def execute(self):
        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(self.manifest)

        #  Not only a manifest is being uploaded,
        #  self.package could be None if manifest_only=True
        if self.package is not None:
            with printer('Reading package "%s"', self.package):
                package = msgpack.dumps(readArchive(self.package))

            with printer('Uploading application "%s"', self.name):
                yield self.storage.write('apps', self.name, package, APPS_TAGS)

        with printer('Uploading manifest'):
            yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)
示例#9
0
    def execute(self):
        with printer('Loading manifest'):
            manifest = CocaineConfigReader.load(self.manifest)

        #  Not only a manifest is being uploaded,
        #  self.package could be None if manifest_only=True
        if self.package is not None:
            with printer('Reading package "%s"', self.package):
                package = msgpack.dumps(readArchive(self.package))

            with printer('Uploading application "%s"', self.name):
                channel = yield self.storage.write('apps', self.name, package, APPS_TAGS)
                yield channel.rx.get()

        with printer('Uploading manifest'):
            channel = yield self.storage.write('manifests', self.name, manifest, APPS_TAGS)
            yield channel.rx.get()

        raise gen.Return("Uploaded successfully")
示例#10
0
 def execute(self):
     with printer('Loading profile'):
         profile = CocaineConfigReader.load(self.profile)
     with printer('Uploading "%s"', self.name):
         yield self.storage.write('profiles', self.name, profile,
                                  PROFILES_TAGS)
示例#11
0
 def execute(self):
     runlist = CocaineConfigReader.load(self.runlist)
     log.info('Uploading "%s"... ', self.name)
     yield self.storage.write('runlists', self.name, runlist, RUNLISTS_TAGS)
     log.info('OK')
示例#12
0
 def execute(self):
     with printer('Loading profile'):
         profile = CocaineConfigReader.load(self.profile)
     with printer('Uploading "%s"', self.name):
         yield upload_profile(self.storage, self.name, profile)
 def execute(self):
     log.info('Uploading "%s"... ', self.name)
     profile = CocaineConfigReader.load(self.profile)
     yield self.storage.write('profiles', self.name, profile, PROFILES_TAGS)
     log.info('OK')
示例#14
0
 def __init__(self, storage, name, content):
     super(Create, self).__init__(storage, 'group', name)
     self.content = CocaineConfigReader.load(content, validate=validate_routing_group)
示例#15
0
 def execute(self):
     with printer('Loading profile'):
         profile = CocaineConfigReader.load(self.profile)
     with printer('Uploading "%s"', self.name):
         yield self.storage.write('profiles', self.name, profile, PROFILES_TAGS)
示例#16
0
def test_config_reader():
    CocaineConfigReader.load(os.path.join(os.path.abspath(os.path.dirname(__file__)),
                             "fixtures/simple_app/manifest.json"))
示例#17
0
 def execute(self):
     if self.content:
         content = CocaineConfigReader.load(self.content, validate=self._validate)
     else:
         content = msgpack.dumps({})
     yield self.storage.write(GROUP_COLLECTION, self.name, content, GROUPS_TAGS)
示例#18
0
 def execute(self):
     runlist = CocaineConfigReader.load(self.runlist)
     with printer('Uploading "%s"', self.name):
         yield self.storage.write('runlists', self.name, runlist,
                                  RUNLISTS_TAGS)
示例#19
0
 def execute(self):
     runlist = CocaineConfigReader.load(self.runlist)
     with printer('Uploading "%s"', self.name):
         yield self.storage.write('runlists', self.name, runlist, RUNLISTS_TAGS)
示例#20
0
 def execute(self):
     runlist = CocaineConfigReader.load(self.runlist)
     log.info('Uploading "%s"... ', self.name)
     yield self.storage.write('runlists', self.name, runlist, RUNLISTS_TAGS)
     log.info('OK')