예제 #1
0
def configure_sx(application):
    reload(sys)
    sys.setdefaultencoding('utf8')
    settings = config.get_settings()
    logger.debug('Configure called with settings: %s.' % settings)

    # SX initialization
    global _sxcontroller
    if os.path.isfile(settings['sx.admin_key']):
        user_data = sxclient.UserData.from_key_path(settings['sx.admin_key'])
    else:
        user_data = sxclient.UserData.from_key(settings['sx.admin_key'])

    cluster = sxclient.Cluster(settings['sx.cluster_name'],
                               ip_addresses=settings.get('sx.host_list'),
                               is_secure=settings.get('sx.ssl', True),
                               port=settings.get('sx.port'),
                               verify_ssl_cert=settings.get(
                                   'sx.verify_cert', True))
    _sxcontroller = sxclient.SXController(cluster, user_data=user_data)
    logger.debug('SXController initialized.')

    # # SX cleanup initialization
    config.register_signal(signal.SIGINT, close_sxcontroller)
    config.register_signal(signal.SIGTERM, close_sxcontroller)
    config.register_signal(signal.SIGQUIT, close_sxcontroller)
    logger.debug('Cleanup actions initialized.')

    # Other stuff
    requests.packages.urllib3.disable_warnings()  # unnecessary noise

    logger.info('Fully configured SX.')
def get_node_list(host_address, key_path, verify_ssl=True, port=None):
    cluster = sxclient.Cluster(host_address,
                               verify_ssl_cert=verify_ssl,
                               port=port)
    user_data = sxclient.UserData.from_key_path(key_path)
    sx = sxclient.SXController(cluster, user_data)
    nodelist = sx.listNodes.json_call()['nodeList']
    return nodelist
예제 #3
0
 def __init__(
         self, cluster_name, node_address, is_secure=True, verify_ssl=True,
         port=None
 ):
     self.cluster = sxclient.Cluster(
         cluster_name, node_address, is_secure=is_secure,
         verify_ssl_cert=verify_ssl, port=port
     )
     self.session = sxclient.ClusterSession(self.cluster)
     self.node_address = node_address
예제 #4
0
 def __init__(
         self, remote_path, cluster_name, key_path, cluster_address=None,
         is_secure=True, verify_ssl=True, port=None, delete_after=False,
         timeout=sxclient.controller.DEFAULT_REQUEST_TIMEOUT
 ):
     cluster = sxclient.Cluster(
         cluster_name, cluster_address, is_secure=is_secure,
         verify_ssl_cert=verify_ssl, port=port
     )
     user_data = sxclient.UserData.from_key_path(key_path)
     self.sx = sxclient.SXController(
         cluster, user_data, request_timeout=timeout
     )
     remote_path = remote_path.decode('utf-8')
     self.volume, self.filename = self.split_remote_path(remote_path)
     self.delete_after = delete_after
예제 #5
0
 def __init__(self,
              cluster_name,
              key_path,
              cluster_address=None,
              is_secure=True,
              verify_ssl=True,
              port=None,
              timeout=sxclient.controller.DEFAULT_REQUEST_TIMEOUT):
     cluster = sxclient.Cluster(cluster_name,
                                cluster_address,
                                is_secure=is_secure,
                                verify_ssl_cert=verify_ssl,
                                port=port)
     user_data = sxclient.UserData.from_key_path(key_path)
     self.sx = sxclient.SXController(cluster,
                                     user_data,
                                     request_timeout=timeout)
예제 #6
0
def main():
    args = parse_command_line()

    setup_logging(args.verbose)

    try:
        cluster = sxclient.Cluster(args.cluster_name, args.cluster_address,
                                   args.is_secure, args.verify, args.port)
        user_data = sxclient.UserData.from_key_path(args.key_path)

        with contextlib.closing(sxclient.SXController(cluster,
                                                      user_data)) as sx:
            s3importer = S3Importer(volume_size=args.volume_size,
                                    volume_owner=args.owner,
                                    volume_replica=args.replica_count,
                                    sx=sx,
                                    volume_prefix=args.volume_prefix,
                                    subdir=args.subdir,
                                    worker_num=args.workers)
            s3importer.import_all()

    except (Exception, KeyboardInterrupt) as exc:
        error_exit(exc)
    def __init__(self,
                 volumes,
                 cluster_name,
                 key_path,
                 cluster_address=None,
                 is_secure=True,
                 verify_ssl=True,
                 port=None,
                 timeout=sxclient.controller.DEFAULT_REQUEST_TIMEOUT):
        cluster = sxclient.Cluster(cluster_name,
                                   cluster_address,
                                   is_secure=is_secure,
                                   verify_ssl_cert=verify_ssl,
                                   port=port)
        user_data = sxclient.UserData.from_key_path(key_path)
        self.sx = sxclient.SXController(cluster,
                                        user_data,
                                        request_timeout=timeout)
        self.volumes = volumes

        if len(self.volumes) == 1 and 'ALL' in self.volumes:
            self.check_all_volumes = True
        else:
            self.check_all_volumes = False
예제 #8
0
def sx_cluster(sx_host):
    return sxclient.Cluster(sx_host, verify_ssl_cert=False, is_secure=False)