def get_service_groups(service, namespace=None): """ Services are objects stored with some metadata, they look like (for a service named "nova"): { group_names: {'rwx': ['images']}, groups: {} } After populating the group, it looks like: { group_names: {'rwx': ['images']}, groups: { 'images': { pools: ['glance'], services: ['nova'] } } } """ service_json = monitor_key_get(service='admin', key="cephx.services.{}".format(service)) try: service = json.loads(service_json) except TypeError: service = None except ValueError: service = None if service: service['groups'] = _build_service_groups(service, namespace) else: service = {'group_names': {}, 'groups': {}} return service
def get_service_groups(service, namespace=None): """Services are objects stored with some metadata, they look like (for a service named "nova"): { group_names: {'rwx': ['images']}, groups: {} } After populating the group, it looks like: { group_names: {'rwx': ['images']}, groups: { 'images': { pools: ['glance'], services: ['nova'] } } } """ service_json = monitor_key_get(service='admin', key="cephx.services.{}".format(service)) try: service = json.loads(service_json) except (TypeError, ValueError): service = None if service: service['groups'] = _build_service_groups(service, namespace) else: service = {'group_names': {}, 'groups': {}} return service
def get_group(group_name): """A group is a structure to hold data about a named group, structured as: { pools: ['glance'], services: ['nova'] } """ group_key = get_group_key(group_name=group_name) group_json = monitor_key_get(service='admin', key=group_key) try: group = json.loads(group_json) except (TypeError, ValueError): group = None if not group: group = {'pools': [], 'services': []} return group
def get_group(group_name): """A group is a structure to hold data about a named group, structured as: { pools: ['glance'], services: ['nova'] } """ group_key = get_group_key(group_name=group_name) group_json = monitor_key_get(service='admin', key=group_key) try: group = json.loads(group_json) except (TypeError, ValueError): group = None if not group: group = { 'pools': [], 'services': [] } return group
def wait_on_previous_node(previous_node): log("Previous node is: {}".format(previous_node)) previous_node_finished = monitor_key_exists( 'admin', "{}_done".format(previous_node)) while previous_node_finished is False: log("{} is not finished. Waiting".format(previous_node)) # Has this node been trying to upgrade for longer than # 10 minutes? # If so then move on and consider that node dead. # NOTE: This assumes the clusters clocks are somewhat accurate # If the hosts clock is really far off it may cause it to skip # the previous node even though it shouldn't. current_timestamp = time.time() previous_node_start_time = monitor_key_get( 'admin', "{}_start".format(previous_node)) if (current_timestamp - (10 * 60)) > previous_node_start_time: # Previous node is probably dead. Lets move on if previous_node_start_time is not None: log( "Waited 10 mins on node {}. current time: {} > " "previous node start time: {} Moving on".format( previous_node, (current_timestamp - (10 * 60)), previous_node_start_time)) return else: # I have to wait. Sleep a random amount of time and then # check if I can lock,upgrade and roll. wait_time = random.randrange(5, 30) log('waiting for {} seconds'.format(wait_time)) time.sleep(wait_time) previous_node_finished = monitor_key_exists( 'admin', "{}_done".format(previous_node))
def wait_on_previous_node(previous_node): log("Previous node is: {}".format(previous_node)) previous_node_finished = monitor_key_exists( 'admin', "{}_done".format(previous_node)) while previous_node_finished is False: log("{} is not finished. Waiting".format(previous_node)) # Has this node been trying to upgrade for longer than # 10 minutes? # If so then move on and consider that node dead. # NOTE: This assumes the clusters clocks are somewhat accurate # If the hosts clock is really far off it may cause it to skip # the previous node even though it shouldn't. current_timestamp = time.time() previous_node_start_time = monitor_key_get( 'admin', "{}_start".format(previous_node)) if (current_timestamp - (10 * 60)) > previous_node_start_time: # Previous node is probably dead. Lets move on if previous_node_start_time is not None: log( "Waited 10 mins on node {}. current time: {} > " "previous node start time: {} Moving on".format( previous_node, (current_timestamp - (10 * 60)), previous_node_start_time)) return else: # I have to wait. Sleep a random amount of time and then # check if I can lock,upgrade and roll. wait_time = random.randrange(5, 30) log('waiting for {} seconds'.format(wait_time)) time.sleep(wait_time) previous_node_finished = monitor_key_exists( 'admin', "{}_done".format(previous_node))