Beispiel #1
0
    def get_service_health(self, service, env, slice=None):
        svc = Service(service, env)
        result = svc.get_health(slice)

        if result is None:
            self.show_result(
                {}, 'Could not get health status for {0}'.format(service))
            return False

        if slice is None:
            message = [self.format_health(service) for service in result]
            is_healthy = all(
                service.get("OverallHealth") == "Healthy"
                for service in result)
        else:
            n = len(result)
            if n == 0:
                message = "{0} is not expected here and is not running here".format(
                    slice)
                is_healthy = False
            elif n > 1:
                message = "Expected one service but found {0}".format(n)
                is_healthy = False
            else:
                (is_healthy,
                 message) = self.get_health_summary(env, service, slice,
                                                    result[0])
        self.show_result(result, message)
        return is_healthy
Beispiel #2
0
 def toggle_service_slices(self, service, env):
     svc = Service(service, env)
     upstream = svc.toggle()
     self.show_result(
         upstream.__dict__,
         "{0} is now configured active for {1} in {2}".format(
             upstream.slice, service, env))
Beispiel #3
0
    def deploy_service(self, service, version, env, slice=None):
        dry_run = self.opts.get('dry-run', False)
        role = self.opts.get('role', None)
        svc = Service(service, env, version)
        result = svc.deploy(slice=slice, dry_run=dry_run, role=role)

        if dry_run:
            self.show_result(result, "Deployment dry run was successful")
        else:
            self.show_result(result, result.get('id'))
Beispiel #4
0
    def publish_service_file(self, service, version, file):
        file_path = os.path.abspath(file)
        if not os.path.isfile(file_path):
            print("{0} is not a valid file".format(file))
            return

        svc = Service(service)
        file_size = self.convert_size(os.path.getsize(file_path))
        with open(file_path, 'rb') as file:
            result = svc.publish(file, version)

        if result is True:
            self.show_result({'success': True}, '{0} {1} published {2}'.format(
                service, version, file_size))
        else:
            self.show_result({'success': False},
                             'There was an issue publishing this service')
Beispiel #5
0
 def get_service_slice(self, service, env):
     svc = Service(service, env)
     active = self.cmds.get('active', False)
     result = svc.get_slices(active)
     messages = [self.format_slice(slice) for slice in result]
     self.show_result(result, messages)
Beispiel #6
0
 def get_deploy_status(self, deploy_id):
     result = Service.get_deployment_by_id(deploy_id)
     self.show_result(
         result,
         "Deployment: {0}".format(result.get('Value').get('Status')))
     return result