def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha segment_id = masakariclient_utils.get_uuid_by_name( masakari_client, parsed_args.segment_id) uuid = masakariclient_utils.get_uuid_by_name(masakari_client, parsed_args.host, segment=segment_id) attrs = { 'name': parsed_args.name, 'type': parsed_args.type, 'control_attributes': parsed_args.control_attributes, 'reserved': parsed_args.reserved, 'on_maintenance': parsed_args.on_maintenance, } # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: masakari_client.update_host(uuid, segment_id=segment_id, **attrs) except sdk_exc.NotFoundException: # Reraise. To unify exceptions with other functions. LOG.debug(_("Segment host is not found: %s"), parsed_args) raise sdk_exc.ResourceNotFound(_('No Host found for %s') % uuid) except Exception as ex: LOG.debug(_("Failed to update segment host: %s"), parsed_args) raise ex return _show_host(masakari_client, segment_id, uuid)
def do_host_create(service, args): """Create a host.""" try: segment_id = utils.get_uuid_by_name(service, args.segment_id) attrs = { 'name': args.name, 'type': args.type, 'control_attributes': args.control_attributes, 'reserved': args.reserved, 'on_maintenance': args.on_maintenance, } utils.remove_unspecified_items(attrs) host = service.create_host(segment_id, **attrs) utils.print_dict(host.to_dict()) except Exception as e: print(e)
def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha uuid = masakariclient_utils.get_uuid_by_name(masakari_client, parsed_args.segment) attrs = { 'name': parsed_args.name, 'description': parsed_args.description, 'recovery_method': parsed_args.recovery_method, 'service_type': parsed_args.service_type, } if masakari_client.default_microversion: api_version = api_versions.APIVersion( masakari_client.default_microversion) if (api_version >= api_versions.APIVersion("1.2") and parsed_args.is_enabled is not None): attrs['is_enabled'] = strutils.bool_from_string( parsed_args.is_enabled, strict=True) # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: masakari_client.update_segment(segment=uuid, **attrs) # Reraise. To unify exceptions with other functions. except sdk_exc.NotFoundException: LOG.debug(_("Segment is not found: %s"), parsed_args) raise sdk_exc.ResourceNotFound(_('No Segment found for %s') % uuid) except Exception as ex: LOG.debug(_("Failed to update segment: %s"), parsed_args) raise ex return _show_segment(masakari_client, uuid)
def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha attrs = { 'name': parsed_args.name, 'description': parsed_args.description, 'recovery_method': parsed_args.recovery_method, 'service_type': parsed_args.service_type, } if masakari_client.default_microversion: api_version = api_versions.APIVersion( masakari_client.default_microversion) if (api_version >= api_versions.APIVersion("1.2") and parsed_args.is_enabled is not None): attrs['is_enabled'] = strutils.bool_from_string( parsed_args.is_enabled, strict=True) # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: segment = masakari_client.create_segment(**attrs) except Exception as ex: LOG.debug(_("Failed to create segment: %s"), parsed_args) raise ex return _show_segment(masakari_client, segment.uuid)
def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha uuid = masakariclient_utils.get_uuid_by_name(masakari_client, parsed_args.segment) attrs = { 'name': parsed_args.name, 'description': parsed_args.description, 'recovery_method': parsed_args.recovery_method, 'service_type': parsed_args.service_type, } # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: masakari_client.update_segment(segment=uuid, **attrs) # Reraise. To unify exceptions with other functions. except sdk_exc.NotFoundException: LOG.debug(_("Segment is not found: %s"), parsed_args) raise sdk_exc.ResourceNotFound(_('No Segment found for %s') % uuid) except Exception as ex: LOG.debug(_("Failed to update segment: %s"), parsed_args) raise ex return _show_segment(masakari_client, uuid)
def do_segment_update(service, args): """Update a segment.""" try: segment_id = utils.get_uuid_by_name(service, args.id) attrs = { 'name': args.name, 'description': args.description, 'recovery_method': args.recovery_method, 'service_type': args.service_type, } attrs = utils.remove_unspecified_items(attrs) segment = service.update_segment(segment_id, **attrs) utils.print_dict(segment.to_dict()) except Exception as e: print(e)
def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha attrs = { 'name': parsed_args.name, 'description': parsed_args.description, 'recovery_method': parsed_args.recovery_method, 'service_type': parsed_args.service_type, } # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: segment = masakari_client.create_segment(**attrs) except Exception as ex: LOG.debug(_("Failed to create segment: %s"), parsed_args) raise ex return _show_segment(masakari_client, segment.uuid)
def take_action(self, parsed_args): masakari_client = self.app.client_manager.ha segment_id = masakariclient_utils.get_uuid_by_name( masakari_client, parsed_args.segment_id) attrs = { 'name': parsed_args.name, 'type': parsed_args.type, 'control_attributes': parsed_args.control_attributes, 'reserved': parsed_args.reserved, 'on_maintenance': parsed_args.on_maintenance, } # Remove not specified keys attrs = masakariclient_utils.remove_unspecified_items(attrs) try: host = masakari_client.create_host(segment_id=segment_id, **attrs) except Exception as ex: LOG.debug(_("Failed to create segment host: %s"), parsed_args) raise ex return _show_host(masakari_client, segment_id, host.uuid)